Repository navigation
Conversation
A thread/stop that arrived while startAgentSession was still before
sessionsByBbThreadId.set found no session, or found the old session already
stopping, and answered { ok: true } with nothing to stop. The start then
launched and registered the agent anyway:
- during a settings rebuild, the stopped message was sent to the new agent
and the turn completed;
- during a fresh thread/start, the stopped thread came back with a live agent.
startAgentSession now registers a PendingSessionStart before its first
await. thread/stop marks every pending start of the thread, and the start
throws "released during construction" after stopSession(existing) and after
resolveAgentLaunchArgs.
Both interleavings were found with a TLA+ model of the per-thread session
lifecycle and are replayed by new bridge tests.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Please read this as a comment, not an approval. GitHub does not let me remove the approval state. My notes on this PR are in #6913 (comment). They include a reachability question that a maintainer should decide.
AGENT GENERATED
|
I checked this locally against main at 88cf8f644c. I did not confirm that the daemon can send
|
|
This is an automated message. We have closed this pull request because it has been open for more than two weeks. |
Human comments
What was wrong
startAgentSessionregisters the new session insessionsByBbThreadIdonly afterawait stopSession(existing)andawait resolveAgentLaunchArgs(params). Athread/stopthat arrives in that window looks only insessionsByBbThreadId, finds no session (freshthread/start) or the old session that is already stopping (settings-driven rebuild), and answers{ ok: true }. Nothing tells the in-flight start that it was stopped, so it launches and registers the agent anyway: during a rebuild the stopped message is prompted and the turn completes; on a fresh start the stopped thread comes back with a live agent. The existingsession.stoppingcheck at the end of construction only catches stops that arrive after registration. Details and permalinks in the issue.What changed
packages/provider-bridge-acp/src/bridge/bridge.tsonly:startAgentSessionregisters aPendingSessionStartfor its thread before its first await and removes it when the start settles (success or failure).thread/stop(bothinterruptandrelease) marks every pending start of that thread as stopped before it looks up the registered session.stopSession(existing)and afterresolveAgentLaunchArgs, and fails with the existingACP session for thread "…" was released during constructionerror, the same one the end-of-construction check already throws. No agent is launched in either case.No wire change: the
thread/stopresult and thethread/start/turn/starterror shape are unchanged, soHOST_DAEMON_PROTOCOL_VERSIONis not bumped. No CLI, guide, or doc surface changes.How you verified
bridge.test.tsreplay the two interleavings with the fake ACP agent: "sends no prompt after thread/stop answers during a session rebuild" and "fails a thread/start that thread/stop answered before the session was registered". Withbridge.tsreverted tomain(dbb247c60f) and the tests kept, both fail (output in the issue); with the fix, both pass.pnpm exec turbo run test --filter=@bb/provider-bridge-acp: 25 files, 574 passed, 4 skipped.pnpm exec turbo run typecheck lint --filter=@bb/provider-bridge-acp: pass, 0 warnings and 0 errors.pnpm exec oxfmt --checkon both changed files: pass.Fixes #6912