Repository navigation
Description
Problem or use case
A worktree created with an agent selected (e.g. Claude) silently relaunches that agent every time the workspace is reopened from the sidebar — even after the user has deliberately exited the agent. There is no way to opt out.
Repro
+→ Create worktree → pick a project, set Agent toClaude, create.- Work in the session, then exit Claude and close the tab (or let the workspace end up with no renderable tabs — sleep/restart also gets you there).
- Click that workspace in the sidebar again.
- Actual: Claude launches on its own, no user action.
- Create another worktree with Agent = Blank Terminal and repeat: only a plain shell opens.
Why this happens (this is intentional today — #1814 "remember worktree creation agent")
- Creation persists the choice as
Worktree.createdWithAgent; picking Blank Terminal stores nothing, which is exactly why the blank case behaves differently. activateAndRevealWorktreefalls back to a synthesized startup whenever the caller passes none:src/renderer/src/lib/worktree-activation.ts:348→opts?.startup ?? buildCreatedAgentReopenStartup(wt)buildCreatedAgentReopenStartup(src/renderer/src/lib/worktree-activation.ts:231-279) builds a launch plan fromcreatedWithAgentwithprompt: ''andallowEmptyPromptLaunch: true.- It only fires when the workspace has no renderable tabs —
shouldAutoCreateInitialTerminal(renderableTabCount)isrenderableTabCount === 0(src/renderer/src/components/terminal/initial-terminal.ts). - Locked in by
reopens an empty worktree with the agent selected at creation time(src/renderer/src/lib/worktree-activation-created-agent.test.ts:60).
So the behavior is by design, but two things about it are questionable:
- No opt-out, and an explicit exit is not respected.
createdWithAgentrecords how the workspace was created, and is then treated as a standing instruction for every future reopen. Quitting the agent is a clear signal the user is done with it; the next sidebar click overrides that, spends tokens, and (for agents with an approval-bypass default arg) starts a permissive session unprompted. There is no setting to disable it. - It is labeled
resumebut is not one. The payload reportstelemetry.request_kind: 'resume'withlaunch_source: 'sidebar', yet it launches a brand-new empty-prompt session with noresumeProviderSession— prior conversation is not carried over. Real resume is handled separately byresumeSleepingAgentSessionsForWorktree. The mismatch makes the telemetry misleading and sets the wrong user expectation.
Note that the opposite expectation also exists in the wild (#9772 asks for a default agent to open reliably on workspace click), so this is about making the behavior selectable rather than removing it.
Proposed solution
Preferred: make the reopen relaunch a real setting instead of implicit behavior, e.g. Reopen workspaces with the agent they were created with (default on, to preserve today's behavior), surfaced in Settings → Agents next to the default-agent controls.
Additionally, either of these would fix the sharper part of the complaint:
- Treat a clean agent exit as consent withdrawal — clear or shadow
createdWithAgent(or record alastAgentExitedCleanlyflag) so a deliberately-ended agent is not resurrected, while crash/sleep paths still relaunch. - Fix the telemetry
request_kindfor this path so a fresh empty-prompt launch is not counted as aresume.
Alternatives or additional context
- Workaround today: create the worktree with Blank Terminal and launch the agent manually from the tab bar
+, or leave a non-agent tab open sorenderableTabCount !== 0suppresses the relaunch. Neither is discoverable. - Platform-independent (renderer-side activation path); applies to git worktrees, folder workspaces, and SSH/remote projects alike.
- Related: #6945 already went the "don't auto-open agent tabs the user didn't ask for" direction for sleeping-session resume; this path never got the same treatment.
Reported on macOS.
Activity
AmethystLiang commentedon Jul 25, 2026
looking into it
feat(agents): opt out of reopening workspaces with creation agent
nwparker commentedon Jul 30, 2026
Resolved by #10647. Reopening or activating an empty workspace no longer synthesizes a startup from
createdWithAgent; only an explicit startup request can launch a new agent. This respects a user’s prior exit across worktrees, folder workspaces, and remote projects. The daemon-history follow-up in #11423 is separate and is also merged.