Skip to content

fix(claude-code): display correct context window for Fable running against BYOK endpoint - #2311

Open
smsunarto wants to merge 1 commit into
get-bb:mainfrom
smsunarto:scott/fable-context
Open

fix(claude-code): display correct context window for Fable running against BYOK endpoint#2311
smsunarto wants to merge 1 commit into
get-bb:mainfrom
smsunarto:scott/fable-context

Conversation

@smsunarto

@smsunarto smsunarto commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

What was wrong

Claude Agent SDK reports a legacy 200k context window through custom "BYOK" Anthropic endpoints, including Agent Proxy, even when Claude Code OAuth routes Fable 5 with its 1M default. BB trusted that reported value and understated both context-window and token-usage capacity.

What changed

Normalize each reported Claude model's context window against the capacity implied by its model ID. The selected model remains the fallback when Claude omits modelUsage, and larger SDK values remain authoritative. Bump HOST_DAEMON_PROTOCOL_VERSION from 153 to 154 because this changes the meaning of usage events sent across the daemon boundary.

How you verified

  • pnpm exec turbo run test --filter=bb-plugin-provider-claude-code --force -- src/sdk-extraction.test.ts src/delta-translation.usage.test.ts src/bridge/__tests__/bridge.test.ts — 91 tests passed.
  • pnpm exec turbo run typecheck --filter=bb-plugin-provider-claude-code --force — passed.
  • The regression test covers ANTHROPIC_BASE_URL=http://127.0.0.1:8317, an SDK-reported 200k window, and BB-emitted 1M context-window and token-usage values.
  • The full provider suite passed 325 of 326 tests. recorded/fork emitted no replay events. The same failure reproduces on unmodified upstream/main.

Fixes # — no linked issue.

AGENT GENERATED

refactor(claude-code): simplify context capacity normalization

test(claude-code): cover custom endpoint context reporting
@smsunarto
smsunarto force-pushed the scott/fable-context branch from 2db908f to dec12e6 Compare August 22, 2026 23:36
@smsunarto smsunarto changed the title fix(claude-code): report Fable context capacity through custom endpoints fix(claude-code): display correct context window for Fable running against BYOK endpoint Aug 23, 2026
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.

1 participant