Repository navigation
Description
Turn finalized prematurely while agent was inside WaitFor for a background task — tail of the turn (final assistant message, file writes) silently dropped from thread history
bb version: 0.50.1 (CLI), Linux
Provider: acp-kimi-code (Kimi Code CLI via ACP)
Date observed: 2026-12-01, ~15:26–15:29 UTC
Summary
A turn was closed with turn/completed (status completed) ~1.5 s after a WaitFor tool call returned (the waited-on background task had just finished). The provider session, however, kept running: it read the task output, executed four file writes, and produced the turn's final assistant message. All of that arrived after turn/completed and was recorded only as provider/unhandled events (for the file writes) or not recorded at all (for the final assistant message). The user never saw the final message; the agent's own session context still contains it, so on the next turn the agent believed the user had read it. In our case this caused the agent to interpret the user's next message ("continue") as consent to a proposal the user had never seen.
Expected behavior
The turn stays open until the agent actually finishes (stop reason from the provider), and the final assistant message plus all tool calls are persisted to the thread log and shown in the UI.
Actual behavior
turn/completed is emitted immediately after the WaitFor tool call resolves (right when the background task it was waiting on completes). Everything the agent does afterwards in the same provider session is orphaned: file writes show up as provider/unhandled (acp/fs/write), and the final assistant message is lost entirely — it is absent from bb thread log --format json and from the UI.
Evidence (from bb thread log <id> --format json --all, 571 events)
Event type counts include turn/started: 5 but turn/completed: 4 (the currently running turn aside, the anomaly is inside turn 1, which does have a turn/completed — see below).
Turn 1 timeline (seq = event sequence number in the thread log):
| seq | time (UTC) | event |
|---|---|---|
| 504 | 15:26:48.162 | item/started — toolCall (the agent's WaitFor on background task bash-liz154j3) |
| 505–507 | 15:26:48.162–.763 | item/toolCall/progress; background commandExecution completes; item/completed for the WaitFor tool call |
| 509 | 15:26:50.229 | turn/completed {"status": "completed"} — turn closed |
| 511 | 15:27:55.722 | provider/unhandled acp/fs/write → <workspace>/servers/<host-id>/README.md |
| 512 | 15:28:16.349 | provider/unhandled acp/fs/write → <workspace>/servers/<host-id>/audit-2026-12-01.md |
| 513 | 15:28:22.842 | provider/unhandled acp/fs/write → <workspace>/README.md |
| 514 | 15:28:33.735 | provider/unhandled acp/fs/write → <workspace>/servers/<host-id>/README.md |
| 515 | 15:28:41.467 | client/turn/requested — the user's next message ("continue") |
| 516 | 15:28:41.727 | turn/started (turn 2) |
Additional facts:
- The last
agentMessageitem persisted for turn 1 is a mid-turn progress note (seq 345–347). NoagentMessageitem exists after seq 347 for turn 1, even though the provider session demonstrably kept producing output (the file writes above, and the final message the agent later quoted verbatim from its own context). - The four
acp/fs/writecalls and the final message correspond to real work: the written files exist on disk with the expected content, so the tool calls executed — they were only dropped from the thread record. - The UI showed the turn as finished with "1 background task still running" attached to it.
- Side symptom: the thread's TODO extension state (
thread/extensionState/updated, only 2 events in the whole log) is stale — updates made after the premature close were lost too;bb statusstill shows the mid-turn todo list. - Subsequent turns (2–5) on the same thread ran and completed normally.
Hypothesis
Race in the turn lifecycle handling of acp-kimi-code provider events: completion of a background task while the agent is blocked in the WaitFor tool resolves the tool call and then finalizes the turn (as if the agent had emitted its stop reason), instead of waiting for the provider's actual end-of-turn. Events the provider session emits afterwards are treated as unhandled because the turn (and possibly the event-routing scope) is already closed.
The exact trigger condition is our reconstruction; the premature turn/completed at seq 509 and the orphaned post-close events are directly proven by the log above.
Impact
Silent loss of the turn's final assistant message. The agent's session context and the thread history diverge: the agent believes the user saw its last message, the user never did. Any user reply is then interpreted against a message that was never delivered — in our case the agent performed configuration changes on a production server treating "continue" as approval of a proposal the user had never seen.
Reproduction sketch (not minimal, from the incident)
- Provider:
acp-kimi-code. During a turn, start a long-running background task (Bashwithrun_in_background=true). - Call the
WaitFortool on that background task so the task completes while the agent is insideWaitFor. - Observe:
turn/completedis emitted right after theWaitFortool result; the agent's subsequent output (final message, further tool calls) lands asprovider/unhandledor is dropped.
We did not attempt a controlled reproduction; the analysis above is from the incident's event log.
Attachments available on request
- Full JSON event log of the affected thread (571 events; we can share it with personal paths/hosts redacted).
Activity
bb-slop-cop commentedon Dec 1, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotproviders,threads,provider-acp; reproduction label:partial-repro.provider/unhandled. Two clean trusted-main checkouts reproduce four such writes after an explicitly simulated provider stop. The held-prompt control stays open after task completion; final messages survive both cases. The report embeds the repeatable diagnostic and its expected failure. All 642 existing owner tests pass.