Skip to content

fix(anthropic): give each Claude model its real 128K output maximum - #6316

Closed
vadymhimself wants to merge 3 commits into
lidge-jun:devfrom
vadymhimself:fix/anthropic-per-model-output-maxima
Closed

vadymhimself wants to merge 3 commits into
lidge-jun:devfrom
vadymhimself:fix/anthropic-per-model-output-maxima

Conversation

@vadymhimself

@vadymhimself vadymhimself commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Both Anthropic registry entries declared only defaultMaxOutputTokens 64000 and no per-model map, so every Claude model resolved a 64000 output ceiling. Anthropic documents 128K synchronous max output for all of them except Haiku 4.5, so the figure understated the real ceiling by half on nine models.

That number is not display metadata:

  • resolveOutputCeiling is what the adapter budgets against when a caller declares no max_tokens, so a 128K-capable model stopped at 64000 with stop_reason: max_tokens and the caller had no way to reach the rest.
  • The same value feeds the combo admission reserve in checkComboTargetInputAdmission, where understating a target's output makes its headroom arithmetic wrong in the other direction.

ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS now carries the per-model maxima and both the OAuth and API-key entries consume it, matching the existing ALIBABA_TOKEN_PLAN_MAX_OUTPUT_TOKENS / OPPER_MODEL_MAX_OUTPUT_TOKENS shape.

Each value was read from that model's own overview page on platform.claude.com (/docs/en/models/<slug>/overview), which states it in the header line and again in the Capabilities table:

Model Max output Source
claude-fable-5-1 128K /docs/en/models/fable-5-1/overview
claude-fable-5 128K /docs/en/models/fable-5/overview
claude-sonnet-5-5 128K /docs/en/models/sonnet-5-5/overview
claude-sonnet-5 128K /docs/en/models/sonnet-5/overview
claude-opus-5-5 128K /docs/en/models/opus-5-5/overview
claude-opus-5 128K /docs/en/models/opus-5/overview
claude-opus-4-8 128K /docs/en/models/opus-4-8/overview
claude-opus-4-7 128K /docs/en/models/opus-4-7/overview
claude-opus-4-6 128K /docs/en/models/opus-4-6/overview
claude-sonnet-4-6 128K /docs/en/models/sonnet-4-6/overview
claude-haiku-4-5 64K unchanged — inherits the default

Deliberately not the 300K Message Batches extended-output figure on those same pages: it requires the output-300k-2026-03-24 beta header and does not apply to the synchronous route these providers use.

Haiku 4.5 is genuinely 64K and is left out of the map on purpose so it keeps inheriting the default, and the default stays 64000 as the floor for any model id the map does not name. Raising the default instead would have been a wider change than the defect warrants, since defaultMaxOutputTokens is also the fallback for unlisted ids.

Verification

  • bun run typecheck — clean.
  • bun test tests/adapters/anthropic/anthropic-output-maxima.test.ts — 3/3.
  • Red/green proof: with the map defined but not wired into the entries, both provider cases fail (every model resolves 64000); wiring it in turns them green. The map-shape case is independent of the wiring.
  • bun test tests/providers tests/routing tests/server/input-admission.test.ts — 162 failures before and after this change, identical set. Those are pre-existing on dev at 26acb4076 and unrelated; they pass in isolation and appear to be shared-state contention under parallel execution.
  • bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts — 18/18. The new file sits under tests/adapters/anthropic/, which the existing regex seed already resolves, so layout.json and test-layout-expected.json are untouched.

Full-suite validation was not run locally; the focused regression set above plus typecheck is what I exercised, and the change is a data-only addition to two registry entries. Remaining coverage is left to CI.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No user-facing doc change: this corrects an internal capability constant to match the vendor's published limit.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (No auth, credential, workflow or dependency surface touched; the diff is two registry fields and a test.)

🤖 Generated with Claude Code

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Improvements
    • Anthropic models can now use output limits of up to 128,000 tokens where supported. Haiku 4.5 retains a 64,000-token limit.
    • These model-specific limits apply to both Anthropic sign-in options, while each option retains its existing default output-token limit.

Both Anthropic registry entries declared only `defaultMaxOutputTokens` 64000 and
no per-model map, so every Claude model resolved a 64000 output ceiling. Anthropic
documents 128K synchronous max output for all of them except Haiku 4.5, so the
figure was understating the real ceiling by half on nine models.

That number is not display metadata. `resolveOutputCeiling` is what the adapter
budgets against when a caller declares no `max_tokens`, so a 128K-capable model
stopped at 64000 with `stop_reason: max_tokens` and the caller had no way to reach
the rest. The same value feeds the combo admission reserve in
`checkComboTargetInputAdmission`, where understating a target's output makes its
headroom arithmetic wrong in the other direction.

ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS carries the per-model maxima and both the OAuth
and API-key entries consume it. Each value was read from that model's own overview
page on platform.claude.com (/docs/en/models/<slug>/overview), which states it in
the header line and again in the Capabilities table: Fable 5.1, Fable 5, Sonnet
5.5, Sonnet 5, Opus 5.5, Opus 5, Opus 4.8, Opus 4.7, Opus 4.6 and Sonnet 4.6 are
all 128K. Deliberately not the 300K Message Batches extended-output beta, which
needs `output-300k-2026-03-24` and does not apply to the synchronous route these
providers use.

Haiku 4.5 is genuinely 64K and is left out of the map on purpose so it keeps
inheriting the default, and the default stays 64000 as the floor for any model id
the map does not name.

Verification: the new test asserts the map covers exactly the seeded models minus
Haiku 4.5, and that both providers resolve 128000 per model (64000 for Haiku)
through `resolveModelPolicy` and through `resolveOutputCeiling`, which is the
resolver the admission path actually calls. It fails on both providers with the
map defined but not wired into the entries, and passes once it is. `bun run
typecheck` is clean. tests/providers, tests/routing and
tests/server/input-admission.test.ts report the same 162 pre-existing failures
with and without this change.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 18e7d83a-b74f-47fd-bfc8-38495c3c409c

📥 Commits

Reviewing files that changed from the base of the PR and between d5b77b8 and 646142a.

📒 Files selected for processing (2)
  • scripts/test-layout/layout.json
  • tests/fixtures/test-layout-expected.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Anthropic model metadata now defines a 64,000-token default and per-model 128,000-token ceilings, except for Haiku 4.5. Both Anthropic provider entries use this metadata, and tests verify the resolved ceilings.

Changes

Anthropic output-token ceilings

Layer / File(s) Summary
Define per-model output ceilings
src/providers/registry/model-seeds.ts
The default remains 64,000 tokens. The new map sets 128,000 tokens for each listed seeded Claude model except Haiku 4.5, which uses the default.
Wire and test provider ceilings
src/providers/registry/entries-core.ts, tests/adapters/anthropic/anthropic-output-maxima.test.ts, scripts/test-layout/layout.json, tests/fixtures/test-layout-expected.json
The Anthropic OAuth and API-key entries receive copies of the map. Tests verify coverage and resolved ceilings for both providers. The test-layout mapping and its expected fixture include the new test.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 64614

The new output ceilings are wired to both Anthropic providers and covered by resolution tests, while the test-layout entry matches its fixture. No concrete merge-blocking issue is evident.

Architecture Summary

Architecture risk: 🔵 Low · up to 64614

The change affects 3 systems.

Changed systems: src, tests, scripts

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 2 changed files map to changed impact.
  • observed — tests (service) was modified; 2 changed files map to changed impact.
  • observed — scripts (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/providers/registry/entries-core.ts: The model-seed imports now include ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS.
  • observed — Modified behavior in src/providers/registry/entries-core.ts: The Anthropic OAuth entry now supplies a copy of the per-model maximum-output-token map.
  • observed — Modified behavior in src/providers/registry/entries-core.ts: The Anthropic API-key entry now supplies a copy of the same per-model maximum-output-token map.
  • observed — Modified behavior in src/providers/registry/model-seeds.ts: The default output ceiling remains 64,000 tokens. The removed comment described relying on Anthropic’s server-side per-model caps and said the larger default only avoided an 8,192-token truncation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: assigning the documented 128K output maximum to Claude models in the Anthropic provider.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions
github-actions Bot marked this pull request as draft September 30, 2026 10:55
@github-actions
github-actions Bot marked this pull request as ready for review September 30, 2026 11:03
@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 44 / 80

이 PR은 Anthropic Claude 모델의 “한 번에 쓸 수 있는 최대 출력 토큰” 숫자를 고칩니다. 베이스는 dev입니다.

예전에는 OAuth(anthropic)와 API 키(anthropic-apikey) 둘 다 기본값만 64000이었고, 모델별 표가 없었습니다. 그래서 Haiku 4.5만 진짜 64K인데도, 나머지 Claude 모델까지 전부 64000으로 잡혔습니다. Anthropic 문서(동기 Messages)는 그 나머지들이 128K입니다.

이 숫자는 화면용 장식이 아닙니다. 호출자가 max_tokens를 안 주면 어댑터가 이 한도로 예산을 잡고, combo 입력 입장 검사(resolveOutputCeiling → checkComboTargetInputAdmission)도 같은 값을 씁니다. 한도가 반만 잡혀 있으면 긴 답이 max_tokens로 잘리고, 입장 여유 계산도 반대 방향으로 틀어집니다.

고친 뒤에는 ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS에 Fable/Sonnet/Opus 계열 10개를 128000으로 넣고, 두 레지스트리 엔트리가 그걸 읽습니다. Haiku 4.5는 표에 없어서 기본 64000을 그대로 물려받습니다. 300K Message Batches(베타 헤더 필요)는 일부러 넣지 않았습니다. 테스트는 표 모양·두 프로바이더의 resolveModelPolicy·resolveOutputCeiling을 같이 검사합니다. types/config 쪼개기로 닫을 무효·중복 PR은 이 주제와 무관합니다.

라인 - src/adapters/anthropic.ts · 레지스트리 한도는 128K로 올라가지만, 예전 thinking 경로의 REASONING_MAX_TOKENS_CEILING(32000) 클램프는 그대로입니다. thinking을 켠 일부 호출은 여전히 32K 근처에서 막힐 수 있습니다. 이번 PR이 바로 고치는 범위는 “생략된 max_tokens + admission” 쪽이 맞습니다.
라인 - 같은 파일의 adaptive thinking 생략 경로 · Math.max(omittedMaxTokens, …) 때문에, 한도가 128K가 되면 요청 max_tokens도 128000으로 커질 수 있습니다(예전 64000). 의도에 가깝지만, 긴 스트림·타임아웃·입장 여유(더 많이 비워 둠) 쪽으로 체감이 달라질 수 있습니다.
라인 - OPPER_MODEL_MAX_OUTPUT_TOKENS의 claude-sonnet-4-6은 아직 64000입니다. Opper 풀 “멤버 중 최소” 주석이면 의도일 수 있고, Anthropic 직행과 숫자가 어긋난 잔여일 수도 있습니다. 이번 PR 범위 밖입니다.

메인테이너의 판단이 필요한 지점

adaptive thinking이 켜진 기본 경로에서 max_tokens를 128K까지 올려도 되는지, 아니면 어댑터 쪽 천장(약 40K)을 따로 손볼 후속 이슈로 둘지. 또 Opper 시드의 sonnet-4-6 64K를 이번에 같이 맞출지, 풀 최소값으로 남겨둘지.

너의 추천

머지해도 좋습니다. 범위가 좁고(시드 맵 + 두 엔트리 배선 + 회귀 테스트), Haiku 제외·300K 제외 이유도 분명합니다. thinking 클램프와 Opper 숫자는 후속으로 이슈만 열어 두면 됩니다. exact-head 전체 테스트 스위트는 이 시점 체크에 안 보이니, CI 초록만 한 번 더 보면 됩니다.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md, dev-only exception) by @lidge-jun.

Thanks @vadymhimself!

lidge-jun added a commit that referenced this pull request Sep 30, 2026
…6329)

Carries #6316 unchanged plus maintainer review fixes; the contributor gate re-drafted the original after the maintainer push.

Co-authored-by: vadymhimself <11277453+vadymhimself@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Landed on through maintainer carry #6329 (with a Co-authored-by trailer for you), after the contributor readiness gate returned this PR to draft following a maintainer review commit. Thank you!

@lidge-jun lidge-jun closed this Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants