Skip to content

Queue non-user messages behind a user's running turn so they can't revoke its approvals - #8096

Open
ymichael wants to merge 1 commit into
mainfrom
bb/7040-codex-accept-edits-non-user-steer-can-silen-thr_jnfqbhuram
Open

ymichael wants to merge 1 commit into
mainfrom
bb/7040-codex-accept-edits-non-user-steer-can-silen-thr_jnfqbhuram

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

A message that isn't from the user (another thread's bb thread tell, a child-outcome system notice) resolves to permission escalation deny. When it arrived during a turn the user started, the dispatch checkpoint steered it into that turn with those deny options. The steer overwrote the running turn's permissions. Codex's bridge saw changed permission settings and interrupted the active turn to restart it with approvalPolicy: never, so the step that needed approval was aborted and no prompt appeared. Runtime-enforced bridges that inject steers without restarting (Pi) kept running the user's work while runtime.steerTurn saved deny as the thread's options, so later approval requests in that turn were declined before any interaction was persisted. ACP cancels the prompt on a steer and reruns with the steer's options, which has the same effect. On main I reproduced it live with real Codex in Accept Edits, 2 of 2 times: a turn ran sleep 20 and then wrote outside the workspace, a sibling sent "FYI, my build finished" during the sleep, and Codex replied "Step 1 was interrupted… Step 2 did not run, and no approval was requested". No file was written. #7040

What changed

  • Server (dispatch-attempt.ts, thread-events.ts): the dispatch checkpoint gets a new core wait. A join-turn attempt whose author resolves to deny waits on thread-busy when it would join an ask turn (one the user started or steered) whose main run is working. The existing queue keeps order and author, so each queued message runs afterwards as its own turn with its own permissions. A new getActiveTurnInitiator reads the initiator of the active turn's latest accepted input, or of the latest request while the turn is still starting. Each deferral is logged at info with the thread, initiator and sender. Non-user messages still steer into non-user turns, and user messages still steer into any turn.
  • Runtime (runtime.ts, execution-options.ts): this is a backstop for any steer that still arrives. steerTurn never lowers a running turn's escalation from ask to deny (keepRunningTurnApprovals), so the provider isn't told to drop approvals and the runtime gate keeps asking. This differs from the proposed "fixed copy". A strictly fixed copy would also stop a user steer from raising a deny turn to ask. On main that raise works: Codex restarts the turn with on-request and Pi's gate flips to ask. Freezing it would bring back the same silent decline the other way round.
  • Logging (runtime-provider-requests.ts): every approval request the runtime declines without asking now logs a line with the request id, turn, thread and reason (deny escalation or no handler). Command contents aren't logged.
  • Docs: the thread-messaging guide chapter and the bb-cli skill say that a tell into a user-started turn queues until that turn ends.
  • Tests: the scripted echo test bridge can now raise an approval from a steer (approve:<kind> in steer text). Steer-mechanics tests for system notices (limiter, held notice, pending question, offline host, coalescing, recovery, turn-starting parking) now seed a non-user running turn, which keeps them testing those mechanics. There is a new system-notice test for the user-turn case.
  • No server/daemon wire fields or plugin SDK surface changed, so there is no HOST_DAEMON_PROTOCOL_VERSION or SDK bump.

Behaviour change to note: a manager thread whose current turn the user started now gets child notices after that turn ends instead of mid-turn. That is the queueing #7040 asks for, and it is what keeps the user's approvals.

#7538's busy-answer/re-send layer is not reintroduced. Nothing is refused, so nothing needs re-sending.

How you verified

  • New tests fail without the fix and pass with it:
    • dispatcher-paths.test.ts: three agent tells during a user turn all queue thread-busy and then run as three separate new-turn agent turns, in order. Control: an agent tell into an agent-started turn still steers.
    • runtime.interactive-requests.test.ts: an ask turn steered with deny options still routes the next approval to the user. A declined approval logs its reason.
    • system-notice-dispatch.test.ts: a child-completed notice waits behind a user turn and then runs as its own system turn.
  • pnpm exec turbo run test lint typecheck --filter=@bb/server (4503 passed), and test for @bb/agent-runtime (315), @bb/host-daemon (915) and @bb/templates. Typecheck and lint pass for agent-runtime, templates and the scripted echo provider.
  • Live, with real Codex in Accept Edits on a pnpm start:worktree instance:
    • Same repro on the fix: the notice reported "queued (waiting for the current turn to finish)", sleep 20 ran fully, and an approval prompt appeared. After approval Codex said "Both steps completed in order" and the file was written. The notice then ran as its own agent turn, which completed.
    • Several notices: 7 sibling tells during one sleep 90 turn all queued. The turn finished with "done", then the 7 notices ran as 7 separate completed turns in order (Notice 1…7). The thread ended idle, the queue was empty and no errors were recorded.
  • Claude Code, ACP and Pi were checked by reading the code, not live. The server-side queueing is provider-agnostic. Pi and ACP are the runtime-enforced bridges the runtime backstop covers. Claude Code enforces approvals per prompt in its bridge, and the queueing also keeps the user's prompt from being followed by a deny prompt mid-turn.

Fixes #7040

🤖 Generated with Claude Code

AGENT GENERATED

A message that is not from the user (another thread's tell, a system
notice) resolves to permission escalation "deny". bb steered it into the
running turn with those options, so a turn the user started lost its
approvals mid-flight: Codex interrupted the turn to apply approvalPolicy
"never", and runtime-enforced bridges such as Pi auto-declined the
turn's later approval requests without asking.

The dispatch checkpoint now queues a deny-escalation message behind a
running "ask" turn (thread-busy), so it runs as its own turn afterwards,
in order, with its own permissions. As a backstop the runtime never lets
a steer lower the running turn's escalation, and it logs every approval
request it declines without asking, with the reason and request/turn ids.

Fixes #7040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex accept-edits: non-user steer can silently change the active turn approval gate

1 participant