[BUG] Worktree isolation clobbers the remote-tracking ref
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Agent worktree isolation cannot base on local branches. Workaround forces clobbering refs/remotes/origin/<default>, destroying the owner's pushed-state signal.
What Should Happen?
When multiple agents work on one box, they should base on each other's landed local work. What gets pushed to the server is the owner's decision alone, and refs/remotes/* must remain truthful so the owner can see what was pushed.
Requested fix (any of, in preference order)
- Let
worktree.baseRefaccept an arbitrary local ref
(e.g. "main" / "refs/heads/main"), or add a
"default-branch" mode meaning the LOCAL default branch.
- Add a per-call base override to the Agent tool's isolation option
(e.g. isolation: {mode: "worktree", base: "main"}).
- At minimum, document that
freshis unsuitable for offline/
sandboxed multi-agent boxes and that the update-ref workaround
destroys the remote-tracking signal.
Error Messages/Logs
Steps to Reproduce
Setup
- Headless/background Claude Code session orchestrating subagents via
the Agent tool with isolation: "worktree", all on one shared dev
box (multi-day, multi-agent project).
- The repository's remote is pushed by the OWNER on their own
schedule; the sandbox itself has no push credentials and never
fetches.
Problem
worktree.baseRef supports exactly two values, and in this topology
both are wrong:
fresh(default) bases every new agent worktree on
refs/remotes/origin/<default-branch>. On a box that never
fetches, that ref goes stale the moment work lands locally; agents
silently build on old code and re-inherit already-fixed bugs
(observed in the field on 2026-07-14: agents reintroduced bugs that
were fixed on local main days earlier).
headbases on the orchestrating session's current HEAD, which is
routinely parked on a docs/orchestrator branch or a mid-edit
worktree. It requires a fragile rebase-before-every-launch
discipline, and its failure mode is silent (stale or dirty base).
The workaround that keeps agents current — runninggit update-ref refs/remotes/origin/main main after every landing —
REPURPOSES the remote-tracking ref and falsifies its meaning. The
owner of this repository used origin/main to know what is actually
pushed to the server and deployed; that signal was silently
destroyed, and deployment-relevant decisions were being made against
a falsified ref. This is corruption of an operational signal, not a
cosmetic inconvenience.
Claude Model
Other
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.198
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
Model: Fable 5