ACP autonomous turns drop output, settle queued prompts early, and ignore cancellation
Problem
ACP sessions lose autonomous turn events, resolve a queued prompt before its own work completes, and ignore cancellation when no ACP prompt driver exists.
This affects native Goals and other engine-driven autonomous work: BB can appear idle while Kimi continues internally, a follow-up returns an empty end_turn immediately, and Stop does not cancel the active turn.
Original detailed report: dpolishuk/bb-kimi-code#8.
Reproduction on current main
Tested against upstream/main f082f04a0 (the 2.6.2 line) with the real engine and scripted model responses:
- Park an autonomous turn at tool approval.
- Submit an ACP prompt behind it.
- The prompt settles in about 50 ms instead of waiting for its own work, and autonomous output is filtered by driverFor.
- Notify session/cancel for an autonomous turn with no ACP driver. Cancellation never reaches agent.cancel and the turn does not settle.
Expected: autonomous output remains visible, a queued prompt settles only after its own work, and Stop cancels autonomous work. Explicit Stop must keep the existing cancellation behavior for normal prompts.
Proposed fix
- Assign promptId to ACP prompts and correlate turn.started, prompt.completed, and prompt.aborted with the matching driver.
- Forward autonomous assistant, thinking, and tool events instead of dropping them when no ACP driver matches.
- Settle autonomous turn.ended with a usage update even when there is no driver.
- Route cancellation to agent.cancel when no driver exists, preserving the existing busy-prompt rejection and explicit cancellation paths.
Verification
Two new real-engine regressions fail on unpatched main (premature prompt settlement and a 30-second cancellation timeout) and pass with the fix. The full ACP suite passes: 158 tests. ACP typecheck and build pass, and targeted oxlint reports 0 warnings/errors.
Please /approve this bug so I can open the focused lifecycle PR with the patch and regression coverage.
Two more ways into the same lifecycle bug, seen on 2.6.2 over ACP (BB client), plus a config workaround for one of them.
1. Manual /compact. Compaction runs in the background (20-44 s in our runs). A session/prompt sent before "Compaction completed" is queued and returns an empty end_turn at once. The model does answer it later: the answer is in the session wire.jsonl (a test token we asked for, CHARLIE-9), but no session/update reaches the client. In 1 of 3 probes the queued turn never finished and later prompts were swallowed too.
2. Foreground Bash moved to the background on timeout. With the default bash_auto_background_on_timeout = true, a foreground Bash that exceeds its timeout becomes a background task (task.started … "detached": true in wire.jsonl). When it ends, its notification starts an autonomous turn (turn.prompt with <notification … source_kind="background_task">). Our next two ACP prompts got an immediate empty end_turn; the autonomous turn stopped after step.begin and never ended. Neither the user nor the model asked for a background task here, so clients cannot expect this.
Workaround that removed trigger 2 in our runs (3/3 clean afterwards):
[task]
bash_auto_background_on_timeout = false
Only process restart recovered a hung autonomous turn for us.
⬛ JARVIS · AlexVasiliev