Repository navigation
fix(anthropic): apply the live sampling and tool-choice contract to every Claude family - #6217
Conversation
…very Claude family A live probe of api.anthropic.com on 2026-09-29 showed the Sonnet 5.5 rules from #6210 were narrower than the upstream contract: - Opus 4.7+, Sonnet 5+ and every Fable return 400 on any non-default temperature/top_p, with or without thinking. The adapter only dropped them when it sent thinking, so a no-reasoning request with temperature failed. - Haiku 4.5, Sonnet 4.5/4.6 and Opus 4.5/4.6 take either field alone but 400 when both are sent; top_p is now dropped when both are present. - Fable 5.1 rejects forced tool_choice like Opus 5.5; it now degrades to auto. - Opus 5.5 and Fable reject both thinking disabled and between_tools, so the web-search and vision sidecars send a low effort and no thinking field for them (verified to end_turn with text inside a 1,024-token budget). Plan, audit and evidence: devlog/_plan/260929_dev_next_hardening_carry/.
|
✅ Deterministic PR hygiene checks passed. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70c8c3f695
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if (body.temperature !== undefined && body.top_p !== undefined && rejectsCombinedSampling(parsed.modelId)) { | ||
| // The 4.5/4.6 families take either field alone but 400 on both; temperature is the one kept. | ||
| delete body.top_p; |
There was a problem hiding this comment.
Preserve the non-default sampler when resolving conflicts
When a 4.5/4.6-family request explicitly carries the default temperature: 1 together with a non-default top_p (for example, 0.9), this branch always deletes top_p, silently discarding the caller's only effective sampling adjustment. Since these models accept either field alone, omit temperature when it is the default and preserve top_p; conversely, keep the current behavior when top_p is the default or both values are non-default.
Useful? React with 👍 / 👎.
Summary
A live probe of api.anthropic.com (2026-09-29, one field per request) showed the Claude request rules added with Sonnet 5.5 in #6210 were narrower than what Anthropic enforces. Requests the adapter builds today fail with 400 on current models:
temperature/top_pwith no reasoningtemperature+top_ptogethertop_pdropped → 200required/ namedany→ 400auto→ 200 (same downgrade as Opus 5.5 / Sonnet 5.5)thinking: disabled→ 400output_config.effort: low, nothinking→ 200Both off switches (
disabledandbetween_tools) are rejected by Opus 5.5 and Fable; with a low effort they still ended their turn with visible text inside the vision sidecar's 1,024-token budget. The rules stay insrc/adapters/anthropic-model-contract.ts. Older ids that were not measured (claude-3-7-sonnet,claude-opus-4-20250514) keep both sampling fields.Not changed, and why: the Messages-native passthrough keeps forwarding caller fields (its contract,
structure/data-planes/protocol-paths.md); dotted Bedrock ids still do not parse, but no direct Bedrock adapter reachesanthropic.ts. Plan, audit and evidence:devlog/_plan/260929_dev_next_hardening_carry/.Verification
bun teston the contract, reasoning, tool-choice, passthrough, web-search, vision, file-size ratchet and test-layout files: 152 pass / 0 fail. Every file intests/adapters/anthropic,tests/web-search,tests/visionand the two Claude Messages endpoint files passes when run on its own.bun run typecheck,bun run structure:check,bun run privacy:scan: pass.Checklist