Repository navigation
Restore the 1-hour prompt cache for pooled Claude Code threads - #5130
Merged
SawyerHood merged 1 commit intoOct 7, 2026
Merged
Conversation
Claude Code picks a 5-minute prompt cache when it runs behind a custom base URL, so pooled subscription threads lost the 1-hour cache a direct subscription login gets. Contribute ENABLE_PROMPT_CACHING_1H=1 while a subscription account (or a parent pool) can serve Claude. API-key-only pools keep Claude Code's 5-minute default, and an explicit user TTL setting still wins. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 tasks done
stephendolan
added a commit
to stephendolan/bb
that referenced
this pull request
Oct 13, 2026
Incorporate upstream get-bb#5130, get-bb#5226, get-bb#5283 and settings/clipboard fixes. Keep retry availability scoped to durable conversation assignments, including parent pools and spend-control recovery. Build the managed package against BB 0.46.0 SDK 0.6.37.
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
Claude Code picks its prompt-cache TTL automatically: 1 hour for a recognized Claude subscription login, 5 minutes for an API key or a custom endpoint. Pooled Claude Code threads run with
ANTHROPIC_BASE_URLpointed at the hub andANTHROPIC_AUTH_TOKENset to the hub token. Claude Code then no longer sees a subscription login, so every pooled conversation silently falls back to the 5-minute cache. It also printsclaude.ai connectors are disabled because ANTHROPIC_API_KEY or another auth source is set.Agent threads often pause for more than 5 minutes: a long build or test run, a CI wait, a background task, a thread message, or a user who replies a few minutes later. Each such pause expires the cache. The next request then re-writes the whole conversation prefix at the cache-write price instead of reading it at the cache-read price. With large contexts these rewrites become a large share of usage, so subscription limits drain much faster through the pool than the same work on a direct login. The change is visible in session transcripts: for pooled threads,
usage.cache_creation.ephemeral_1h_input_tokensstays at 0.This is the same class of custom-base-URL side effect the plugin already offsets with
ENABLE_TOOL_SEARCHand_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL.What changed
plugins/account-pool/src/server.ts: theclaude-codeenv contribution now addsENABLE_PROMPT_CACHING_1H=1when the pool can serve Claude through at least one enabled subscription (OAuth) account. It also adds it while the instance proxies to a parent pool, because the child cannot see the parent's account kinds.plugins/account-pool/src/operations.ts: newroutesOnlyApiKeys(provider). When every usable enabled Claude account is an API key, the flag is left out and Claude Code keeps its 5-minute API-key default.ENABLE_PROMPT_CACHING_1Hand notCLAUDE_CODE_PROMPT_CACHE_TTL=1h:CLAUDE_CODE_PROMPT_CACHE_TTLoutranks the user'spromptCacheTtlsetting, so it would silently override a user's explicit choice.ENABLE_PROMPT_CACHING_1Hranks belowFORCE_PROMPT_CACHING_5M,CLAUDE_CODE_PROMPT_CACHE_TTL, thepromptCacheTtlandsubagentPromptCacheTtlsettings, and agent frontmatter. An explicit user choice therefore still wins.subagentPromptCacheTtl: "5m".How you verified
restores the 1-hour prompt cache only while a subscription account can serve Claude:ENABLE_PROMPT_CACHING_1H=1;pnpm exec turbo run typecheck test --filter=bb-plugin-account-pool: typecheck passes, 12 test files / 349 tests pass.turbo run lintfor the plugin passes (two existing warnings inapp.tsx, untouched).enabledfilter inroutesOnlyApiKeysmakes the new test fail.claude -pthrough a local hub, user settings excluded. The response'susage.cache_creationshowed:ephemeral_5m_input_tokens;ENABLE_PROMPT_CACHING_1H=1: onlyephemeral_1h_input_tokens;promptCacheTtl: "5m"setting: onlyephemeral_5m_input_tokens, so the user's setting wins;ephemeral_1h_input_tokens, which confirms the hub routing is what changes the TTL.🤖 Generated with Claude Code