fix(claude): only enable 1M context beta when model has [1m] suffix#273
Merged
Conversation
Both executors unconditionally set: queryOptions.betas = ['context-1m-2025-08-07']; The comment acknowledged this was a no-op on OAuth / Pro-Max (where betas are ignored and the `[1m]` suffix is the actual lever), but on API-key auth the SDK honors the beta header — so every API-key user got 1M context for *every* model, including plain `opus-4-7`. Visible symptom: `/model claude-opus-4-7` showed a 1000k context window in the card footer (and billed at 2× the rate) instead of the expected 200k. The user only intended 1M on the explicit `claude-opus-4-7[1m]` form. Fix: only emit the beta flag when the model name contains `[1m]`. That makes the suffix the single canonical signal for both auth paths — SDK parses it directly, and we re-send the matching beta as belt-and-braces for any auth mode that needs the explicit header. Both `executor.ts` and `persistent-executor.ts` had the same unconditional line; both fixed. Comment notes they must stay in sync. No new tests — the SDK's beta dispatch is mocked away in vitest, and the change is one conditional. All 291 existing tests still pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
SimonYeyi
pushed a commit
to SimonYeyi/metabot
that referenced
this pull request
May 26, 2026
…virobotics#273) Both executors unconditionally set: queryOptions.betas = ['context-1m-2025-08-07']; The comment acknowledged this was a no-op on OAuth / Pro-Max (where betas are ignored and the `[1m]` suffix is the actual lever), but on API-key auth the SDK honors the beta header — so every API-key user got 1M context for *every* model, including plain `opus-4-7`. Visible symptom: `/model claude-opus-4-7` showed a 1000k context window in the card footer (and billed at 2× the rate) instead of the expected 200k. The user only intended 1M on the explicit `claude-opus-4-7[1m]` form. Fix: only emit the beta flag when the model name contains `[1m]`. That makes the suffix the single canonical signal for both auth paths — SDK parses it directly, and we re-send the matching beta as belt-and-braces for any auth mode that needs the explicit header. Both `executor.ts` and `persistent-executor.ts` had the same unconditional line; both fixed. Comment notes they must stay in sync. No new tests — the SDK's beta dispatch is mocked away in vitest, and the change is one conditional. All 291 existing tests still pass. Co-authored-by: Flood Sung <floodsung@xvirobotics.ai> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Both Claude executors unconditionally set the 1M-context beta flag on every request:
```ts
queryOptions.betas = ['context-1m-2025-08-07'];
```
The comment correctly noted that betas are ignored on OAuth / Pro-Max auth (where the `[1m]` model-name suffix is the real lever), but on API-key auth the SDK does honor the beta header — so every API-key user got 1M context for every model, including plain `opus-4-7`.
User-visible symptom
Picking `/model claude-opus-4-7` showed `1000k` in the card footer (and billed at ~2× rate) instead of the expected `200k`. The 1M was supposed to be opt-in only via `/model claude-opus-4-7[1m]`.
Fix
Only emit the beta flag when the model name contains `[1m]`. The suffix is now the single canonical signal for both auth paths:
Both `executor.ts` and `persistent-executor.ts` had the same unconditional line — both fixed, both comment-tagged that they need to stay in sync.
Test plan
🤖 Generated with Claude Code