Skip to content

Give pooled Claude Code sessions the native 1M Opus context window - #4452

Merged
ymichael merged 3 commits into
get-bb:mainfrom
matthiasvongrundherr:fix/pool-claude-native-1m-context
Sep 29, 2026
Merged

ymichael merged 3 commits into
get-bb:mainfrom
matthiasvongrundherr:fix/pool-claude-native-1m-context

Conversation

@matthiasvongrundherr

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

With Account Pooler routing on, the plugin points Claude Code's ANTHROPIC_BASE_URL at the local hub. Claude Code only gives Opus models without a [1m] suffix their native 1M context window when the base URL is unset or api.anthropic.com, or when _CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL is set. Every pooled Claude Code session therefore ran Opus with a 200k window and compacted or failed with Prompt is too long far below what the pooled account allows. Since 0.44.0 the model catalog has no [1m] variant, so users have no in-app way around it. Root cause and the Claude Code source excerpt are in #4207.

What changed

  • plugins/account-pool/src/server.ts: the claude-code env contribution now adds _CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL=1 next to ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN and ENABLE_TOOL_SEARCH, following the existing ENABLE_TOOL_SEARCH override. The hub forwards to Anthropic's API with the pooled account's own credentials, so Claude Code now applies the same model limits as with a direct login. Bypassed threads and instances that neutralise inherited routing get nothing new.
  • Docs: docs/configuration.md and the plugins guide template (bb-guide-plugins.md) name the new variable and why it is set.
  • No wire change, no HOST_DAEMON_PROTOCOL_VERSION bump, no catalog change.
  • Scope relative to Account Pooler drops Claude Code Opus to a 200k context window (ANTHROPIC_BASE_URL disables native 1M); no [1m] model to work around it #4207: this is suggested fix 1. Fixes 2 ([1m] catalog entries) and 3 (the 200k placeholder before the first result) are not part of this PR.
  • The variable is set whenever the hub serves Claude, independent of anthropicUpstreamBaseUrl, the same way ENABLE_TOOL_SEARCH is. A custom upstream still has to accept the pooled accounts' Anthropic credentials, so it is Anthropic's API or a pass-through in front of it.
  • The variable is internal to Claude Code (leading underscore). If a later Claude Code release drops it, pooled sessions fall back to today's 200k and nothing else changes.

How you verified

  • plugins/account-pool/src/server.test.ts: the two tests that pin the full claude-code contribution (direct hub and nested proxy) now expect _CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL=1. Against the previous server.ts both fail (2 failed, 158 passed); with the change they pass.
  • pnpm exec turbo run test typecheck --filter=bb-plugin-account-pool --force: 323 tests passed, typecheck passed.
  • @bb/templates tests: 46 passed. test/plugin-scaffold-external.test.ts fails the same way on main in my environment (npm pack is blocked by my sandbox) and was left out.
  • oxlint on the changed TypeScript files: clean. oxfmt --check: clean except the existing storedConfig expression in server.ts, which is already flagged on main; left unchanged.
  • node scripts/check-source-nul.mjs and node scripts/check-provider-literal-ratchet.mjs: clean.
  • Manual check on bb 0.44.0 with Claude Code 2.1.283, inside a pooled thread with ANTHROPIC_BASE_URL pointing at the hub: claude -p "say ok" --model claude-opus-5-5 --setting-sources "" --output-format json reports modelUsage["claude-opus-5-5"].contextWindow as 200000 without the variable and 1000000 with _CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL=1. Since 2026-09-28 the same variable has been set for all pooled Claude Code sessions on this machine through ~/.claude/settings.json; new sessions report a 1M window.
  • Not run: a bb build with this change and the plugin loaded end to end.

Fixes #4207

🤖 Generated with Claude Code

AGENT GENERATED

@ymichael
ymichael merged commit e837c28 into get-bb:main Sep 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Account Pooler drops Claude Code Opus to a 200k context window (ANTHROPIC_BASE_URL disables native 1M); no [1m] model to work around it

2 participants