Skip to content

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

Merged
SawyerHood merged 1 commit into
get-bb:mainfrom
smsunarto:scott/fable-context
Aug 26, 2026
Merged

fix(claude-code): display correct context window for Fable running against BYOK endpoint#2311
SawyerHood merged 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 170 to 171 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 test --filter=bb-plugin-provider-claude-code --force — 335 tests passed.
  • pnpm exec turbo run test --filter=@bb/host-daemon-contract --force -- test/contract.test.ts — 37 tests passed.
  • pnpm exec turbo run typecheck --filter=bb-plugin-provider-claude-code --filter=@bb/host-daemon-contract --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.

Fixes # — no linked issue.

AGENT GENERATED

@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
refactor(claude-code): simplify context capacity normalization

test(claude-code): cover custom endpoint context reporting
@SawyerHood
SawyerHood force-pushed the scott/fable-context branch from dec12e6 to 9bb962a Compare August 26, 2026 22:33
@SawyerHood
SawyerHood merged commit 6f63cd7 into get-bb:main Aug 26, 2026
13 checks passed
@smsunarto
smsunarto deleted the scott/fable-context branch August 26, 2026 23:18
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.

2 participants