Skip to content

Continue automatically after switching a thread's directory #4778

Description

@tomdale

The workflow

An agent starts work in one checkout, then needs to move the thread to another checkout or worktree to finish the same task. For example: “Switch this thread to /path/to/worktree and continue fixing the failing test there.”

The directory change should be a handoff, not a point where the user has to send another “continue” message.

What happens today

update_environment_directory changes the thread's environment for future turns and instructs the agent to end the current turn. Once the agent follows that instruction, work waits for another user message.

The successful tool response explicitly says:

This applies to future turns; stop work in this turn so the next turn can run from the updated directory.

The running provider keeps its old working directory, so continuing filesystem work in that same turn would be unsafe.

What you would expect

After a successful switch, let the agent end its current turn, then automatically resume the task in a new turn using the selected directory.

  • Allow an explicit opt-out when switching directories is the end of the task.
  • Keep the handoff unobtrusive: no generated prompt in the composer queue, at most a small timeline marker.
  • Respect Stop and replacement turns so preparation finishing late cannot restart cancelled work.
  • Preserve user messages queued or steered while the switch is being prepared.

Context and alternatives

A prototype implements this using BB's durable queue, with an optional continue flag defaulting to true. It is a reference for discussion, not a request to accept that design unchanged. I am seeking sign-off here before opening an upstream PR.

In isolated bb runs, a real tool call produced one continuation in the new directory without another user send. Cancellation, concurrent dispatch, steering, and queue boundaries have regression coverage. The prototype's Stop API/CLI cancels pending continuation even when idle; it does not add an idle composer Stop button.

Related work checked:

  • PR #3336 proposed continuing in the same turn using explicit paths. It was closed without merging; this proposal instead keeps the next-turn working-directory boundary.
  • Issue #3187 and PR #4346 concern Pi tool delivery/session-directory failures. This request is about the extra user interaction after an otherwise successful switch.

The workaround is to send another “continue” message.

Checks

  • I searched open and closed issues for the same request.
  • If an agent wrote this, the body ends with > AGENT GENERATED.

AGENT GENERATED

Activity

  1. added
    threads
    workspaces
    on Oct 2, 2026
  2. bb-slop-cop commented on Oct 2, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied classification: Type: Feature · Priority: Medium · Effort: High. Added labels: threads, workspaces. No existing classification values or labels were replaced; the final Type was re-read and verified.

    Trusted upstream main explicitly instructs the agent to stop after a successful directory change. Automatic next-turn resumption therefore adds behavior rather than fixes an unexpected failure. Medium priority reflects a workflow interruption with a manual workaround; High effort reflects continuation-policy design and cancellation/queue interactions.

    No bug report or pull request: this is a feature requiring product/design decisions, not an eligible simple bug fix.

  3. hxy91819 commented on Oct 3, 2026

    @hxy91819

    I have an independent implementation of this on a fork, rebased on desktop-v0.45.0 (129f6217): desktop-v0.45.0...hxy91819:bb:fix/environment-switch-auto-continue (20 files, +540/−56)

    Differences from the prototype described above:

    • continueCurrentTask is a required boolean on the tool input rather than an optional default-true flag; the tool description tells the agent to set it true when unfinished work should resume and false when switching is the whole task.
    • The continuation is a system-notice queued message (environment-switched) created in the same transaction as the environment switch. It carries the thread's resolved model, reasoning level, permission mode, and service tier captured before the switch, so the continuation turn runs with the same settings.
    • It is skipped when ordinary queued messages already exist or queue auto-send is paused, and cancelled on Stop, pre-start stop, or any new user send or queued message for the thread.
    • A "Workspace switched" timeline row marks the handoff.

    Not addressed: whether the composer queue UI hides the generated continuation; the fork uses the system-notice queued row as is.

    Happy to align with whichever design the maintainers prefer and open a PR once there is sign-off here and I am on the contributor list.

    AGENT GENERATED

  4. added a commit that references this issue on Oct 3, 2026
  5. added a commit that references this issue on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    threadsworkspaces

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions