Skip to content

Keep ACP steers working through settings-driven agent restarts - #6404

Merged
ymichael merged 1 commit into
mainfrom
bb/acp-steer-with-permission-mode-change-looks-hung-thr_eb5u4tftq7
Oct 27, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/acp-steer-with-permission-mode-change-looks-hung-thr_eb5u4tftq7

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When a steer changes an ACP launch setting (for example permission mode Full → Accept Edits), the ACP bridge restarts the agent process and reloads its session before sending the steer. rebuildAgentSession stopped the old session, which settled the running prompt as interrupted, and the replacement session's startAgentSession emitted session.reset, which deleted the delta assembler's open turn. So for the whole restart (~26s for OpenCode), the thread showed "Worked for Ns", hid the steer, and swapped the stop button for send. It looked hung until a brand-new turn began.

What changed

packages/provider-bridge-acp/src/bridge/bridge.ts:

  • When a running turn needs a rebuild, rebuildAgentSession closes the old prompt's open tool calls (ACP_PROMPT_INTERRUPTED_METHOD) and clears the old session's active prompt without settling the turn.
  • The replacement resume request now carries continuesTurn. When it's set, the session.reset is skipped so the open turn stays.
  • The runTurn loop continues the steer in the same turn on the replacement session, instead of emitting a new turn/started. This matches how a steer without a restart already works.
  • If the replacement fails to start, the turn now settles as failed with the error. Before, it had already ended as interrupted.

No wire change: the events the server receives keep the same shape, so there's no HOST_DAEMON_PROTOCOL_VERSION bump.

How you verified

  • pnpm exec turbo run test typecheck --filter=@bb/provider-bridge-acp: all tests pass, typecheck clean.
  • bridge.test.ts has two new assertions. Both fail on the parent commit and pass on this branch:
    • Stacked permission steers across two rebuilds produce exactly one turn/started and no interrupted completion.
    • A replacement that fails to start ends the turn as failed.
  • End to end on two pnpm start:worktree servers, one per build, with a real OpenCode (opencode/big-pickle) thread steered via bb thread tell --permission-mode accept-edits during sleep 60. A headless browser sampled what was visible every 0.5s.
Scenario Before After
Steer Full → Accept Edits mid-command 10s restart: no "Working...", send button, turn t1 interrupted, new t2 14.5s and 25s restarts: "Working..." + "Steer pending" + stop button throughout, single t1
Stop 3s into the restart, then a follow-up Already idle before Stop Active until Stop, "Stopped manually", the dropped steer is never sent, follow-up works
Steer with no permission change Single turn Unchanged
Idle thread, message with a permission change Working during the restart, new turn Unchanged

AGENT GENERATED

🤖 Generated with Claude Code

A steer that changes launch settings (such as Full -> Accept Edits) makes the
ACP bridge restart the agent and reload its session before sending the steer.
The bridge completed the running turn as interrupted before the restart and
the replacement session reset the thread's assembler state, so the thread
looked idle for the whole restart (~26s for OpenCode) until a new turn began.

The rebuild now keeps the turn open: it closes the old prompt's open tool
calls, skips the assembler reset for the replacement session, and continues
the steer in the same turn, as a steer without a restart already does. If the
replacement fails to start, the turn settles as failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 14abe44 into main Oct 27, 2026
50 checks passed
@ymichael
ymichael deleted the bb/acp-steer-with-permission-mode-change-looks-hung-thr_eb5u4tftq7 branch October 27, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant