Skip to content

fix(sse): adapt the Claude flow to Opus 4.7+ adaptive-thinking + fixed-sampling contract - #4230

Merged
diegosouzapw merged 2 commits into
release/v3.8.29from
feat/claude-opus-adaptive-params
Jun 19, 2026
Merged

diegosouzapw merged 2 commits into
release/v3.8.29from
feat/claude-opus-adaptive-params

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

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:

  1. Manual extended thinking is gone. thinking.type:"enabled" or any thinking.budget_tokens now returns 400. Reasoning is adaptive-only, steered by output_config.effort. (Migration guide, extended thinking, oh-my-openagent#4614). The OpenAI→Claude translator mapped reasoning_effort low/medium/high to a manual thinking:{type:"enabled", budget_tokens} → 400 on those models.
  2. Sampling params are fixed. Non-default temperature/top_p/top_k return 400. The translator forwarded client-supplied temperature/top_p unconditionally, and the Claude registry models carried no unsupportedParams.

output_config.effort (low/medium/high/xhigh/max) was already correct — no change there.

What

  • modelSpecs.ts — new adaptiveThinkingOnly flag + isAdaptiveThinkingOnly() helper, set on claude-opus-4-7/claude-opus-4-8/claude-fable-5 (resolves dated/Bedrock aliases).
  • openai-to-claude.ts — for adaptive-only models, reasoning_effort of 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 — normalizeClaudeAdaptiveThinking catch-all at the existing post-translation thinking-normalization chokepoint (next to normalizeThinkingForModel/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 leaf open-sse/services/claudeAdaptiveThinking.ts.
  • registry (claude/anthropic) — unsupportedParams: ["temperature","top_p","top_k"] on Opus 4.7+/Fable 5 ids (both dashed claude-opus-4-8 and dotted claude-opus-4.7), stripped at the existing getUnsupportedParams chokepoint.

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 + isAdaptiveThinkingOnly flags.
  • 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

…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.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@diegosouzapw
diegosouzapw merged commit a044246 into release/v3.8.29 Jun 19, 2026
4 checks passed
@diegosouzapw
diegosouzapw deleted the feat/claude-opus-adaptive-params branch June 19, 2026 12:06
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)
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