Skip to content

Provider session contract: explicit phases, one admission gate, declared settings - #7538

Open
ymichael wants to merge 1 commit into
mainfrom
bb/provider-session-contract-one-draft-pr-thr_y6mc8pqzcs
Open

ymichael wants to merge 1 commit into
mainfrom
bb/provider-session-contract-one-draft-pr-thr_y6mc8pqzcs

Conversation

@ymichael

@ymichael ymichael commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb guessed what each agent was doing. Bridges inferred turn ends and busy agents from silence and grace timers (Codex 250 ms / 5 s zero-work grace, ACP 5 s quiet turns and 2 s busy waits, Pi 5 s extension-report timeouts), a turn.boundary could claim a turn nobody opened (claimIfIdle), and the server guessed compaction from the request text in two places (isManualCompactionActive). Each bridge diffed settings itself and restarted provider sessions whenever it decided to, with no check for running work (Claude per-setting restarts, Codex constructionSignature, ACP reconcileExecutionSettings, Pi rebuilds), while the daemon evicted whole environments on any shell-env change and swapped the environment-wide skill catalog. Capabilities came from bb's catalog: per-agent supportsManualCompaction overrides, a fake "Agent default"/"medium" ACP model, and a hard-coded list of 1M-context Claude models. Plan: plans/provider-session-contract.md in @thread:thr_hdhvdu78fj.

Fixes #7040

Related, partly addressed but not fixed: #3636, #4942, #5359, #5843, #6301.

What changed

All three phases, one PR. Every mechanism on the plan's deletion list is deleted for bb's built-in bridges (rg for each name finds nothing); nothing old runs beside the new system. The one deliberate exception is main's claimIfIdle inference, kept only inside the protocol 2 compatibility path for third-party bridges (below), with a removal condition in docs/provider-bridge-protocol.md.

Phase 1: one state machine, one gate, open work

  • packages/agent-runtime/src/runtime-session-state.ts replaces the turn-state tracker, pending-start map and idle-since map with one per-thread machine: starting → idle → turnStarting → turnRunning → compacting / waitingOnUser → stopping → dead. It moves only on explicit reports (turn.open, turn.boundary, the compaction item lifecycle, interaction requests, request results). The turn-start watchdog stays as a backstop.
  • One admission gate: the runtime admits a turn/start only from idle and a steer only into the turn it names, and answers busy itself while starting, stopping or compacting. turn/start and turn/steer now return {admission: "accepted" | "busy" | "rejected"} from the bridge; accepted comes only after input.accepted is on the wire.
  • The daemon reports thread_busy / turn_rejected (COMPETING_TURN_ERROR_CODE and CompetingTurnError are gone). The server's lifecycle machine (lifecycle/machine.ts) answers them as busy and rejected turn-request answers: it records a busy request as refused and re-sends it behind the running turn, or after a backoff of 5, 10, 20, 40 and 80 s when no turn runs; after six busy answers in a row it stops and fails the run with a provider_busy error the user can retry. A rejected request settles the thread idle with the reason visible. Sends, steers, queued messages and parent notices all go through this one path.
  • claimIfIdle is removed from the protocol 3 grammar and assembler; bridges open every turn explicitly. Output an agent sends with no prompt in flight is recorded on the last turn (attach: "currentOrLast" on text deltas and closes, item.open and item.close) instead of opening a turn.
  • New thread/openWork request (openWork: {list} capability). The runtime refuses to reap, restart (restartRecommended, now checking the thread itself as well as siblings) or resume a session while its phase, timeline background work, plugin tool calls or the bridge's list show open work. A failed or timed-out probe counts as busy for that attempt; after three failures in a row the thread gets a note saying bb can't confirm no work is running and that stopping the thread applies the change. Bridge-internal auth recovery stays ungated.
  • Deleted: claimIfIdle (protocol 3), Codex ZERO_WORK_SETTLEMENT_GRACE_MS/GOAL_RESUME_TURN_GRACE_MS, ACP AGENT_TURN_QUIET_MS/SESSION_BUSY_QUIET_MS and the activity-based agent turn opening (startsAgentWork), Pi AGENT_END_LEAF_TIMEOUT_MS, both isManualCompactionActive checks (plus the now-unused isStoredTurnProviderCompactionRunning and getStoredTurnRequestEventForTurn queries).

Phase 2: one settings reconciler

  • Bridges declare capabilities.sessionSettings per setting and per value (live | resume | fresh), and may narrow it per session in thread start/resume/fork results.
  • runtime-session-settings.ts diffs the desired record (options, env, instructions, tools, skills, plugin build) against the applied one at each turn/start, and only there: nothing is applied to idle threads in the background, and a turn causes at most one resume. Live changes go out in turn/start.apply; resume changes release and resume the session (new bridge process for skills/build changes) when no work is open, after a note that background processes bb does not track may stop; otherwise the turn runs on the old values and a thread note says what waits and why. Fresh changes never auto-apply.
  • Steers never apply settings: a mid-turn message that changes settings joins the running turn on its current settings, and a thread note says the change applies from the next turn. A message that lowers permissions (for example Full Access to accept-edits) is answered busy and runs as the next turn, so a running turn never keeps broader access than the user asked for. Raising permissions joins like any other change.
  • The daemon passes the whole desired record for hosted threads, reads the current shell env per turn, and stages skills per thread.
  • Deleted: ACP reconcileExecutionSettings restart predicate and rebuildAgentSession (a crash-only recoverAgentSession remains), Codex constructionSignature/environmentHash and the steer interrupt-restart, Claude apply{Chrome,Subagent,ContextWindow,Artifact}Setting, the bypass restart branch, applyTurnEnvironment/environmentSignature, the steer restart and the resume deep-equal, Pi reconcileTurnOptions rebuild/rebuildThreadSession, daemon shellEnvGeneration, evictIdleRuntimeEntries, replaceEntryForSkillCatalog, SkillCatalogConflictError, retainedSkillCatalogHashes.
  • Declarations: Codex model/tier/permission/reasoning (now effort per turn) live, memory/subagents/env/skills resume, instructions/tools fresh. Claude model/reasoning/tier/permission live except full (resume; narrowed to live for sessions launched with bypass), chrome/subagents/1M/artifacts/env/tools/skills resume, instructions fresh. ACP native model/reasoning/permission live, narrowed to resume for launch-flag models and permission args; env/tools resume; instructions/skills fresh. Pi model and thinking live via set_model/set_thinking_level; env/tools/skills/instructions resume.

Phase 3: capabilities from the live session

  • Deleted the per-agent supportsManualCompaction overrides (old custom-agent entries are ignored). ACP no longer declares compaction: bb offers the built-in /compact (menu, compact-before-send offer, bb thread compact, --compact-first) when a provider declares it or the thread's live bb/provider-commands lists compact, so ACP agents show it only once the agent advertises a compact command.
  • Deleted the fake ACP_DEFAULT_MODEL. An agent with no model list reports one entry from the live session's agentInfo, with no invented effort; availableModelSchema.defaultReasoningEffort is now optional. Launch-flag (modelCli) agents only receive model ids their list contains; a stored acp-default or unlisted id is not passed and bb warns.
  • Deleted LARGE_CLAUDE_CONTEXT_MODELS; the context window comes from the live session (getContextUsage, result.modelUsage).

Third-party bridges: protocol 2 compatibility

  • The runtime accepts protocol 2 and 3. A bridge answering 2, or answering 3 without capabilities.sessionSettings, runs on a compatibility path (packages/provider-bridge-protocol/src/protocol-v2.ts, assembler/protocol-v2.ts); the second case also logs one stderr line naming the missing field. This catches bridges such as NanoGPT and MoA that report the SDK's PROVIDER_BRIDGE_PROTOCOL_VERSION constant: bumping their SDK would otherwise claim 3 without implementing it.
  • On that path a bridge sees what it saw on main: claimIfIdle boundaries open and settle a turn as main's assembler did, any turn/start/turn/steer result counts as accepted, every turn carries the full options with no apply, steers carry their own options, env and instructions (including lowered permissions), and there is no thread/openWork probe, no settings note and no settings-driven resume. Env, skill, tool and build changes are applied by a resume at the next turn start, the equivalent of main's idle-bridge restart. The runtime's own busy gate, phases and watchdog are shared; none change the wire.
  • The conformance kit detects the protocol from the handshake; a new rule handshake/session-contract fails a bridge that claims 3 without sessionSettings.

Versions and docs

  • PROVIDER_BRIDGE_PROTOCOL_VERSION 2 → 3 (grammar snapshot renamed to v3). Protocol 2 bridges keep working through the compatibility path.
  • HOST_DAEMON_PROTOCOL_VERSION 271 → 272 (new error codes and their meaning).
  • Plugin SDK 0.6.165; @get-bb/plugin-sdk/provider-bridge exports the new schemas and types.
  • Conformance kit: new rules turn/admission-answered, openWork/list-declared and handshake/session-contract; the cross-provider permission contract now drives Codex and Claude through their own declarations.
  • Docs: docs/provider-bridge-protocol.md (new "Session contract" and "Protocol 2 compatibility" sections; Sessions items rewritten), docs/provider-plugin-api.md, docs/configuration.md, the Plugin Guide provider-bridges card, the plugin-authoring providers reference, the thread-messaging guide, and the Claude, Codex, ACP and Pi plugin skills/readmes.
  • Pi keeps its minimum of 0.84.0. Pi whose bb extension advertises agentSettled settles turns on Pi's explicit settlement report; older Pi ends each turn on agent_end as before. The bridge chooses by the extension handshake, not a timer.

Success measures (non-test source). Timing constants in the four bridges: 53 → 48. Runtime: 7 → 8 (the open-work probe timeout). Issue inflow can only be measured after release.

Rebased onto main (Nov 18)
Main's newer work is kept and moved onto this PR's model:

Breaking changes

  • Third-party provider bridges do not break. Protocol 2 bridges, and bridges that report 3 without the session contract, run on the compatibility path with main's behaviour. Verified with the real NanoGPT bridge (below).
  • Mid-turn settings changes on built-in bridges apply from the next turn, with a note, instead of restarting the session mid-turn; a mid-turn message that lowers permissions runs as the next turn.
  • ACP agents show /compact only when they advertise a compact command.

Fix coverage

Each fix this PR replaces, the tests that covered it on main, and what covers it now.

Fix Original tests Replacement, or why obsolete
#6379 / #6420 Pi extension compaction server "queues sends while a provider-started compaction turn is active"; Pi bridge "holds a prompt sent while a Pi extension compacts and sends it when compaction ends", "retries a prompt Pi rejected before the bridge saw the compaction start", "drops a prompt held behind compaction when the thread is released" End to end through the runtime and the real Pi bridge on fake Pi, runtime.pi-compaction-busy.test.ts: "the runtime answers busy while a Pi extension compacts, and the retried turn starts after compaction ends", "...relays Pi's busy refusal for a prompt that races the compaction start...", "...answers busy during bb's /compact and starts the next turn after it ends". Bridge: "answers busy while a Pi extension compacts after a run, and gives the compaction its own turn", "answers busy when Pi refuses a prompt for a compaction the bridge had not seen start", "answers busy to a steer and a new turn while bb's /compact runs...". Server: "re-queues a send the runtime refuses busy during compaction and delivers it after the compaction turn". "drops a prompt held behind compaction..." is obsolete: the bridge no longer holds prompts.
#2160 / #2221 Pi turn options bridge.turn-options.test.ts (6 tests) Rewritten for apply.settings in the same file (model and thinking live, compaction model, unresolvable model keeps the session, steer applies nothing). "keeps serving the thread when the replacement child never starts" is obsolete (no child respawn). New: runtime "fails the turn when the settings resume fails and resumes cleanly afterwards".
#4806 / #4922 ACP permission changes on follow-ups and steers ACP "reconciles $before -> $after on $method" (16 cases), "rejects simultaneous starts while reconciling unchanged permissions", "preserves stacked steers across permission CLI rebuilds", "reports a permission-changing steer whose replacement fails to start" "permission contract: $before -> $after on a follow-up" (8 cases through the shared runPermissionChangeCase, native live, launch flag with and without load, opencode env); "never applies a permission change a steer carries, and applies it on the next turn/start that lists it" (native and launch flag, through the reconciler); "answers a second simultaneous start busy"; "delivers stacked steers on the same turn". The failed-replacement test is obsolete: steers no longer rebuild, and a failed resume is the runtime's (covered by the #2221 row).
#5051 / #5141 ACP model, effort, tier on follow-ups ACP "applies changed ACP-native reasoning and service tier before a follow-up prompt", "rejects a follow-up turn whose ACP-native model the agent refuses", "relaunches a CLI-selected ACP agent when a follow-up changes its model", "rebuilds the agent with the current turn's model selection" First unchanged. Refusal now "keeps the agent's model and warns when asked to apply a model the agent does not offer" and "returns the model config option's own error...". Relaunch: "relaunches a CLI-selected ACP agent with the new model when the thread is resumed" and runtime "resumes the session to apply a setting the bridge declares resume". New: runtime "carries the turn's live model change into a resume another setting forced".
#1235 / #1236 Claude settings without replacing sessions Claude "rebuilds for enforcement changes but applies model changes live", "keeps a live Claude session across an escalation-only resume change", "keeps background subagents on their parent tool escalation..." Last unchanged. Replaced by "declares which Claude settings apply live and which need a resume", "switches permissions live, including into full access once the process was launched for bypass", "applies sandbox changes live without replacing the Claude process", runtime "carries changed settings on the next turn without rebuilding the session". New: "lists a running background task as open work until Claude reports it finished" (what stops a resume killing background agents).
#2580 / #3503 Codex turn the response names bridge.zero-work-turn.test.ts (11), translator.turn-response.test.ts (3) Unchanged apart from apply. Added "fails a turn/start answer that reports no turn instead of inventing one", "answers accepted only after the turn it opened is on the wire".
#2014 / #2021 Pi and ACP acceptance on consumption ACP "accepts turn input only after the prompt carrying it goes out", "never accepts a queued steer the stopped turn did not send"; Pi tests already deleted on main ACP unchanged. Pi: "a steer consumed by the run is reported accepted and named in the reply", "a steer still queued when the run ends is reported dropped through the delivery barrier, not a timer".
#5691 / #5813 ACP launch-model changes across restore ACP it.each "preserves the session across CLI $setting changes (restorable=$restorable)" restorable=true: "relaunches a CLI-selected ACP agent with the new model when the thread is resumed". restorable=false (now fresh, never applied): new runtime "keeps the old model on a session it cannot restore and says so once", plus "turns a resume into fresh for a session that cannot be restored".
#3462 / #3502 explicit stop of daemon turns the server lost daemon "reports a retained turn instead of releasing...", "reports a runtime competing-turn refusal with the contract error code"; 9 server stop tests; server send-dispatch competing-turn tests Retained-turn and stop tests unchanged. Daemon it.each "reports a runtime %s refusal of status %s with the %s error code" (start/steer × busy/rejected). Server "queues a busy refusal behind the running root turn instead of failing the run" (restored: root turn completes, the retry goes out, the queue empties); "returns the thread to idle and schedules the retry when no turn is running" replaces the run-failure case.
Pi settlement #5341 bridge.interruption-recovery, rpc-session.settlement, run-settlement, delta-translation tests All titles kept. "prompt-settled settles only a turn owed to accepted input" became "prompt-settled closes the turn the bridge opened and never opens one" (no claimIfIdle).
#7031 steer turn-start timeout runtime watchdog tests, daemon "reports an unanswered turn start as unconfirmed...", server "keeps the thread active and runs the turn when the provider starts it late" Daemon and server unchanged; runtime tests moved to the 120 s watchdog with the same assertions.
#7392 newer turn during a stale steer runtime "keeps a newer turn that started while a stale steer was in flight" Unchanged.
#6551 / #6596 Codex Goal pause on stop and /goal resume binding bridge.goal-controls.test.ts (7), server "clears a paused Goal" Kept: "pauses an active goal before interrupting the turn...", "leaves a thread without an active goal alone when stopping it", "sends other /goal text to Codex as a normal prompt", server "clears a paused Goal". "resumes a paused goal for /goal resume and binds the turn Codex starts to that message" → "binds /goal resume to the Goal turn Codex starts when Codex reports that turn $order it answers which turn is active" (before and after). "finishes /goal resume when Codex does not start a goal turn" (5 s grace) → "finishes /goal resume with an empty turn when Codex starts no Goal turn" (no wait). "clears the goal for /goal clear without starting a Codex turn" → "settles /goal $command on the Codex reply without starting a Codex turn" (clear and pause).

How you verified

Live, this round (dev instance built from this branch, driven with pnpm bb:dev, plus bridges driven directly against real CLIs):

  • Third-party bridge on protocol 2: the real NanoGPT bridge (commit 75a69860), installed as bb's git install does and bundled twice: with its pinned SDK 0.6.133 (answers protocol 2) and with this branch's SDK (answers 3 without sessionSettings, so it runs on the compatibility path and logs one stderr line). Each ran three turns and a mid-turn steer through createAgentRuntime against a local OpenAI-style server: all turns started and settled, the steer joined, model and API-key changes reached the server, and the runtime sent only initialize, thread/start, turn/start ×3 and turn/steer (no apply, thread/openWork, thread/stop or thread/resume).
  • Codex /goal (codex 0.169.0, through the bridge): a prompt that calls create_goal set a Goal; Stop during the Goal turn paused the Goal before the interrupt and settled the turn interrupted; /goal resume after a thread resume set the Goal active and was accepted into the Goal turn Codex started, which ran to complete about 33 s later; /goal pause on the completed Goal was rejected with a reason; /goal clear settled with an empty turn and no Codex turn. The no-turn case (a fork with deferGoalContinuation) settled /goal resume in 22–333 ms with an empty turn.
  • Real Pi compaction with messages sent during it (pi with a real model, bridge driven directly; an extension held session_before_compact for 6 s so the window was observable): during bb's /compact a steer, a new turn and a second /compact were all answered busy and the compaction item stayed open; the next turn after compaction was accepted. The same for an extension-started ctx.compact() on agent_settled (Pi: a message sent during an extension-started compaction is steered, rejected, and lost #6379): busy during it, the retried turn accepted after. Pi's session file shows exactly the accepted messages, none of the refused ones.
  • Codex /compact with two messages sent during it: both were answered busy (client/turn/rejected thread_busy), then re-sent in order after compaction as their own turns and answered ("alpha-during-compact", "beta-during-compact"); the queue ended empty. This run found two bugs (risks 14 and 15), both fixed.
  • Second enrolled daemon (a separate host-daemon process with its own data dir, enrolled by join code; the Codex process ran under it): a turn completed; a message that raised reasoning to high while a new skill had been added restarted the session once ("Restarting the provider session to apply skills…", then "Applied skills, reasoning level; the provider session resumed with its history.") and answered; Stop during a foreground sleep 60 interrupted the turn, ended the command and released the session; the next message resumed the thread and answered.
  • Idle reaper: with the idle timeout at 5 minutes, the daemon logged "Reaped idle provider sessions" for the idle Codex thread (idle 501 s) and two errored threads, and skipped the two Codex threads whose background terminals (sleep 900, sleep 600) were still running; both processes kept running.
  • Settings notes in the app (screenshots in thread storage, not uploaded): the mid-turn note now shows below the steer in a collapsed turn without expanding; with a background terminal running, adding a skill gave a full-width note before the turn, "Changed skills needs a provider session restart, which waits while work is open (Codex background terminal is running sleep 600); it applies at the first turn after that."; a mid-turn message with a different model joined the turn and showed "Changed model applies from the next turn; this message joined the running turn on its current settings." (before this round it sat inside the turn's "Worked for" group). Messages refused busy during compaction show no "Steer failed" label after delivery.
  • ACP /compact visibility: opencode (3 commands) and omp (50) publish compact, cursor-agent (80) does not; on opencode a turn then /compact produced the compaction item, context.compacted and a completed turn.
  • Plugin changes never touch idle threads: adding a global skill while other threads sat idle restarted none of them; the reaper later released them on its own schedule.

Live, earlier rounds: Claude model switch live and Full Access by resume with history; Full Access deferred behind a background sleep 150 and applied after; Codex mid-turn model change joined the turn and applied next turn, and lowering Full Access mid-turn ran as the next turn; Codex effort per turn; a skills change deferred behind a background terminal then applied by resume; cursor-agent /compact refused with a reason; opencode live model switch; Pi model and thinking live in one session; Pi 0.83.0 (no agentSettled) ending turns on agent_end.

Tests (targeted, via turbo): typecheck + lint for everything affected by the diff; tests for @bb/agent-runtime (session state, reconciler, session contract, protocol 2, Pi end-to-end), @bb/host-daemon, @bb/provider-bridge-protocol (assembler, grammar, conformance for both protocols, permission contract), the four bridge plugins and echo, @bb/provider-bridge-acp, @bb/thread-view, @bb/db query plans, and the affected server suites. Parity recordings replay green. Full suites are left to CI.

Busy retries and open-work checks

  • Busy retries are bounded. With a turn running, a busy-refused message waits behind it. With no turn running, the retry waits 5 s, then 10, 20, 40 and 80 s. After six busy answers in a row with no input accepted in between, bb stops re-sending and fails the run with "The agent answered busy 6 times in a row, so bb stopped re-sending this message. Retry it once the agent is free, or stop the thread."; Retry re-sends it. Tested with a daemon that answers busy forever.
  • A failing open-work check does not defer silently forever. Each failure counts as busy for that attempt; after three in a row the thread gets one note that bb can't confirm the agent has no running work, won't restart the session on its own, and that stopping the thread applies the change. I chose this over applying at the next idle boundary because a failed check means bb cannot see the agent's work at all; restarting anyway could kill a background job the user relies on. Tested: the note on the third failure, never a restart, and stop + resume carries the new setting.

Decisions for Michael

Two behaviour changes this PR makes on purpose; each needs your call.

1. Plugin tool and provider build changes now restart the provider session (risk 4).

  • On main: a running provider session kept the plugin tools and provider plugin build it started with until something else rebuilt it, so after a plugin update the agent kept calling stale tools with no notice. (Shell-env and skill changes evicted idle bridges in the background, without checking for running work.)
  • On this branch: tool, skill, env and build changes apply at the next turn the user starts, by restarting the session with its history (at most once per turn, never on idle threads, and only when no open work is reported). A thread note says so before the restart. A restart ends child processes the agent started that no open-work list reports, such as nohup … & (Changing a plugin's skills replaces every idle Codex thread's runtime at its next turn and kills the thread's background commands #6301); bridges report background terminals, tasks and sub-agents, so those defer the restart instead.
  • Options: keep this; or keep stale tools until the user restarts the thread, as main did.

2. Pi 0.84–0.98 extension commands that run no turn stay open (risk 12).

  • On main: a 5 s timer (AGENT_END_LEAF_TIMEOUT_MS) closed the turn when Pi went quiet after an extension command that started no agent run.
  • On this branch: the timer is gone (the plan's no-timers rule). Pi 0.84–0.98 report settlement but not whether a prompt ran a turn, so such a command leaves the turn open until the user stops it; the turn-start watchdog flags it. Pi 0.99+ reports it exactly and closes the turn. Pi whose extension does not advertise agentSettled ends turns on agent_end as before.
  • Options: keep this; or restore the timer for Pi 0.84–0.98 only, as a version-gated exception to the no-timers rule.

Risks

  1. Busy retry storms (Automatic recovery storms a dead Codex thread with repeated no-active-session errors #2328 shape). Fixed: backoff and a cap of six, then a visible failure.
  2. ACP agent-started output leaving threads Working. Fixed: output with no prompt in flight goes on the last turn as completed activity; a turn opens only on state_update running (settled by idle) or for a permission request, elicitation or tool call the agent raises with no prompt in flight (the runtime needs a turn to route it; it settles once the last one is answered). No timer. Verified with the fake agent only (no real agent emitted unprompted updates, see below).
  3. Mid-turn settings changes apply from the next turn (reverses Send the composer's execution selection with steers #2149/Active steers ignore model/reasoning changes #1860's "steer applies the model"). Fixed for visibility: the note uses a new thread-event warning category, session-settings, which stays visible outside the completed turn's collapsed group (bridges cannot send it; the bridge warning delta keeps its four categories). Verified live: the note shows below the steer without expanding. Lowering permissions runs as the next turn.
  4. Plugin tool, skill and build changes resuming hosted sessions. Fixed: applied only at a turn the user starts, at most one resume per turn, never on idle threads in the background, with a note before the resume that untracked background processes may stop. The remaining behaviour change is under Decisions for Michael.
  5. A failing open-work check. Fixed as above; the change waits until the user stops the thread.
  6. Deferred settings shown only as thread notes. Verified in the app: notes render with their full text (screenshots below).
  7. Codex /goal resume binding (Codex thread shows idle (no spinner) while actively running commands #1646/Codex goal remains active after a turn ends but no next turn starts #6226 shape). Fixed: after setting the Goal active the bridge asks Codex which turn is active (a turn/steer with an impossible expected id, which Codex runs in order after the goal set and refuses naming the active turn), then accepts the message into that Goal turn or settles it at once with an empty turn when Codex starts none. No timer. Verified live (below). No structured alternative exists in Codex 0.169 (checked against codex app-server generate-ts output, the rust-v0.169.0 source and the live app-server):
    • the thread/goal/set reply is sent before Codex decides whether to start a turn, has no turn field, and always says active;
    • thread/goal/updated from the set has turnId: null; the first update naming the turn comes seconds later, and none comes when no turn starts;
    • thread/status/changed and turn/started arrive only if a turn starts, and Turn has no goal or trigger field;
    • thread/read sent right after the set returned idle, turns: [] in 4 of 4 runs while the goal turn started 10–60 ms later (it reads a cached status);
    • thread/turns/list is explicitly concurrent and also cached; thread/goal/get returns only the goal; no activeTurn-style field exists in the 847 generated v2 types.
      turn/steer checks the session's live active turn, but its refusals carry no structured data (CodexErrorInfo covers only activeTurnNotSteerable), so the turn id is only in the message text. If that wording changes, /goal resume fails with a visible error and the Goal stays active; the bridge never guesses.
  8. Stop during the up-to-120 s ACP prompt wait. Fixed: thread/stop answers a pending turn/start at once, cancels, and settles the turn interrupted; tested ("answers a turn/start the agent never took as soon as the thread stops...").
  9. Bridge protocol bump. Fixed: protocol 2 bridges keep working through the compatibility path.
  10. ACP /compact on agents without a compact command. Fixed: offered only when the live commands list compact. Verified live: listed by opencode and omp, not by cursor-agent.
  11. Stored acp-default models on launch-flag agents. Fixed and tested: never passed through the launch flag; bb warns.
  12. Pi 0.84 to 0.98 extension commands that run no turn: a behaviour change, under Decisions for Michael.
  13. Replaced fixes. Fixed: coverage restored, see the table above.
  14. Busy-refused messages labelled "Steer failed" although bb re-sent them (found in live QA). Fixed: shown pending while bb retries; once a retry is accepted the message renders once, in the turn the retry ran in, whatever page boundaries fall between the request, its refusal and the retry (the server loads the missing request, refusal, retries and give-up for each window); a give-up or any other refusal shows failed. Tested at 1, 2, 3 and 20 segments per page; verified live. A refused message whose expected turn is on an earlier page no longer throws in the projection (that crash was also on main). One residual: a client that already holds an older page keeps what it showed until the latest window covers it again, which needs a refusal to scroll out of the latest 20 segments while bb is still retrying.
  15. Two messages refused during one compaction lost the first (found in live QA): the retry was only sent for the thread's latest request, and a new request superseded other queued retries. Fixed and verified live: both are re-sent in order after compaction.

Not verified

  • ACP agent-started output from a real agent. No installed agent sent unprompted session/updates: OpenCode 2.0.22 resumed itself after a background job without telling the ACP client, cursor-agent never continued, omp had no credits. Covered by the fake agent only.
  • Stop during the ACP prompt wait, and ACP session_busy: fake agent only.
  • The open-work probe failing three times in a row (the stop note): unit tests only; no real bridge fails its probe on demand.
  • Claude live this round: the dev instance had no Claude login; Claude's open-work listing is unit-tested and was verified live in an earlier round.
  • Codex Goal no-turn case through bb's own flows: bb never forks with deferGoalContinuation, so it was driven through the bridge directly.
  • MoA and other third-party bridges: only NanoGPT was run; the others use the same SDK constant and handshake shape.
  • Modal sandboxes: not exercised; a second enrolled daemon was (below).
  • Screenshots are not attached here because this repository is public and they show a development instance; they are in the author's thread storage.

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael marked this pull request as ready for review November 14, 2026 01:05
@ymichael
ymichael marked this pull request as draft November 14, 2026 04:54
@ymichael
ymichael marked this pull request as ready for review November 14, 2026 06:11
@ymichael
ymichael marked this pull request as draft November 14, 2026 06:11
@ymichael
ymichael force-pushed the bb/provider-session-contract-one-draft-pr-thr_y6mc8pqzcs branch from 79ed286 to 265fbb9 Compare November 14, 2026 06:48
@ymichael
ymichael marked this pull request as ready for review November 14, 2026 06:52
@ymichael
ymichael force-pushed the bb/provider-session-contract-one-draft-pr-thr_y6mc8pqzcs branch from 265fbb9 to 217bf14 Compare November 17, 2026 04:02
@ymichael
ymichael force-pushed the bb/provider-session-contract-one-draft-pr-thr_y6mc8pqzcs branch 2 times, most recently from 7607043 to b331d11 Compare November 19, 2026 02:21
…red settings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael force-pushed the bb/provider-session-contract-one-draft-pr-thr_y6mc8pqzcs branch from b331d11 to 49cce10 Compare November 19, 2026 02:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment