Map Anthropic reasoning effort by provider#1338
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019e1682-ae38-76cc-bda3-d90d28b62198 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
💡 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".
| reasoning_effort is not None | ||
| and model_id.startswith("claude-") | ||
| and is_anthropic_route |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
sampling_args.reasoning_efforttoextra_body.verbosityfor Anthropic models on OpenRouter/Prime OpenAI-compatible routes.reasoning_effortto native Anthropicoutput_config.effortand enable adaptive thinking for Claude 4.6/4.7 when unset.Verification
uv run ruff check --fix verifiers/clients/openai_chat_completions_client.py verifiers/clients/anthropic_messages_client.py tests/test_client_multimodal_types.pyuv run pytest tests/test_client_multimodal_types.pyanthropic/claude-opus-4.7:reasoning_effort="high": https://app.primeintellect.ai/dashboard/evaluations/rbej739yowcedihefu7sqykkreasoning_effort="xhigh": https://app.primeintellect.ai/dashboard/evaluations/gl5n8e3cv0fcesfhjwgm1bczreasoning_effort="max": https://app.primeintellect.ai/dashboard/evaluations/ieaij5d5dpnjtcmlycby2wjgNote
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_effortpresence and specific Claude/OpenRouter-style routes.Overview
Adds provider-specific translation of
sampling_args.reasoning_effortin both clients.For native Anthropic
messages, it now mapsreasoning_efforttooutput_config.effortand auto-enablesthinking={"type":"adaptive"}for select Claude 4.6/4.7 models whenthinkingisn’t already set.For OpenAI-compatible chat completions routed to Anthropic via OpenRouter/Pinference, it maps
reasoning_effortintoextra_body.verbosity(and ensuresextra_body.reasoning.enabled) while leaving other models/providers to use the standardreasoning_effortfield.Reviewed by Cursor Bugbot for commit a4c1fc7. Bugbot is set up for automated code reviews on this repo. Configure here.