Skip to content

fix(claude): only enable 1M context beta when model has [1m] suffix#273

Merged
floodsung merged 1 commit into
mainfrom
fix/1m-context-only-when-suffix-set
May 14, 2026
Merged

fix(claude): only enable 1M context beta when model has [1m] suffix#273
floodsung merged 1 commit into
mainfrom
fix/1m-context-only-when-suffix-set

Conversation

@floodsung

Copy link
Copy Markdown
Contributor

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:

  • SDK parses the suffix directly (covers OAuth / Pro-Max).
  • We re-send the matching beta header as belt-and-braces (safety net for API-key auth, and for any future SDK rev that needs the explicit header).

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

  • `npm run build` clean
  • `npx vitest run` — 291 / 291 pass
  • `npm run lint` — 0 errors, 2 pre-existing warnings (untouched)
  • Manual on Feishu (API-key auth): `/model claude-opus-4-7` then send a prompt, confirm card footer shows `ctx: …/200k`
  • Manual: `/model claude-opus-4-7[1m]` then send a prompt, confirm card footer shows `ctx: …/1000k`
  • Manual (OAuth / Pro-Max): same two checks — `[1m]` suffix should be the only way to enable 1M

🤖 Generated with Claude Code

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>
@floodsung floodsung merged commit a6ce914 into main May 14, 2026
3 checks passed
@floodsung floodsung deleted the fix/1m-context-only-when-suffix-set branch May 14, 2026 06:19
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>
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