Skip to content

fix(translation): map OpenAI none and minimal reasoning effort for Anthropic - #1074

Open
v0ropaev wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
v0ropaev:fix/anthropic-openai-only-effort
Open

v0ropaev wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
v0ropaev:fix/anthropic-openai-only-effort

Conversation

@v0ropaev

@v0ropaev v0ropaev commented Oct 22, 2026 •

Copy link
Copy Markdown

What

The Anthropic request encoder now maps the two OpenAI-only reasoning efforts. "minimal" becomes output_config.effort = "low" with adaptive thinking. "none" becomes thinking = {"type": "disabled"} and sends no output_config.effort. Every other effort value is passed through as before.

Why

OpenAI Chat reasoning_effort and Responses reasoning.effort accept "none" and "minimal". Anthropic's output_config.effort only accepts low, medium, high, xhigh and max. AnthropicMessagesCodec::encode_request copied the effort as is, so a Chat or Responses caller routed to an anthropic_messages target got a request Anthropic rejects with a 400. For example, {"reasoning_effort": "none"} from Chat was translated to {"thinking": {"type": "adaptive"}, "output_config": {"effort": "none"}}. That turns thinking on, which is the opposite of what the caller asked for, and the effort value is invalid. "minimal" produced {"effort": "minimal"}, also invalid. Codex CLI with model_reasoning_effort = "minimal" or "none" is one way to hit it.

Mapping "none" to disabled thinking mirrors the reverse direction from #840, where Anthropic disabled thinking becomes Responses effort: "none". "low" is the closest Anthropic effort to "minimal".

Notes for reviewers

The change is in crates/switchyard-translation/src/codecs/anthropic/buffered.rs. openai_request_translates_system_developer_and_reasoning_to_anthropic in tests/request_translation.rs now also sends none and minimal and checks thinking and the effort in output_config. It fails on main and passes with the fix.

One open choice is how to handle "none". Per Anthropic's docs, Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5 and Claude Fable 5.1 reject thinking: {"type": "disabled"}, so on those models a "none" request still gets a 400. The other option is to leave out both thinking and the effort, which every model accepts but which runs those models with thinking on at their default effort. I went with disabled because it does what the caller asked on the models that support it and matches #840. Today the request fails on every model, so either option is an improvement. Happy to switch if you prefer the other one.

Tested with the pinned 1.99 toolchain.

cargo test -p switchyard-translation and clippy with -D warnings pass.
cargo fmt --all --check is clean.
cargo clippy --workspace --all-targets -- -D warnings is clean.

Summary by CodeRabbit

  • Bug Fixes
    • Improved how reasoning effort settings are translated for Anthropic requests. Setting effort to none now disables thinking without adding an effort setting; minimal maps to low, while low and high retain their corresponding effort levels.
    • Existing thinking settings are preserved rather than overwritten by defaults.

…thropic

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>
@v0ropaev
v0ropaev requested a review from a team as a code owner October 22, 2026 06:06
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA-NeMo/Switchyard/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: ae0232fe-de3d-400c-a6c0-bcb06dd8ccbf
📥 Commits

Reviewing files that changed from the base of the PR and between 34ca48e and 14b06bc.

📒 Files selected for processing: 2
  • crates/switchyard-translation/src/codecs/anthropic/buffered.rs
  • crates/switchyard-translation/tests/request_translation.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

Anthropic request encoding now maps OpenAI reasoning effort values to Anthropic thinking settings. Tests cover none, minimal, low, and high for Chat and Responses requests.

Changes

Reasoning Effort Mapping

Layer / File(s) Summary
Map reasoning effort during request encoding
crates/switchyard-translation/src/codecs/anthropic/buffered.rs, crates/switchyard-translation/tests/request_translation.rs
none maps to disabled thinking without an effort setting. Other values use adaptive thinking, and minimal maps to low. Tests check the mappings for Chat and Responses requests.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 14b06

The change appears ready to merge after normal checks; no actionable issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: mapping OpenAI none and minimal reasoning effort values for Anthropic translation.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the effort flow,
“None” turns thinking off, you know.
“Minimal” hops to “low” with care,
While “high” sets its effort there.
Chat and Responses pass the test,
Then I nibble greens and rest.

Comment @coderabbitai help to get the list of available commands.

@nachiketb-nvidia nachiketb-nvidia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one nit, otherwise, LGTM!


// OpenAI accepts "none" and "minimal" reasoning effort, which Anthropic does not.
#[test]
fn openai_reasoning_effort_maps_to_anthropic_effort() -> TestResult {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you check if there is an existing test you can extend rather than creating a new one? thank you!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, folded it into openai_request_translates_system_developer_and_reasoning_to_anthropic in 88116c7. It reuses that request and just loops over none and minimal at the end. Sorry for the delay.

…easoning test

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>

This branch has not been deployed

No deployments
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