Skip to content

fix(providers): stop zed-hosted claude-haiku-4-5 thinking from inflating max_tokens (#13364) - #13780

Merged
diegosouzapw merged 3 commits into
release/v3.8.51from
fix/13364-zed-hosted-haiku-thinking-inflates
Sep 16, 2026
Merged

diegosouzapw merged 3 commits into
release/v3.8.51from
fix/13364-zed-hosted-haiku-thinking-inflates

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

Closes #13364

Root cause (short)

zed-hosted's passthrough catalog exposes the short hyphenated Claude id
claude-haiku-4-5, but modelSpecs' registered alias for that model is the dotted
claude-haiku-4.5 — a spelling mismatch, not a missing spec. Because
PROVIDER_MODEL_ALIASES had no zed-hosted entry, resolveCanonicalProviderModel
passed the wire id through unchanged, so getCanonicalModelSpecId found neither an
exact nor an alias match. capMaxOutputTokens() then resolved null, and
fitThinkingToMaxTokens took the "no known cap" branch — adding the response
headroom directly to the requested thinking budget instead of fitting under the
real ceiling: 32000 + 131072 = 163072, which Zed's proxy rejects (model's real
output cap is 64000). The codebase already has the identical fix for the same
class of provider (kiro, in the same PROVIDER_MODEL_ALIASES table) — zed-hosted
never got the equivalent entry.

Fix

Add a zed-hosted entry to PROVIDER_MODEL_ALIASES in open-sse/services/model.ts,
mapping claude-haiku-4-5 → claude-haiku-4.5, same pattern as the existing kiro
entry. Scoped to claude-haiku-4-5 only (the model reported and reproduced) — not
guessing at Sonnet/Opus id spellings on Zed without confirming them against the live
catalog first.

This only affects capability/budget-cap lookups
(resolveCanonicalProviderModel → getStaticSpec/capMaxOutputTokens). It never
touches the wire model field sent to Zed: zed-hosted.ts passes the raw wire model
string straight into openaiToClaudeRequest(model, ...), and result.model = model
is set unconditionally from that same raw string, never rewritten by the alias table.

Regression test

tests/unit/issue-13364-zed-hosted-haiku-thinking-inflation.test.ts

Run:

DATA_DIR=$(mktemp -d) timeout 300 node --import tsx/esm --test --test-force-exit \
  tests/unit/issue-13364-zed-hosted-haiku-thinking-inflation.test.ts

Before fix (RED) — matches the reporter's live-proxy numbers exactly:

✖ zed-hosted/claude-haiku-4-5 thinking+tools must not inflate max_tokens past the real 64000 output cap
  AssertionError: max_tokens (163072) must not exceed the model's real output cap (64000) — Anthropic/Zed rejects the request otherwise

After fix (GREEN):

✔ zed-hosted/claude-haiku-4-5 thinking+tools must not inflate max_tokens past the real 64000 output cap (89.286607ms)
ℹ pass 1
ℹ fail 0

Gates run

  • npx eslint --suppressions-location config/quality/eslint-suppressions.json open-sse/services/model.ts tests/unit/issue-13364-zed-hosted-haiku-thinking-inflation.test.ts → clean, no warnings.
  • npm run check:open-sse-typecheck → clean.
  • node scripts/check/check-file-size.mjs → no new violations on touched files.
  • node scripts/check/check-complexity.mjs / node scripts/check/check-cognitive-complexity.mjs → no new violations (additive data-table change only).
  • node scripts/check/check-test-discovery.mjs → new test file discovered.
  • Existing related suites, all green:
    tests/unit/kiro-claude-sonnet-5-2267.test.ts, tests/unit/zed-provider.test.ts,
    tests/unit/zed-hosted-proxy-enums-13362.test.ts,
    tests/unit/zed-hosted-think-close-marker.test.ts,
    tests/unit/zed-hosted-models-discovery-route.test.ts,
    tests/unit/zed-hosted-loopback-port-derivation.test.ts,
    tests/unit/zed-hosted-stream-error-boundary.test.ts (this one timed out once under
    heavy machine load running alongside the other 6 files; re-run in isolation passed
    cleanly in 46s — a load-related flake, unrelated to this change, which only touches
    open-sse/services/model.ts).

Existing tests aligned

None — no existing assertion encoded the old buggy contract; this is a purely additive
lookup-table entry.

Not covered here

  • The broader effortBudgetMap.high = 131072 behavior (any reasoning_effort above
    medium maps straight to Anthropic's xhigh-tier thinking budget) affects every
    provider through this translation leg, not just zed-hosted, and is out of scope for
    this fix.
  • Sonnet/Opus ids on zed-hosted are not added here — only claude-haiku-4-5 is
    reproduced/reported. A follow-up should confirm the live Zed catalog spelling before
    adding those.

diegosouzapw and others added 3 commits September 15, 2026 15:39
…ing max_tokens (#13364)

zed-hosted's passthrough catalog exposes the short hyphenated id
"claude-haiku-4-5", but modelSpecs' registered alias is the dotted
"claude-haiku-4.5" - a spelling mismatch, not a missing spec. With no
zed-hosted entry in PROVIDER_MODEL_ALIASES, capMaxOutputTokens() resolved
no cap for this model, so fitThinkingToMaxTokens added the response
headroom directly to the requested thinking budget (32000 + 131072 =
163072) instead of fitting under the real 64000 output cap - Zed's proxy
rejects the inflated request. Same class of fix already applied for the
"kiro" provider in the same table.

Regression test: tests/unit/issue-13364-zed-hosted-haiku-thinking-inflation.test.ts

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@diegosouzapw
diegosouzapw merged commit 94220af into release/v3.8.51 Sep 16, 2026
19 of 21 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ing max_tokens (diegosouzapw#13364) (diegosouzapw#13780)

Merged in the 2026-09-16 sweep of the maintainer's own open PRs, at the owner's explicit instruction. No push was made to the PR branch: the merge took the head as the owning session left it (verified OPEN, non-draft and MERGEABLE against the release tip immediately before merging).
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.

fix(providers): zed-hosted claude-haiku-4-5 thinking inflates max_tokens to 163072

1 participant