Skip to content

fix(translate): add qwen/qwen3.8-max output-token cap (32768) - #974

Open
Symbiomancer wants to merge 1 commit into
mainfrom
fix/qwen38-max-output-cap
Open

fix(translate): add qwen/qwen3.8-max output-token cap (32768)#974
Symbiomancer wants to merge 1 commit into
mainfrom
fix/qwen38-max-output-cap

Conversation

@Symbiomancer

Copy link
Copy Markdown
Contributor

Incident

Prod Claude Code session 5842e58e-0d13-4901-addd-8afb5b31965d (2026-08-20 ~22:10Z) got a 👎 with:

API Error: Claude's response exceeded the 64000 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

Router telemetry shows the client requested claude-opus-5 with max_tokens=64000; the HMM policy routed to qwen/qwen3.8-max on Fireworks (hmm_policy(... fallback to 'high'; AA Agentic Index roster arm 'qwen/qwen3.8-max' (harness='claude_code', rank=1, eligible=4/4))). Both observed turns came back truncated:

  • resp_output_tokens ≈ 2913 / 2957, upstream_finish_reason: length, resp_stop_reason: max_tokens
  • next request carried Claude Code's auto-continue prompt ("Output token limit hit. Resume directly…") — a truncate→resume loop until the client errored.

Root cause

qwen/qwen3.8-max was onboarded in #907 and promoted to high as claude_code's rank-1 arm, but has no modelMaxOutputTokens entry, so the emit layer clamps the client's 64000 → defaultMaxOutputTokenCap = 8192. Qwen3-Max thinking consumes most of that budget, leaving ~2.9k visible tokens per turn.

Fix

Add "qwen/qwen3.8-max": 32768 (Qwen3-Max family output ceiling on Fireworks' qwen3p8-max; adjust if the model card states otherwise). Same bug class as the kimi-k3 entry — regression test mirrors TestOpenAISameFormat_ExplicitMaxTokensClampsToKimiK3Ceiling and covers both the over-cap clamp (64000 → 32768) and under-cap passthrough (16384 unchanged). Verified red without the map entry, green with it; full go test ./internal/translate/ passes.

Follow-up (not in this PR)

Other rostered OSS arms still inherit the 8192 fallback: deepseek/deepseek-v4-pro (medium), deepseek/deepseek-v4-flash + minimax/minimax-m3 (low). Their real ceilings need verification before adding entries — same silent-truncation risk applies.

qwen/qwen3.8-max was onboarded to the catalog (#907) and promoted to the
high cluster as claude_code's rank-1 AA Agentic Index arm, but never got a
modelMaxOutputTokens entry. Claude Code requests max_tokens=64000, which
the emit layer then clamped to the 8192 OSS fallback; Qwen3-Max thinking
consumes most of that budget, so every agentic turn ended in
finish_reason=length and the client entered an auto-resume loop until it
surfaced 'Claude's response exceeded the 64000 output token maximum'
(prod session 5842e58e-0d13-4901-addd-8afb5b31965d, 2026-08-20 ~22:10Z,
two consecutive turns truncated at ~2.9k visible output tokens).

Qwen3-Max family serves 32k output on Fireworks (qwen3p8-max); add the
cap entry so large requests pass through instead of being truncated 4x.
Same bug class as the kimi-k3 fix; other still-absent OSS rows
(deepseek-v4-pro/flash, minimax-m3) keep the 8192 fallback until their
real ceilings are verified.
@claude

claude Bot commented Aug 20, 2026

Copy link
Copy Markdown

Claude finished @Symbiomancer's task —— View job


Posted one advisory comment-length suggestion on internal/translate/default_max_tokens_test.go lines 183–187: the 5-line regression doc-comment can be condensed to two lines without losing the essential WHY.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment on lines +183 to +187
// Claude Code turn requesting max_tokens=64000 was clamped to the 8192
// fallback. Qwen3-Max serves 32k output on Fireworks (qwen3p8-max); every
// agentic turn ended in finish_reason=length and an auto-resume loop until
// the client surfaced "response exceeded the 64000 output token maximum".
func TestOpenAISameFormat_ExplicitMaxTokensClampsToQwen38MaxCeiling(t *testing.T) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Claude Code turn requesting max_tokens=64000 was clamped to the 8192
// fallback. Qwen3-Max serves 32k output on Fireworks (qwen3p8-max); every
// agentic turn ended in finish_reason=length and an auto-resume loop until
// the client surfaced "response exceeded the 64000 output token maximum".
func TestOpenAISameFormat_ExplicitMaxTokensClampsToQwen38MaxCeiling(t *testing.T) {
// Regression: absent modelMaxOutputTokens entry clamped max_tokens=64000 to
// the 8192 fallback; every turn truncated (finish_reason=length loop).

Was 5 lines narrating the full incident; the essential WHY fits in two.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8ff3f7d. Configure here.

// Qwen3-Max family serves 32k output on Fireworks (qwen3p8-max). Without
// this entry a Claude Code max_tokens=64000 turn was clamped to the 8192
// fallback and truncated every agentic turn (finish_reason=length loop).
"qwen/qwen3.8-max": 32768,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong Qwen output-token ceiling

Medium Severity

The new qwen/qwen3.8-max entry in modelMaxOutputTokens sets the ceiling to 32768, but the Qwen3.8-Max model card (and Fireworks listings) document a 131072 output limit. Claude Code’s max_tokens=64000 requests still clamp below the real ceiling, so thinking-heavy turns can keep hitting finish_reason=length and the same truncate→resume loop this change aimed to stop.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8ff3f7d. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Reviews (1): Last reviewed commit: "fix(translate): add qwen/qwen3.8-max out..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Reviews (2): Last reviewed commit: "fix(translate): add qwen/qwen3.8-max out..." | Re-trigger Greptile

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