Skip to content

Map Anthropic reasoning effort by provider#1338

Merged
willccbb merged 3 commits into
mainfrom
fix/anthropic-reasoning-effort
May 12, 2026
Merged

Map Anthropic reasoning effort by provider#1338
willccbb merged 3 commits into
mainfrom
fix/anthropic-reasoning-effort

Conversation

@xeophon
Copy link
Copy Markdown
Member

@xeophon xeophon commented May 11, 2026

Summary

  • Map sampling_args.reasoning_effort to extra_body.verbosity for Anthropic models on OpenRouter/Prime OpenAI-compatible routes.
  • Map reasoning_effort to native Anthropic output_config.effort and enable adaptive thinking for Claude 4.6/4.7 when unset.
  • Add focused client tests for Claude 4.6/4.7 OpenRouter-style and native Anthropic mappings.

Verification


Note

Medium Risk
Touches request parameter normalization for both Anthropic and OpenAI chat clients, which can change model behavior and cost/latency characteristics across providers. Risk is mitigated by being gated to reasoning_effort presence and specific Claude/OpenRouter-style routes.

Overview
Adds provider-specific translation of sampling_args.reasoning_effort in both clients.

For native Anthropic messages, it now maps reasoning_effort to output_config.effort and auto-enables thinking={"type":"adaptive"} for select Claude 4.6/4.7 models when thinking isn’t already set.

For OpenAI-compatible chat completions routed to Anthropic via OpenRouter/Pinference, it maps reasoning_effort into extra_body.verbosity (and ensures extra_body.reasoning.enabled) while leaving other models/providers to use the standard reasoning_effort field.

Reviewed by Cursor Bugbot for commit a4c1fc7. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4c1fc71bb

ℹ️ 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".

Comment on lines +267 to +269
reasoning_effort is not None
and model_id.startswith("claude-")
and is_anthropic_route
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict verbosity mapping to Claude 4.6/4.7

When this client targets OpenRouter/Pinference with Claude models that still use budget-based reasoning (for example Claude 3.7/4.5), this broad model_id.startswith("claude-") branch moves reasoning_effort into verbosity and only sends reasoning.enabled, so a requested high/xhigh reasoning effort becomes OpenRouter’s default reasoning instead. OpenRouter’s Claude 4.6 migration docs distinguish verbosity from reasoning.effort and say older models continue to use reasoning.effort, so this should be gated to the 4.6/4.7 adaptive-thinking model IDs rather than every Claude model.

Useful? React with 👍 / 👎.

@willccbb willccbb merged commit 0968ea9 into main May 12, 2026
8 checks passed
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