← reports

#6966 · Provider approval withdrawal is not forwarded

BugPriority: MediumEffort: Mediumprovidersprovider-claude-codeGitHub issue

2026-11-03 · trusted base d083003e469db9fa4b85d6abe56519e0e034b25f

PARTIALLY REPRODUCED · Root-cause confidence: high for the missing bridge cancellation; medium for the complete reported hook-to-queue sequence.

1. TL;DR

A provider can withdraw a tool-approval request after bb has already received it. The Claude bridge correctly settles its own SDK callback on withdrawal, but sends no message to the rest of bb. A focused test against unchanged production code confirms that information is lost, and a second clean checkout gives the same result. Static tracing shows why a separately persisted approval could then keep a later message waiting. The actual desktop, live Claude hook, completed MCP tool, and queued follow-up were not exercised here, so the overall verdict is deliberately partial rather than a claimed end-to-end reproduction.

2. Claims vs findings

Claim, paraphrasedFindingEvidence
A provider-side cancellation leaves bb unaware of an obsolete approval.Verified at the bridge boundaryAn approval request is emitted; abort settles the SDK callback; zero subsequent transport messages are emitted. Identical assertion failure in two checkouts.
A hook answers while a permission prompt is outstanding, and the tool still completes.Unverified liveNo real Claude CLI, MCP connector, user credentials, or hook script was run. The test supplies the SDK AbortSignal directly.
An idle thread retains a pending card and a follow-up stays queued.Supported by code; unverified liveServer persists provider interactions independently. Queue wake-up refuses to proceed while a turn-bound interaction remains. No server database or UI was exercised.
Read-only tool annotations avoid the problem, and manually answering the card unblocks it.UnverifiedNeither the annotation distinction nor the manual workaround was tested.

3. Environment and trusted inputs

4. Minimal reproduction

  1. Clone trusted main, pin the recorded base, and install/build existing dependencies:
    git clone https://github.com/get-bb/bb.git bb-6966-base
    cd bb-6966-base
    git checkout --detach d083003e469db9fa4b85d6abe56519e0e034b25f
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build

    The first all-package build in this investigation encountered an SDK build-order race in the GitHub plugin. Explicitly building the SDK and repeating the normal all-package build succeeded: 73/73 tasks. This was an environment/setup failure, not the reproduced cancellation failure.

  2. Apply the following investigator-authored patch. It extends the existing bridge test harness and uses its established mocked SDK only; it adds no export, production seam, or dependency.
    git apply <<'PATCH'
    diff --git a/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts b/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts
    index 9da1b8c75f..bccc2f5340 100644
    --- a/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts
    +++ b/plugins/provider-claude-code/src/bridge/__tests__/bridge.test.ts
    @@ -2650,6 +2650,50 @@ describe("bridge", () => {
         }
       });
     
    +  it("notifies bb when the SDK withdraws a pending tool approval", async () => {
    +    const bridge = createBridgeJsonRpcTestHarness(handleLine);
    +    const queries: ControlledClaudeQuery[] = [];
    +    const threadId = "thread-approval-withdrawal";
    +    queryMock.mockImplementation(() => {
    +      const query = createControlledClaudeQuery();
    +      queries.push(query);
    +      return query;
    +    });
    +
    +    try {
    +      await startBridgeThread({ bridge, threadId });
    +      const controller = new AbortController();
    +      const resultPromise = getLastCanUseTool()(
    +        "mcp__fixture__write_record",
    +        { value: "fixture" },
    +        {
    +          requestId: "control-fixture",
    +          signal: controller.signal,
    +          toolUseID: "tool-fixture",
    +        },
    +      );
    +      const request = await waitForBridgeRequest(bridge, isApprovalInteraction);
    +      expect(request).toMatchObject({
    +        params: { threadId, payload: { kind: "approval" } },
    +      });
    +      const messageCount = bridge.messages.length;
    +
    +      controller.abort();
    +      await expect(resultPromise).resolves.toMatchObject({
    +        behavior: "deny",
    +        message: "Interactive request cancelled",
    +      });
    +      await bridge.flushWork();
    +
    +      const cancellationMessages = bridge.messages.slice(messageCount);
    +      expect(cancellationMessages).not.toEqual([]);
    +    } finally {
    +      await stopBridgeThread({ bridge, queries, threadId });
    +      queries.forEach((query) => query.finish());
    +      bridge.restore();
    +    }
    +  });
    +
       it("forwards ExitPlanMode for user approval in plan mode", async () => {
         const bridge = createBridgeJsonRpcTestHarness(handleLine);
         const queries: ControlledClaudeQuery[] = [];
    PATCH
  3. Run the focused test from the repository root:
    pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/bridge.test.ts -t 'notifies bb when the SDK withdraws a pending tool approval'

Expected

After a previously forwarded approval is withdrawn, bb must receive an identifiable terminal cancellation/disposition for that request. This diagnostic checks the weaker necessary condition that some outbound message is sent. It deliberately does not prescribe a new wire method.

Actual

The approval creation assertion and local SDK-result assertion pass. The transport assertion fails because the message list after abort is empty. Verbatim diagnostic lines from each run:

FAIL  |bb-plugin-provider-claude-code| src/bridge/__tests__/bridge.test.ts > bridge > notifies bb when the SDK withdraws a pending tool approval
AssertionError: expected [] to not deeply equal []

Test Files  1 failed (1)
     Tests  1 failed | 106 skipped (107)

The added test is 44 text lines in one existing file. Its credible regression is losing the provider-to-bb withdrawal signal; existing nearby tests cover successful user responses, not this abort path. Before proposing any production patch, a stronger regression should check request correlation, server state, and queue dispatch rather than merely nonempty output.

5. Root cause

  1. The bridge generates its own interactive request ID. It stores a local waiter and sends interaction/request with that ID. The SDK control request ID is not a server interaction ID.
  2. The approval abort handler deletes that local waiter and settles the SDK callback, but does not call the transport sender:
    const onAbort = (): void => {
      if (!threadSession.pendingInteractiveRequests.delete(requestId)) {
        return;
      }
      finish({
        behavior: "deny",
        message: "Interactive request cancelled",
        toolUseID: args.toolUseId,
      });
    };

    The local deny here settles bb's callback after cancellation; it is not evidence that the already-withdrawn tool was denied by Claude or that a hook's result was undone.

  3. The runtime scopes the provider request ID and waits for the host interaction callback. That callback accepts the request but no AbortSignal.
  4. The daemon registers and waits for the interaction. The host registry keeps a distinct pending entry. Deleting the bridge's own Map entry cannot delete this entry.
  5. The server persists the provider interaction without an expiry. Interaction-settled queue dispatch checks for remaining turn-bound interactions. This explains how a stale persisted request can still prevent a follow-up from dispatching. This last causal chain is source-based, not an executed server-level reproduction.

The deeper gap is an absent request-withdrawal lifecycle across the bridge/runtime/host/server boundary, not a card-rendering refresh bug. The typed bridge notification vocabulary has no interaction-withdrawal entry. A sender-only notification would not suffice without a matching consumer and persisted-state transition.

6. Proposed fix and automation safety

Design a correlated provider-withdrawal path that retires exactly the pending request, carries cancellation through the runtime and daemon, settles the server interaction without granting permission, and wakes the existing queue machinery. Make it idempotent and test withdrawal racing with registration and with a user response. Preserve already-resolved interactions and avoid treating a provider cancellation as user approval. Reuse existing interruption machinery where its semantics match; explicitly assess version compatibility for enrolled daemons.

No automated fix or PR was safe under the rule. A robust proposal changes the public bridge/lifecycle contract and spans provider, runtime, daemon, and server ownership. That fails the one-subsystem/no-public-protocol-change conditions regardless of line count. No production fix branch was created, committed, or pushed. No open PR was found through issue cross-reference metadata or a separate open-PR search for the numeric issue.

7. Verification

The same investigator repeated the reproduction, not an independent agent. A second clean clone of the canonical repository was detached at d083003e469db9fa4b85d6abe56519e0e034b25f; clean git status --short was checked before adding the same 44-line test. It received its own frozen dependency install and SDK build, then the exact focused Turbo command above. Both runs executed rather than using a cached test result.

RunResultMeaning
First clean base checkoutExit 1; one failed test, 106 skipped; 2.03s Vitest durationExpected failure: zero bridge messages after SDK abort.
Second clean verification checkoutExit 1; one failed test, 106 skipped; 1.55s Vitest durationThe same abort-to-transport gap recurs with fresh module/session state.
Existing adjacent response-path testsExit 0; two passed, 105 skippedExisting question and plan-approval forwarding paths still work in the test environment.
Source integritygit diff --check passes in both checkouts; only the same test file differs from each recorded base.No production code modified; no binary changes.

No correction was needed after the second run. The verified metadata means this scoped, partial report was repeated successfully; it does not upgrade the missing live-hook reproduction to end-to-end verification.

8. Related issues and PRs

Issue metadata contained no cross-referenced PRs, and the open-PR numeric search returned none during this investigation. No linked branch, historical PR patch, reporter script, or reporter test was executed. This report does not claim a historical PR has been reviewed.

9. Appendix: commands, limits, and publication

pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/bridge.test.ts -t 'notifies bb when the SDK withdraws a pending tool approval'
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/__tests__/bridge.test.ts -t 'forwards ExitPlanMode for user approval in plan mode|forwards AskUserQuestion'
git diff --check
git diff --numstat

Repeat the focused test in a second clean clone pinned to the recorded commit. No production services need stopping because none were started. Raw logs, the test diff, and process notes stay outside the public reports repository; the complete reproduction patch is inline above. No screenshot or fabricated transcript is supplied.

Trust boundary: the issue, including its commands and code blocks, was treated as untrusted evidence. None was executed. The test was derived from the trusted source's SDK callback and existing test harness. Public text omits machine identities, absolute temporary paths, credentials, and user runtime data.

> AGENT GENERATED