Repository navigation
Description
Summary
bb's claude-code provider starts short-lived claude processes to read session metadata.
readIsolatedClaudeContextUsage(context-usage-probe.ts) resumes the thread's session in an isolatedquery(). On my machine this runs at the start of every turn: each user message and each background-task notification.probeClaudeInitialization(initialization-probe.ts, the probe from claude-code initialization probe leaves ~/.claude.json.tmp.* files in $HOME when the disk is slow #6141) starts withpersistSession: falsefrom~/.bb/provider-maintenance-workspace.
Neither one restricts MCP. With settingSources: ["user", "project", "local"], every probe initializes every user-scope MCP server (8 on this machine). It also runs each server's headersHelper. Then it closes about 0.5–1 s later, while tools/list, prompts/list and resources/list are still in flight. The servers see a connection that drops before the request body arrives.
Evidence
Environment: bb 0.47.1, Claude Code 2.1.312, agent-sdk 0.3.245, macOS. Data from one Mac, 28–29 Oct.
- Claude Code's MCP client logs (
~/Library/Caches/claude-cli-nodejs/<cwd>/mcp-logs-<server>/) hold about 900 sessions for one server. Of these:- 741 logged
HTTP connection closed after 0s (cleanly)right after connecting; - 154 logged
Failed to fetch tools: … (CONNECTION_CLOSED); - none has a transcript.
- 741 logged
- Repro. I ran a process sampler while a background-task notification started a new turn. It showed
bb-provider-bridge-workerspawning, in the same second,claude … --resume=<the thread's session> --permission-mode default --setting-sources=user,project,local …next to the long-lived thread process. The extra process lacks--include-partial-messages,--replay-user-messagesand--settings. It exited about 1 s later. A new MCP client session opened and dropped at the same time. - The long-lived thread sessions never lost their tools, so nothing is functionally broken.
Impact
About 450 probes a day on one machine. Each one opens and aborts a connection to every configured MCP server and runs every headersHelper; ours reads the macOS Keychain.
On our side, each aborted request made the server log three errors (starlette ClientDisconnect, then the MCP SDK's stream echo and the stateless session's ClosedResourceError). That reached about 94% of our monthly error-tracking quota before we filtered it. Every MCP server a bb user configures takes the same load.
Suggestion
- Initialization probe: it only needs the initialize response (commands, models, account). Pass
strictMcpConfig: truewithmcpServers: {}. - Context-usage probe: MCP tool definitions do count toward context, so dropping MCP here would change the number. Two possible fixes:
- read the usage from the live session instead of an isolated resume;
- cache it and refresh it only when the MCP or tool set changes, instead of on every turn.
Related: #6141 (the same initialization probe leaves ~/.claude.json.tmp.* files behind). Happy to share logs.
Activity
bb-slop-cop commentedon Oct 30, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotproviders,provider-claude-code,perf.confirmed-repro.gwayne9955 commentedon Nov 12, 2026
This has a worse effect than load when an MCP server uses OAuth with refresh-token rotation: the probes sign every Claude Code session out of that server, about once a day here.
Mechanism
invalid_grant: refresh token does not exist. Claude Code then logsNo valid tokens in storage, clearing stored tokensand clears the shared credential, so every session needs a new sign-in.Evidence (bb 0.49.0 desktop,
claude-code/2.1.319 (sdk-cli, agent-sdk/0.3.318), macOS; one internal HTTP MCP server behind a FastMCP OAuth proxy; 2026-11-07 to 2026-11-12)~/Library/Caches/claude-cli-nodejs/<cwd>/mcp-logs-<server>/: 5 refreshes started by a probe whose log ends afterStarting token refresh/Found client info, with no result. Each probe's log for every MCP server stops at the same moment, about 0.3 to 1.2 s after it starts, and none has a transcript./tokenfor each of those refreshes. The next refresh from a different session got a 401 (invalid_grant) 1 s to 5 min later.Saving tokensand its log ended in the same millisecond. A failure followed 3 s later.invalid_grantfailures that week, in 5 separate sign-out events.~/.bb/provider-maintenance-workspace, so both probes need the fix.#7447 (
strictMcpConfig: trueon both probes) fixes this, because the probes then never connect to the OAuth server. I applied the same two-line change to a local 0.49.0 bundle and will report back if any lost rotation shows up after it.Stop Claude metadata probes from connecting to user MCP servers (get-…