Repository navigation
Conversation
ymichael
force-pushed
the
bb/class-fix-failures-never-reported-as-user-answer-thr_3aancrnpbf
branch
2 times, most recently
from
November 18, 2026 00:10
95e9719 to
13035f7
Compare
ymichael
added a commit
that referenced
this pull request
Nov 18, 2026
…ws from each bridge Review of #7723 found the rule let a JSON-RPC error stand in for a warning, but Codex turns an error into "the user declined" (#4645). Every non-user answer now sends the owner's warning, whatever the provider receives. Newly routed through the owner: - Codex: unreadable and unmatched question requests, and runtime errors, unreadable resolutions and unmappable answers for command, file-change and permission approvals and requestUserInput, not only MCP elicitations. - Claude Code: invalid AskUserQuestion/ExitPlanMode input, runtime errors, unreadable resolutions and unmappable answers (deny with the owner's text). - ACP: a new prompt silently cancelled the open question of an agent-initiated turn; it now withdraws it with a warning and an error. - Plugin settings save reloaded a needs-configuration plugin and dropped its load problem; the route now answers 422 like enable and reload. The guard derives its ACP, Pi and Codex rows from the question kinds each bridge routes (ACP_QUESTION_REQUEST_METHODS, PI_EXTENSION_DIALOG_METHODS, CODEX_QUESTION_REQUEST_METHODS), covers Codex approvals, requestUserInput and Claude permissions, and requires a warning for every non-user answer. With the old behaviour restored it fails 29 of 88 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/class-fix-failures-never-reported-as-user-answer-thr_3aancrnpbf
branch
from
November 18, 2026 05:38
13035f7 to
497c515
Compare
ymichael
added a commit
that referenced
this pull request
Nov 18, 2026
…ws from each bridge Review of #7723 found the rule let a JSON-RPC error stand in for a warning, but Codex turns an error into "the user declined" (#4645). Every non-user answer now sends the owner's warning, whatever the provider receives. Newly routed through the owner: - Codex: unreadable and unmatched question requests, and runtime errors, unreadable resolutions and unmappable answers for command, file-change and permission approvals and requestUserInput, not only MCP elicitations. - Claude Code: invalid AskUserQuestion/ExitPlanMode input, runtime errors, unreadable resolutions and unmappable answers (deny with the owner's text). - ACP: a new prompt silently cancelled the open question of an agent-initiated turn; it now withdraws it with a warning and an error. - Plugin settings save reloaded a needs-configuration plugin and dropped its load problem; the route now answers 422 like enable and reload. The guard derives its ACP, Pi and Codex rows from the question kinds each bridge routes (ACP_QUESTION_REQUEST_METHODS, PI_EXTENSION_DIALOG_METHODS, CODEX_QUESTION_REQUEST_METHODS), covers Codex approvals, requestUserInput and Claude permissions, and requires a warning for every non-user answer. With the old behaviour restored it fails 29 of 88 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bridges answered cancel or decline when bb, not the user, ended a question: the ACP bridge on runtime errors, unreadable resolutions and answers that did not fit; the Pi bridge on every failure, including dialogs it could not show (#4264, #7647); and Codex MCP elicitations on runtime errors and unreadable resolutions. The agent then believed the user had declined, and the user never learned their question was lost. A new contract test runs every first-party bridge (ACP forms, ACP permissions, Pi dialogs, Codex MCP elicitations, Claude Code questions) through four failure causes and a user stop. Each failure must reach the agent as an error or come with a warning; a user stop must not warn. It failed 12 of 25 cases on main. Every bridge now answers without the user through one bridge-kit owner, unansweredInteractionWarning (SDK: experimental_unansweredInteractionWarning), which builds the provider.warning row. ACP answers such questions with a JSON-RPC error that says why; Pi and Codex keep their protocol's cancel. ask-user-question names non-user cancellations instead of saying the user dismissed the question (#7347). The plugin enable route returned ok when the plugin failed to load. setEnabled now returns the load problem and the route answers 422, so the CLI special case from #5534 is deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ws from each bridge Review of #7723 found the rule let a JSON-RPC error stand in for a warning, but Codex turns an error into "the user declined" (#4645). Every non-user answer now sends the owner's warning, whatever the provider receives. Newly routed through the owner: - Codex: unreadable and unmatched question requests, and runtime errors, unreadable resolutions and unmappable answers for command, file-change and permission approvals and requestUserInput, not only MCP elicitations. - Claude Code: invalid AskUserQuestion/ExitPlanMode input, runtime errors, unreadable resolutions and unmappable answers (deny with the owner's text). - ACP: a new prompt silently cancelled the open question of an agent-initiated turn; it now withdraws it with a warning and an error. - Plugin settings save reloaded a needs-configuration plugin and dropped its load problem; the route now answers 422 like enable and reload. The guard derives its ACP, Pi and Codex rows from the question kinds each bridge routes (ACP_QUESTION_REQUEST_METHODS, PI_EXTENSION_DIALOG_METHODS, CODEX_QUESTION_REQUEST_METHODS), covers Codex approvals, requestUserInput and Claude permissions, and requires a warning for every non-user answer. With the old behaviour restored it fails 29 of 88 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/class-fix-failures-never-reported-as-user-answer-thr_3aancrnpbf
branch
from
November 18, 2026 21:05
497c515 to
f15d1c2
Compare
ymichael
deleted the
bb/class-fix-failures-never-reported-as-user-answer-thr_3aancrnpbf
branch
November 18, 2026 21:14
ymichael
added a commit
that referenced
this pull request
Nov 18, 2026
## Human comments ## What was wrong A provider can stop waiting on a request it raised: a Claude `PermissionRequest` hook answers it and the SDK aborts the `can_use_tool` request, Codex sends `serverRequest/resolved`, a Pi dialog reaches its `timeout`, or an ACP/Pi session ends with a permission open. In each case the bridge dropped its local waiter (Claude's `onAbort` only answered `deny` locally; Codex ignored `serverRequest/resolved`) and nothing reached the runtime, daemon, or server. The interaction row stayed `pending`, so the card stayed up and every later message queued behind it (#6966). The wire had no way to say a request was withdrawn: `notifications/cancelled` existed only for ACP tool calls, and the server only closed interactions per thread (provider exit) or on reconnect. Pointed at by T3 Code's fix for the same bug, pingdotgg/t3code#27320. ## What changed - **Bridge → runtime:** `BRIDGE_NOTIFICATION_METHODS.requestCancelled` (`notifications/cancelled { requestId }`) now covers `interaction/request` as well as tool calls. Every bridge that stops waiting sends it: - Claude: the SDK abort for permission requests and user questions, and session close/replace/stream end. - Codex: `serverRequest/resolved` for a request bb has not answered, plus child exit and session release. These apply to forwarded tool calls too. - ACP: `cancelPendingPermissions`, which covers stop, release, steer cancel, policy change, and agent exit. - Pi: dialog `timeout` and session close/replace. - **Runtime:** `RuntimeToolCalls` → `RuntimeProviderRequests`, also used for interactive requests. `onInteractiveRequest(request, signal)` gets an abort signal. A withdrawn request is never answered. - **Daemon:** `InteractiveRequestRegistry.registerAndWait(request, signal)` rejects a withdrawn wait. Once registration settles, it reports the withdrawal through the existing retrying interrupt queue to a new `POST /session/interactive-request/withdraw` route, so a withdrawal that races registration cannot leave a row behind. - **Server:** `interruptWithdrawnProviderRequest` closes the matching row as `interrupted` with the reason "The agent stopped waiting for this answer". The next queued message then dispatches. It writes the lifecycle record but not the approval's `item/completed: interrupted`. Writing that item made the projection drop the real result Claude sends after the hook allows the tool; the first live re-run caught this. - **Projection (`thread-view`):** a call that its turn ends without settling no longer keeps `approvalStatus: waiting_for_approval` (in `interruptPendingToolMessages`, `event-projection-state.ts`). This affects a provider that withdraws and never settles the item. - **On top of #7723:** ACP's `withdrawPendingQuestions` (bb answers on its own when a new prompt starts) now also aborts the forwarded request, so that card closes too. Codex and Pi keep #7723's unanswered-interaction warnings and add the withdrawal on top. - **Wire:** `HOST_DAEMON_PROTOCOL_VERSION` 268 → 269 (new route). Plugin SDK 0.6.160 → 0.6.161 (new `BRIDGE_NOTIFICATION_METHODS` key, bridge-grammar snapshot). Docs: `docs/provider-bridge-protocol.md`, `docs/provider-plugin-api.md`. - **Test fixtures:** the scripted-echo bridge gets `withdraw_approval`, and the fake Codex app-server gets `withdrawAfterMs`. ## How you verified **Live repro, before (origin/main 502cf5a, `pnpm start:worktree`, claude 2.1.325).** I used a project `.claude/settings.json` `PermissionRequest` hook (matcher `Bash`) that returns `allow`, and a `claude-code` thread in `accept-edits` that runs two unsandboxed `curl` commands. Both commands completed (`HTTP/2 200`) and the turn finished with `DONE.`. Then: ```text bb thread interactions list -> pint_2dsywi5jzf pending, pint_r4b2sui9p5 pending bb thread list --json -> {"status":"idle","hasPendingInteraction":true} bb thread tell 'Reply OK.' -> message queued (waiting for a pending interaction); it dispatches when that clears ``` **Same steps, after:** ```text pending_interactions -> both interrupted, "The agent stopped waiting for this answer" (rows from the first after-run, which still used the earlier wording) command items -> completed, exitCode 0, "HTTP/2 200"; timeline rows status completed, no approval state bb thread list -> idle, hasPendingInteraction false bb thread tell -> dispatched; agent replied "OK." ``` I also stopped a thread with a genuinely pending approval (no hook). The card closed and the command row shows `interrupted` with no lingering "waiting for approval". After rebasing onto #7754 (timeline rows rebuilt from item records) and #7723, I re-ran both live cases. The hook case shows both commands `completed`, exit 0, `HTTP/2 200`, `approvalStatus: null`, both cards `interrupted`, and the follow-up dispatched. The stop-while-pending case shows the card `interrupted` and the command row `interrupted` with no approval state. **Tests:** - New tests: - Integration: `tests/integration/fake/smoke/withdrawn-approvals.test.ts`, full server + daemon + runtime + scripted bridge. The card closes, the row is not left waiting, and the follow-up message dispatches. - Runtime: abort on withdraw. - Daemon registry: withdraw after registration, during registration, never registered, and after the answer. - Daemon app: posts the withdraw route. - Server: route, idempotence, and the item left to the provider. - Bridges: Claude (approval + user question), Codex `serverRequest/resolved` (no late answer reaches Codex), ACP stop, Pi timeout/answer/close. - thread-view: the turn-end approval state. - They fail without the fix. With the runtime's interactive cancel disabled, the integration test fails with `expected [ { id: 'pint_nk2fcgcggg', … } ] to deeply equal []`. Without the projection change, the thread-view test fails. - `pnpm exec turbo run typecheck` and `test` pass for `@bb/agent-runtime`, `@bb/host-daemon`, `@bb/server`, `@bb/host-daemon-contract`, `@bb/provider-bridge-protocol`, `@bb/provider-bridge-acp`, `@bb/thread-view`, the Claude, Codex, and Pi plugins, and the scripted-echo bridge. `lint` passes on the touched packages. Fixes #6966 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
When a question or permission request ended for any reason other than the user, each bridge chose its own answer, usually the protocol's "the user cancelled" or a bare error, and nobody told the user. The runtime gives a bridge only an error string when bb stops waiting. ACP answered
cancel/decline/cancelled, and Pi answered{cancelled:true}. Codex answeredcancelfor MCP elicitations and a bare JSON-RPC error for approvals and requestUserInput, which Codex itself reports to the model as the user declining (#4645). Claude Code denied with an internal message. ACP also silently cancelled the open question of an agent-initiated turn when the user sent a new prompt, so the card stayed open in bb and any later answer went nowhere. Two other places had the same shape.ask-user-questionturned every non-timeout cancellation into "the user dismissed the question" (#7347). The plugin enable and settings-save routes returnedokwhen the plugin failed to load, because the service droppedloadOne's problem. #5534 patched enable in the CLI only.Reproduced live on main (1fa400d) before the fix. In a source build, a Pi extension command opened a
selectwhose title was 9,010 characters. The bridge failed validation and answered{cancelled:true}, and the extension recordedanswer: null. The thread showed nothing: no pending interaction and no warning. This is the #4264 / #7647 shape.What changed
packages/provider-bridge-protocol/src/contract-tests/unanswered-interactions.test.tsloads each first-party bridge in-process and drives every question kind it routes through six cases: unshowable request, runtime error (bb stopped waiting), unreadable resolution, unmappable answer, withdrawn question, and stopped turn. Each bridge's rows come from a list its own dispatch code uses: ACP fromACP_QUESTION_REQUEST_METHODS(the handler maphandleAgentRequestdispatches through), Pi fromPI_EXTENSION_DIALOG_METHODS(the enum its request schema validates) and Codex fromCODEX_QUESTION_REQUEST_METHODS(the gatedecodeCodexInteractiveRequestswitches over). A kind added to any of them fails the guard until it has a surface. Claude Code's three surfaces (AskUserQuestion, ExitPlanMode, any other tool's permission) are listed by hand; see "Left out" below. The rule: every answer the user did not give sends aprovider.warning, whatever the provider receives. A JSON-RPC error alone does not count. A stopped turn adds no warning. A case a surface cannot reach must say why. The result is 88 rows. Turbo test inputs for@bb/provider-bridge-protocolinclude Pi and ACP, so a change in any bridge re-runs the guard.unansweredInteractionWarning({ cause, answer })builds the warning andunansweredInteractionErrorMessage(cause)gives the agent-facing error or deny text. The SDK exports them asexperimental_*, with an audit entry, Plugin Guide symbols and aprovider-plugin-api.mdsection. The causes are unshowable request, runtime error, unreadable resolution, unmappable answer and withdrawn. Every bridge site that answers without the user goes through them:{cancelled:true}, since Pi has no failure answer, but now with the warning.buildCodexInteractiveResultreturns a typedanswered | unansweredresult for every payload kind. MCP elicitations keepcancel; approvals and requestUserInput keep the error, now carrying the owner's text. Unknown non-question server requests still get METHOD_NOT_FOUND and no warning.switchoverPluginInteractionCancelReason. Onlyuserreads as a dismissal; other reasons name themselves.setEnabledandupdateSettingsreturn{ ok, error?, … }with the load problem.POST /plugins/:id/enableandPUT /plugins/:id/settingsanswer 422 (plugin "x" did not start: …), like reload. A route table covers reload, enable and settings save. The Exit 1 when bb plugin enable leaves the plugin in error #5534 CLI special case is deleted, and the CLI guide notes that enable exits 1 with the load error.Issues this root cause produced
cancelledbecause its protocol has no failure answer. #7660 shortens the text.bb plugin enableexits 0 /ok:trueon a failed loadOn main, the first version of the guard failed 12 of 25 rows. With this PR's behavior reverted (Claude without warnings, Codex error answers without warnings, ACP's silent cancel on a new prompt), the expanded guard fails 29 of 88 rows. The settings-save row fails with the old settings route.
Patches deleted: the #5534 enable workaround in the CLI; #6518's ACP-local "could not show" wording; Codex's MCP-only cancel special case (
buildCodexInteractiveResultnow handles every kind); and the Pi and Codex tests that asserted a silent cancel as correct behavior.Left out, deliberately
stopsRequested(and ACP's and Pi's stop handling) treats every interrupt as a stop, including workflowstopChildand archive. The bridge cannot do better:thread/stopcarries onlyintent, and workflowstopChildcalls the samethreads.stopAPI as the user, so even the server records it as a manual stop. A stopped turn is never silent, though. The server marks the open questioninterruptedwith its reason in the timeline, and for the agentcancelledis the protocol's meaning of a cancelled turn. Carrying a stop origin to bridges would be a server, daemon and bridge wire change (HOST_DAEMON_PROTOCOL_VERSION) that adds nothing the timeline doesn't already show. The guard calls this case "turn-stopped" rather than "user-stop".canUseToolspecial-cases two tool names and treats every other tool as a permission. There is no list in its dispatch to derive from, and adding one only for the test would be a test-only production seam.Decisions for review
cancel/decline/cancelledfor these failures, including permission requests and questions withdrawn by a new prompt.plugins.enableandplugins.updateSettingsthrow.How you verified
@bb/provider-bridge-acpbridge.test.tsandelicitation.test.ts, Piextension-ui*, Codexinteractive-requests,bridge.elicitation,bridge.native-questionandbridge.calibration, Claude Codebridge.test.ts, ask-user-questionserver-harness, the server plugin service/route/settings/update/safe-mode/logo/icon/app-bundle suites, heroes, echo-provider, provider-management, and the CLIplugin-enable.turbo run typecheck lintfor the protocol, ACP, plugin SDK, Pi, Codex, Claude Code, Plugin Guide and server packages.provider/warning"bb answered the agent without you" ("…with "cancelled" because it could not show the question: title: Too big: expected string to have <=8192 characters"), and it is visible in the thread timeline.Fixes #7347
🤖 Generated with Claude Code