Repository navigation
Description
Summary
A Codex-backed thread emitted turn/completed while a command-execution item from that same turn was still running. The command later emitted output and item/completed after the terminal turn event. Every subsequent new-turn request then failed in one of two contradictory states:
thread <provider-thread> already has an active writerNo active codex session for thread <bb-thread>
Stopping the broken runtime and retrying the exact input did not recover the thread. Provider retry refused because the input had not been accepted, and edit-message could not apply because the rejected request was agent-origin rather than an editable user turn.
Native ordering evidence
For one exact turn/provider-thread:
item/startedfor a long-runningcommandExecution.turn/completedwithstatus=completed.item/commandExecution/outputDeltafor the still-running command.item/completedfor that command, reporting success and a multi-minute duration.- A later
client/turn/requestedwas rejected asalready has an active writer. - A recovery new-turn request was rejected as
No active codex session. - A further exact redelivery again rejected as
already has an active writer.
This is a native event/state contradiction: the turn was publicly terminal before all of its writer-owned items terminalized, leaving BB and the provider bridge disagreeing about whether a session/writer existed.
Expected behavior
- Do not emit
turn/completeduntil every command/tool/item belonging to that turn is terminal and no turn writer remains. - If a provider sends premature completion, BB should delay/fail the terminal event or reconcile outstanding items deterministically.
- A terminal thread must not simultaneously report both active-writer and no-active-session states.
- Stop/restart should clear any orphaned writer ownership without deleting event history or replaying rejected input.
- Rejected agent-origin requests need a supported exact-redelivery recovery path; edit-message is not applicable.
Acceptance
- A fixture delays command completion beyond provider turn completion; BB does not publish terminal completion first.
- After true terminalization, one new-turn request is accepted exactly once.
- Stop/restart clears stale writer ownership while preserving interruption/history.
- Tests cover the contradictory
already has an active writer/No active codex sessionsequence and prove it cannot persist.
No repository or canonical-state mutation is needed to reproduce; this report is based on bounded native event reads.
Activity
SawyerHood commentedon Aug 24, 2026
---Auto-Generated---
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2327.html
The report is self-contained: copy-paste repro steps with the test or script inline, expected vs actual output, screenshots where the bug is visual, and code permalinks at the base commit. It was independently re-executed by a second agent (see its Verification section).
Willhong commentedon Sep 11, 2026
Root-cause evidence from a live reproduction (2026-09-11, bb 0.42.0 from source, Codex CLI 0.154.0, macOS 25.6). The active-writer refusal did not start with premature
turn/completed; it started with the host daemon binding one Codex thread id to two bb threads.Observed sequence (bb DB
eventsrows and~/.codex/sessionsrollouts on one machine, same environmentenv_3rm6y2khyw)thr_fh9dq7fvsumessage edit (system/operation edit_message) staged a rewind; 08:00:26 the thread fork-started on Codex thread01a08d8d.thr_r6xinwrds3spawned on the same bridge and got Codex thread01a08ddd(itsthread/identityat 09:28:45.041).thr_fh9dq7fvsuitem/startedstill carriedproviderThreadId: 01a08d8d; 09:28:46.250 the matchingitem/completedfor the same item iddaa50c5e42-i430carried01a08ddd. Every laterthr_fh9dq7fvsuevent, including its 09:32:30turn/completed, was stamped01a08ddd. The rollout file for01a08d8dshows that turn completing normally at 09:32:30, so the events were routed to the right bb thread but stamped with the other thread's Codex id.thr_fh9dq7fvsuresumed provider thread01a08ddd(the server picks the latest storedprovider_thread_id) and ran a turn insidethr_r6xinwrds3's rollout (user text visible inrollout-…-01a08ddd.jsonlat 01:12:51Z with no correspondingthr_r6xinwrds3event).thr_r6xinwrds3turn.submit→thread 01a08ddd-… already has an active writer(~/.bb/logs/host-daemon.38.loglines 1783–1784).lsofshowed the lock~/.codex/thread-writer-locks/01a08ddd-….lockheld by the app-server child thatthr_fh9dq7fvsu's session had spawned at 10:12:47.Mechanism (permalinks at
8d32c61e)thread/identitynotification stamped with the bb thread id, and athread.identitydelta translated from Codex'sthread/started(bb/plugins/provider-codex/src/delta-translation.ts
Lines 1036 to 1043 in 8d32c61
bb/packages/provider-bridge-protocol/src/assembler/delta-assembler.ts
Lines 1971 to 1978 in 8d32c61
emitTranslatedEventsrecords an identity forevent.threadIdwhen that id is hosted, otherwise it pops a FIFO of pending identity slots and ignores the notification's source thread (bb/packages/agent-runtime/src/runtime.ts
Lines 1181 to 1208 in 8d32c61
thread/startregistration and is never consumed when the identity arrives through the direct notification; a rewind staging slot is never consumed because staging events are suppressed. So after one message edit the queue front wasthr_fh9dq7fvsu, andthr_r6xinwrds3's delta identity was recorded onto it.What this refutes: the "turn/completed before item/completed" ordering in the report is orthogonal. In this reproduction every turn terminalized in order; the contradiction between "active writer" and "no active session" comes from two bb threads owning one rollout.
Deterministic regression and fix in #3460 (
runtime.codex-topology.test.ts"keeps a rewound thread's provider identity when another thread starts on the same bridge" fails onmainwithexpected 'codex-fx-…-1' to be 'codex-fx-…-fork-1'). The server-side gap that let the corrupted stamp become the resume target is filed separately.Retry transient Codex writer-lock refusals and cover the writer hando…