Skip to content

[Feature]: Let workspaces opt out of relaunching the agent they were created with #10578

Closed

Description

@jeongph

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

  1. + → Create worktree → pick a project, set Agent to Claude, create.
  2. 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).
  3. Click that workspace in the sidebar again.
  4. Actual: Claude launches on its own, no user action.
  5. 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.
  • activateAndRevealWorktree falls 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 from createdWithAgent with prompt: '' and allowEmptyPromptLaunch: true.
  • It only fires when the workspace has no renderable tabs — shouldAutoCreateInitialTerminal(renderableTabCount) is renderableTabCount === 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:

  1. No opt-out, and an explicit exit is not respected. createdWithAgent records 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.
  2. It is labeled resume but is not one. The payload reports telemetry.request_kind: 'resume' with launch_source: 'sidebar', yet it launches a brand-new empty-prompt session with no resumeProviderSession — prior conversation is not carried over. Real resume is handled separately by resumeSleepingAgentSessionsForWorktree. 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 a lastAgentExitedCleanly flag) so a deliberately-ended agent is not resurrected, while crash/sleep paths still relaunch.
  • Fix the telemetry request_kind for this path so a fresh empty-prompt launch is not counted as a resume.

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 so renderableTabCount !== 0 suppresses 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

  1. AmethystLiang commented on Jul 25, 2026

    @AmethystLiang
    Contributor

    looking into it

  2. added a commit that references this issue on Jul 29, 2026
    3d481f4
  3. nwparker commented on Jul 30, 2026

    @nwparker
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions