Repository navigation
Fix Claude conversations blocked by automatic context reporting - #5914
Merged
Merged
Conversation
ymichael
added a commit
that referenced
this pull request
Nov 16, 2026
## Human comments ## What was wrong bb starts two short-lived Claude Code processes to read session metadata: the initialization probe (`plugins/provider-claude-code/src/bridge/initialization-probe.ts:41`) and the isolated context-usage probe (`plugins/provider-claude-code/src/bridge/context-usage-probe.ts:26`). Both load `settingSources: ["user", "project", "local"]` and do not restrict MCP. So each probe connected to every user, project and plugin MCP server, and then closed about 1 s later while MCP discovery was still in progress. The context probe runs at the start of every turn, so MCP servers saw a dropped connection on every turn (#6655, [report](https://get-bb.github.io/reports/issues/6655.html)). ## What changed - `initialization-probe.ts`: adds `strictMcpConfig: true`. The probe passes no `mcpServers`, so the CLI starts no MCP server. `probeClaudeUsage` shares this code path. - `context-usage-probe.ts`: adds `strictMcpConfig: true`. When the thread has dynamic tools, the bb bridge server is still passed through `mcpServers`, so those tools are still loaded and counted. - `__tests__/probe-mcp-isolation.test.ts` (new): with a mocked SDK `query`, checks that both probes set `strictMcpConfig` and pass no MCP server except the bb bridge. In `@anthropic-ai/[email protected]`, `strictMcpConfig` maps to `--strict-mcp-config`: the CLI uses only the servers given in `mcpServers` and ignores `.mcp.json`, user settings, plugins and agent frontmatter (`sdk.d.ts:2403`). No wire, protocol, CLI or doc change. Difference from the issue: the issue also suggests reading context usage from the live session or caching it. #5914 moved away from the live session because it blocked conversations, so that is not part of this PR. ## How you verified - Before the fix (new test on the old probes): `AssertionError: expected { cwd: '/tmp/probe', env: {}, ...(3) } to match object { strictMcpConfig: true }`, 2 of 2 tests fail. - After the fix: `pnpm exec turbo run lint lint:type-aware typecheck test --filter=bb-plugin-provider-claude-code` passes, 11 of 11 tasks, 31 test files, 444 tests, 0 lint warnings. `oxfmt --check` passes. - Real SDK and bundled CLI (Linux x64, outside the repo, temporary HOME with a user-scope HTTP MCP server on loopback and a fake `count_tokens` endpoint): - Old code: both probes connected to the MCP server on every run (`POST /mcp` twice per probe). Across 10 context-probe runs, the user MCP tool was reported with 0 tokens and `isLoaded: false` at most, and `totalTokens` was 1648 every time. - New code, 3 runs each: 0 MCP requests from either probe. The probes still returned 5 models, 44 commands and `totalTokens` 1648. With dynamic tools, `mcp__bb-bridge__probe_tool` was still listed. - Not verified: macOS, `headersHelper`, a real Anthropic account, and a run through the bb UI. With a real account, a fast MCP server could in theory answer before `getContextUsage` and add its tool tokens to the old number. The new number never includes user MCP tools. No such count was seen in the runs above. Fixes #6655 > AGENT GENERATED --------- Co-authored-by: Michael Yong <[email protected]> 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
Automatic Claude context reports ran on the same Claude process that handles user prompts. A stalled token-count request could block that process from consuming the next prompt. BB's five-second report timeout only stopped waiting for the result; it did not cancel the underlying request, so the conversation could remain stuck until manually stopped.
What changed
Keep automatic context breakdowns, but collect them in a separate, non-persisted fork of the saved conversation. The reporter has its own MCP server, disables hooks, and cannot execute tools. A five-second deadline, replacement report, or thread stop closes the reporter. User prompts continue on the live process without waiting for reporting or restarting the conversation.
Remove the live session's context-report method, document the isolation behavior in the provider skill, and keep diagnostic forks from consuming conversation segments in the replay harness. No server/daemon wire contracts change.
How you verified
pnpm exec turbo run test typecheck lint --filter=bb-plugin-provider-claude-code— 398 tests passed; typecheck and lint passed.pnpm exec turbo run test typecheck lint --filter=@bb/provider-bridge-protocol— all 314 tests passed, including replay and cross-provider permission contracts; typecheck and lint passed. The permission fixture distinguishes diagnostic forks from the live session.