Skip to content

feat(anthropic): support Claude Opus 4.8 effort levels and adaptive thinking#360

Merged
SantiagoDePolonia merged 3 commits into
mainfrom
feat/opus-4-8
May 29, 2026
Merged

feat(anthropic): support Claude Opus 4.8 effort levels and adaptive thinking#360
SantiagoDePolonia merged 3 commits into
mainfrom
feat/opus-4-8

Conversation

@SantiagoDePolonia
Copy link
Copy Markdown
Contributor

@SantiagoDePolonia SantiagoDePolonia commented May 28, 2026

Summary

Adds full GoModel support for Claude Opus 4.8 (and fixes the same gap for 4.7) on the OpenAI-compatible surface.

  • Adaptive thinking routing — Opus 4.8 and 4.7 only accept thinking: {type: "adaptive"}; manual budget_tokens thinking returns a 400. Added both prefixes to the adaptive-thinking set so reasoning requests route to output_config.effort instead of a rejected budget_tokens payload.
  • New effort levels — extended reasoning.effort to the full Anthropic enum low/medium/high/xhigh/max. xhigh and max (introduced with Opus 4.8) were previously downgraded to low. Legacy budget-token models map the new levels to higher thinking budgets.
  • Docs — new docs/providers/anthropic.mdx documenting the effort→thinking mapping (adaptive vs legacy), the budget-token table, and model-specific effort gating; wired into the providers overview and nav.

User-visible impact

Clients can now send "reasoning": {"effort": "xhigh"} (or max) to Opus 4.8/4.7 and have it forwarded as output_config.effort with adaptive thinking, instead of being silently weakened to low. Omitting reasoning is unchanged (Anthropic applies its server-side default of high).

Provider-specific behavior

  • Effort levels are model-gated upstream (xhigh on 4.8/4.7 only; max on 4.8/4.7/4.6/Sonnet 4.6). GoModel forwards the requested level and lets Anthropic validate, rather than encoding a capability matrix that would drift against the model registry.
  • Native-only fields (e.g. inline mid-task system entries) remain available through the /p/anthropic/messages passthrough route.

Testing

  • Added table cases: Opus 4.8 xhigh/max, Opus 4.7 adaptive routing, legacy budget mappings, and isAdaptiveThinkingModel coverage for 4.8/4.7.
  • make test-race, make lint, and mint validate pass via pre-commit hooks.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive Anthropic/Claude guide, listed Anthropic as a supported provider, and documented a native passthrough route for Claude-native requests; clarified config and temperature requirements.
    • Documented reasoning-effort mapping, new effort levels (xhigh, max), and guidance for adaptive vs legacy model behavior and fallbacks.
  • Behavior
    • Effort levels now route to adaptive thinking or legacy token budgets based on model capability, with sensible downgrades for unsupported values.
  • Tests
    • Added tests covering new effort levels and adaptive-model handling.

Review Change Stack

…hinking

Opus 4.8 and 4.7 require adaptive thinking ({type: "adaptive"}); manual
budget_tokens thinking returns a 400. Add both model prefixes to the
adaptive-thinking set so reasoning requests route correctly.

Extend reasoning effort to the full Anthropic enum (low/medium/high/xhigh/max).
Opus 4.8 introduced xhigh and max; previously these were downgraded to low.
Map the new levels to thinking budgets on legacy models.

Document the Anthropic provider's reasoning effort mapping in a new provider
page, including the adaptive-vs-legacy split and model-specific effort gating.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

This PR extends the Anthropic provider to support higher reasoning effort levels (xhigh, max) and new Claude model variants (opus 4.8, opus 4.7). It adds comprehensive documentation explaining effort mapping for adaptive-thinking versus legacy models, updates core type comments, expands model detection and normalization logic, and includes test coverage for the new configurations.

Changes

Anthropic Extended Reasoning Effort Support

Layer / File(s) Summary
Anthropic provider documentation
docs/docs.json, docs/providers/anthropic.mdx, docs/providers/overview.mdx
New dedicated Anthropic page documents API key setup, default max_tokens injection, reasoning effort mapping (adaptive vs legacy models), model-gating of higher effort levels, and temperature handling for extended thinking. Overview updated to link and describe Anthropic as a dedicated provider.
Core type documentation for reasoning effort
internal/core/types.go
Reasoning.Effort comment expanded to include xhigh and max as valid values and note provider downgrade behavior.
Anthropic model detection and effort normalization
internal/providers/anthropic/anthropic.go
Adaptive-thinking model prefixes extended to include claude-opus-4-8 and claude-opus-4-7 variants; normalizeEffort updated to accept xhigh and max with fallback to low for unsupported values.
Request translation for reasoning effort
internal/providers/anthropic/request_translation.go
applyReasoning comment clarifies adaptive-thinking vs legacy thinking; reasoningEffortToBudgetTokens function extended to map xhigh and max to higher budget token defaults.
Anthropic internal type documentation
internal/providers/anthropic/types.go
Comments clarified for anthropicThinking and anthropicOutputConfig to distinguish adaptive configuration from legacy manual thinking with budget tokens.
Test coverage for new models and effort levels
internal/providers/anthropic/anthropic_test.go
New table-driven test cases added for additional Claude model variants and reasoning-effort combinations; TestIsAdaptiveThinkingModel extended to cover opus 4.8 and 4.7 models.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 New Claude models hop in with thinking so fine,
Opus 4.8 and 4.7, reasoning sublime,
Xhigh and max effort now mapped with care,
Adaptive thoughts float through the air,
Documentation blooms—the feature's complete! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding support for Claude Opus 4.8 effort levels and adaptive thinking, which is the core objective of the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/opus-4-8

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.

❤️ Share

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

@mintlify
Copy link
Copy Markdown

mintlify Bot commented May 28, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
gomodel 🟢 Ready View Preview May 28, 2026, 10:49 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR adds fuller Anthropic reasoning-effort support for newer Claude models. It changes:

  • Adds Opus 4.8 and 4.7 to the adaptive-thinking routing list.
  • Extends Anthropic effort handling to accept xhigh and max.
  • Caps legacy-model xhigh and max requests at the existing high thinking budget.
  • Adds chat and Responses API tests for adaptive routing and legacy budget mapping.
  • Adds Anthropic provider docs and links them from the provider overview.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (2): Last reviewed commit: "test(anthropic): add legacy xhigh Respon..." | Re-trigger Greptile

Comment thread internal/providers/anthropic/request_translation.go Outdated
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/providers/anthropic.mdx`:
- Line 43: The docs line implying "Opus 4.6+, Sonnet 4.6" is misleading because
the code uses an explicit prefix list (adaptiveThinkingPrefixes) checked by
isAdaptiveThinkingModel; update the wording in the anthropic.mdx row for
Adaptive to explicitly list the concrete, supported versions (e.g., "Adaptive
(currently: Opus 4.6, 4.7, 4.8; Sonnet 4.6)" or similar) or remove the "4.6+"
shorthand so it matches the actual behavior of isAdaptiveThinkingModel.
- Around line 58-62: Update the anthropic.mdx wording to clarify that when
`reasoning.effort` is omitted GoModel does not set `thinking: {type:
"adaptive"}` (so extended thinking is not explicitly enabled), but many adaptive
models may still auto-apply adaptive thinking with a default `effort` of `high`;
rephrase the sentence that currently says "requests run without thinking" to a
conditional statement that mentions some models auto-apply adaptive thinking
when `thinking` is unset, and remove the implication that `effort`
deterministically controls total token spend—instead note that `effort` is soft
guidance for depth/likelihood and that final token usage is variable and bounded
by `max_tokens`.

In `@internal/providers/anthropic/anthropic_test.go`:
- Around line 3655-3704: Add matching ResponsesRequest test cases in
TestConvertResponsesRequestToAnthropic_ReasoningEffort to mirror the new
ChatRequest cases (e.g., "opus 4.8 - adaptive thinking with xhigh effort", "opus
4.8 - adaptive thinking with max effort", "opus 4.7 - adaptive thinking with
high effort", and the legacy mapping cases) so the /v1/responses conversion is
validated; for each case use the same model and reasoning values but set
maxOutputTokens (instead of maxTokens), and include expectedThinkType,
expectedEffort, expectedMaxTokens, expectNilTemp and expectedBudget where
applicable to match the ChatRequest tests and ensure parity across conversion
paths.
- Around line 3939-3942: Add an explicit negative test entry asserting Sonnet
4.8 does NOT accept adaptive thinking by adding entries like
{"claude-sonnet-4-8", false} (and optionally the dated variant
{"claude-sonnet-4-8-20260301", false}) to the same test cases map/array used
alongside {"claude-opus-4-8", true} / {"claude-opus-4-7", true}, and ensure the
loop/assertion that checks adaptive support uses those boolean expectations to
fail if Sonnet 4.8 is treated as adaptive.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9bd297bd-e343-494d-8e23-99acab4d9c94

📥 Commits

Reviewing files that changed from the base of the PR and between 670d47f and 17d473e.

📒 Files selected for processing (8)
  • docs/docs.json
  • docs/providers/anthropic.mdx
  • docs/providers/overview.mdx
  • internal/core/types.go
  • internal/providers/anthropic/anthropic.go
  • internal/providers/anthropic/anthropic_test.go
  • internal/providers/anthropic/request_translation.go
  • internal/providers/anthropic/types.go

Comment thread docs/providers/anthropic.mdx Outdated
Comment thread docs/providers/anthropic.mdx Outdated
Comment thread internal/providers/anthropic/anthropic_test.go
Comment thread internal/providers/anthropic/anthropic_test.go
Address PR review feedback:

- Cap the legacy (manual-thinking) budget at the "high" level (20000) for the
  xhigh/max effort levels. These are adaptive-thinking features (Opus 4.6+) that
  legacy models do not support, and inflating budget_tokens — and max_tokens
  with it — to 32000/48000 could exceed older models' output limits and 400.
- Clarify the docs: adaptive routing is an explicit allowlist (not a version
  comparison), and effort is a behavioral signal bounded by max_tokens.
- Add Responses-path test parity for the new effort levels and a negative
  TestIsAdaptiveThinkingModel case asserting a hypothetical Sonnet 4.8 is not
  treated as adaptive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
internal/providers/anthropic/anthropic_test.go (1)

3874-3913: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add missing legacy xhigh mapping case in Responses-path reasoning tests.

TestConvertResponsesRequestToAnthropic_ReasoningEffort still lacks the legacy xhigh case, so Line 3874-Line 3913 doesn’t fully mirror the chat-path mapping matrix for the same behavior change.

Suggested minimal addition
 		{
+			name:              "legacy model - xhigh effort caps at high budget",
+			model:             "claude-3-5-sonnet-20241022",
+			reasoning:         &core.Reasoning{Effort: "xhigh"},
+			maxOutputTokens:   new(25000),
+			expectedThinkType: "enabled",
+			expectedBudget:    20000,
+			expectedMaxTokens: 25000,
+			expectNilTemp:     true,
+		},
+		{
 			name:              "legacy model - max effort caps at high budget",
 			model:             "claude-3-5-sonnet-20241022",
 			reasoning:         &core.Reasoning{Effort: "max"},

As per coding guidelines, “Add or update tests for behavior changes to cover request translation … and provider-specific parameter mapping.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/providers/anthropic/anthropic_test.go` around lines 3874 - 3913, Add
a test case to TestConvertResponsesRequestToAnthropic_ReasoningEffort mirroring
the legacy model xhigh mapping: create a table entry using model
"claude-3-5-sonnet-20241022" with reasoning &core.Reasoning{Effort: "xhigh"},
maxOutputTokens new(25000), and set expectedThinkType "enabled", expectedBudget
20000, expectedMaxTokens 25000, expectNilTemp true so the Responses-path tests
match the chat-path mapping matrix.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/providers/anthropic.mdx`:
- Around line 64-69: Update the paragraph describing omission of `reasoning` to
remove the contradiction: clarify that when you omit `reasoning`, GoModel does
not set the `thinking` field (so GoModel does not explicitly enable extended
thinking), but some Claude models may still apply server-side adaptive thinking
when `thinking` is not present and default that adaptive effort to `high`;
reference the `reasoning` and `thinking` fields and the GoModel/Claude behavior
so the text states that absence means GoModel didn't request thinking, while
Claude may independently default to `high` effort.

---

Duplicate comments:
In `@internal/providers/anthropic/anthropic_test.go`:
- Around line 3874-3913: Add a test case to
TestConvertResponsesRequestToAnthropic_ReasoningEffort mirroring the legacy
model xhigh mapping: create a table entry using model
"claude-3-5-sonnet-20241022" with reasoning &core.Reasoning{Effort: "xhigh"},
maxOutputTokens new(25000), and set expectedThinkType "enabled", expectedBudget
20000, expectedMaxTokens 25000, expectNilTemp true so the Responses-path tests
match the chat-path mapping matrix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 96570971-9221-4786-9b71-1ae7fc1c077d

📥 Commits

Reviewing files that changed from the base of the PR and between 17d473e and 9107695.

📒 Files selected for processing (3)
  • docs/providers/anthropic.mdx
  • internal/providers/anthropic/anthropic_test.go
  • internal/providers/anthropic/request_translation.go

Comment thread docs/providers/anthropic.mdx Outdated
Address follow-up review feedback:

- Add the legacy "xhigh effort caps at high budget" case to the Responses-path
  reasoning test so it fully mirrors the chat-path mapping matrix.
- Reword the effort doc note to remove the apparent contradiction: effort is a
  separate control that governs overall token spend whether or not extended
  thinking is engaged, defaulting to high when unset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
docs/providers/anthropic.mdx (1)

64-70: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify omission behavior to avoid implying deterministic server-side effort application.

Line 66-Line 70 mixes two different behaviors: GoModel not setting thinking/output_config, and Anthropic’s possible server defaults. Since GoModel only applies reasoning when reasoning.effort is present, this should be phrased conditionally (e.g., some models may auto-apply adaptive thinking when thinking is unset), not as guaranteed “effort governs overall token spend whether or not thinking is engaged.”

Suggested doc tweak
-  without it those models do not engage extended thinking. Effort is a separate
-  control that governs overall token spend (text and tool calls) whether or not
-  thinking is engaged, and Anthropic defaults it to `high` when unset. It is a
+  without it GoModel does not configure thinking. Some Claude models may still
+  auto-apply adaptive thinking server-side when `thinking` is unset (with a
+  default effort of `high`). Effort is a
   behavioral signal for depth and verbosity, not a hard budget — actual usage
   varies per request and is bounded by `max_tokens`.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/providers/anthropic.mdx` around lines 64 - 70, Reword the paragraph to
separate GoModel behavior from Anthropic server defaults: state that GoModel
only sets thinking: {type: "adaptive"} when reasoning.effort is provided (i.e.,
GoModel will not enable adaptive thinking unless reasoning.effort is present),
and then add a conditional note that some Anthropic models or the Anthropic
service may apply their own default thinking/output_config or effort heuristics
when thinking is unset; keep references to reasoning.effort, thinking, effort,
adaptive, and max_tokens so readers know which controls are local (GoModel)
versus potential server-side defaults (Anthropic).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docs/providers/anthropic.mdx`:
- Around line 64-70: Reword the paragraph to separate GoModel behavior from
Anthropic server defaults: state that GoModel only sets thinking: {type:
"adaptive"} when reasoning.effort is provided (i.e., GoModel will not enable
adaptive thinking unless reasoning.effort is present), and then add a
conditional note that some Anthropic models or the Anthropic service may apply
their own default thinking/output_config or effort heuristics when thinking is
unset; keep references to reasoning.effort, thinking, effort, adaptive, and
max_tokens so readers know which controls are local (GoModel) versus potential
server-side defaults (Anthropic).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a4aae82e-f93a-4a82-b045-2ee09975e826

📥 Commits

Reviewing files that changed from the base of the PR and between 9107695 and eb01698.

📒 Files selected for processing (2)
  • docs/providers/anthropic.mdx
  • internal/providers/anthropic/anthropic_test.go

@SantiagoDePolonia SantiagoDePolonia merged commit 60dc00c into main May 29, 2026
19 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