Repository navigation
fix(sse): adapt the Claude flow to Opus 4.7+ adaptive-thinking + fixed-sampling contract - #4230
Merged
Merged
Conversation
…ed-sampling contract
Claude Opus 4.7 and later (Opus 4.7/4.8, Fable 5) changed the Messages API contract:
manual extended thinking was removed (`thinking.type:"enabled"` or ANY `budget_tokens`
returns 400 — adaptive-only, steered by `output_config.effort`) and non-default
`temperature`/`top_p`/`top_k` now return 400 (sampling is fixed). OmniRoute still emitted
both shapes, so OpenAI-format `reasoning_effort` low/medium/high and any client-supplied
sampling param could hard-400 on the most-used provider.
- modelSpecs: new `adaptiveThinkingOnly` flag + `isAdaptiveThinkingOnly()` on opus-4-7/4-8/fable-5
- translator: `reasoning_effort` (every level) -> adaptive + `output_config.effort` for those models
- chatCore: `normalizeClaudeAdaptiveThinking` catch-all collapses residual manual thinking
(passthrough legacy shape / per-model defaults) to `{type:"adaptive"}`, keyed on the model
- registry: strip `temperature`/`top_p`/`top_k` for opus-4-7/4-8/fable-5 (claude + anthropic ids)
Pre-4.7 models (Opus 4.6/4.5, Sonnet, Haiku) keep manual budgets and sampling params.
TDD: +27 cases (adaptive-thinking-normalize, sampling-params, translator). typecheck/lint/file-size green.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jun 19, 2026
Merged
tkgo11
pushed a commit
to tkgo11/OmniRoute
that referenced
this pull request
Sep 23, 2026
…d-sampling contract (cheaper-inference#4230) * feat(sse): adapt the Claude flow to Opus 4.7+ adaptive-thinking + fixed-sampling contract Claude Opus 4.7 and later (Opus 4.7/4.8, Fable 5) changed the Messages API contract: manual extended thinking was removed (`thinking.type:"enabled"` or ANY `budget_tokens` returns 400 — adaptive-only, steered by `output_config.effort`) and non-default `temperature`/`top_p`/`top_k` now return 400 (sampling is fixed). OmniRoute still emitted both shapes, so OpenAI-format `reasoning_effort` low/medium/high and any client-supplied sampling param could hard-400 on the most-used provider. - modelSpecs: new `adaptiveThinkingOnly` flag + `isAdaptiveThinkingOnly()` on opus-4-7/4-8/fable-5 - translator: `reasoning_effort` (every level) -> adaptive + `output_config.effort` for those models - chatCore: `normalizeClaudeAdaptiveThinking` catch-all collapses residual manual thinking (passthrough legacy shape / per-model defaults) to `{type:"adaptive"}`, keyed on the model - registry: strip `temperature`/`top_p`/`top_k` for opus-4-7/4-8/fable-5 (claude + anthropic ids) Pre-4.7 models (Opus 4.6/4.5, Sonnet, Haiku) keep manual budgets and sampling params. TDD: +27 cases (adaptive-thinking-normalize, sampling-params, translator). typecheck/lint/file-size green. * docs(changelog): note Claude Opus 4.7+ adaptive-thinking + fixed-sampling fixes (cheaper-inference#4230)
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.
Why
Claude Opus 4.7 and later (Opus 4.7/4.8, Fable 5) changed the Messages API request contract — and OmniRoute (where Claude is the most-used provider) still sent the old shapes, so well-formed requests could hard-400:
thinking.type:"enabled"or anythinking.budget_tokensnow returns400. Reasoning is adaptive-only, steered byoutput_config.effort. (Migration guide, extended thinking, oh-my-openagent#4614). The OpenAI→Claude translator mappedreasoning_effortlow/medium/high to a manualthinking:{type:"enabled", budget_tokens}→ 400 on those models.temperature/top_p/top_kreturn400. The translator forwarded client-suppliedtemperature/top_punconditionally, and the Claude registry models carried nounsupportedParams.output_config.effort(low/medium/high/xhigh/max) was already correct — no change there.What
modelSpecs.ts— newadaptiveThinkingOnlyflag +isAdaptiveThinkingOnly()helper, set onclaude-opus-4-7/claude-opus-4-8/claude-fable-5(resolves dated/Bedrock aliases).openai-to-claude.ts— for adaptive-only models,reasoning_effortof every level →{type:"adaptive"}+output_config.effort(preserves the requested level), never a manual budget. Pre-4.7 models keep the budget buckets.chatCore.ts—normalizeClaudeAdaptiveThinkingcatch-all at the existing post-translation thinking-normalization chokepoint (next tonormalizeThinkingForModel/normalizeMimoThinking): collapses any residual manual thinking that reached dispatch (Claude-native passthrough legacy shape, per-model defaults) to{type:"adaptive"}, keyed on the resolved upstream model so it covers every routing mode. New pure leafopen-sse/services/claudeAdaptiveThinking.ts.claude/anthropic) —unsupportedParams: ["temperature","top_p","top_k"]on Opus 4.7+/Fable 5 ids (both dashedclaude-opus-4-8and dottedclaude-opus-4.7), stripped at the existinggetUnsupportedParamschokepoint.Scope guard: pre-4.7 models (Opus 4.6/4.5, Sonnet 4.5/4.6, Haiku 4.5) still accept manual budgets and sampling params — regression-tested.
Tests (TDD)
claude-adaptive-thinking-normalize.test.ts(11) — enabled+budget → adaptive, budget/max_tokens stripped, adaptive untouched, disabled untouched, pre-4.7 budget preserved, alias resolution, no-op identity.claude-adaptive-sampling-params.test.ts(5) — sampling strip for Opus 4.7+/Fable 5 (both id shapes) + pre-4.7 regression guard +isAdaptiveThinkingOnlyflags.translator-openai-to-claude.test.ts— new adaptive-only-by-level test + pre-4.7 budget regression; repointed the Support Claude Effort Level #627 128k-cap regression onto Opus 4.6 (still budget-based).typecheck:core✓ ·eslint✓ ·check:file-size✓ (chatCore baseline 5095→5102, justified) ·check:provider-consistency✓ ·check:env-doc-sync✓ · broad Claude/thinking cluster 118/118.🤖 Generated with Claude Code