Skip to content

fix(anthropic): use adaptive thinking for Claude 5 models - #2100

Open
dkoryto wants to merge 1 commit into
stacklok:mainfrom
dkoryto:fix/anthropic-claude-5-adaptive-thinking
Open

dkoryto wants to merge 1 commit into
stacklok:mainfrom
dkoryto:fix/anthropic-claude-5-adaptive-thinking

Conversation

@dkoryto

@dkoryto dkoryto commented Oct 5, 2026 •

Copy link
Copy Markdown

Summary

Sessions on Claude 5 models (for example claude-opus-5-5) routed through the anthropic provider showed no reasoning.

The adapter picks the extended-thinking request format from the prefix list in adaptiveThinkingPrefixes (provider/anthropic/request.go). That list stopped at Opus 4.8. Claude 5 models didn't match it, so they fell back to the older budget_tokens format, which these models reject.

Change

  • Add the claude-opus-5, claude-sonnet-5, and claude-fable-5 family prefixes to the adaptive list. One family prefix covers every 5.x release and dated snapshot, so a new point release won't need another update.
  • I left out a speculative claude-mythos-5 prefix because no such model is in the curated catalog.
  • Extend TestThinkingConfigModelAware to cover Claude 5 models.
  • Update the doc comments that list the adaptive families.

The live capability lookup still takes precedence. This change only fixes the offline fallback that every other Anthropic-protocol provider entry relies on.

Verification

  • go test ./ in provider/anthropic. The new cases failed before the fix and pass after it.
  • golangci-lint (pinned v2.13.1, repository config) on provider/anthropic: 0 issues.
  • Offline end-to-end check: the real provider sent requests to a local fake Messages endpoint. On main, claude-opus-5-5, claude-sonnet-5-5, and claude-fable-5-1 sent thinking: {type: "enabled", budget_tokens: 4095}. With this change they send thinking: {type: "adaptive"}, and the streamed reasoning reaches the provider output. claude-opus-4-8 was unchanged in both runs.
  • Live check against the Anthropic API: one request to claude-opus-5-5 with a short reasoning prompt, sent through the provider.
Version thinking sent Result
main {type: "enabled", budget_tokens: ...} 400 invalid_request_error: "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.
this branch {type: "adaptive"} Reasoning streamed (118 characters), correct answer returned

This answers the open question in the issue. Before this change, the request failed with an API error. It wasn't a successful response with the reasoning missing.

Repository gates (local, macOS 26.6.2 arm64)

  • GOOS=linux task lint: 0 issues in every module. Plain task lint on macOS reports 3 staticcheck findings in internal/executionexecutor and cmd/mecatl-executor. They already exist on main and are unrelated to this change; filed as task lint fails on macOS: staticcheck SA4023 in execution executor non-Linux stub #2101.
  • task test:race: provider/anthropic and every package that imports it pass. The suite still fails locally in 10 packages outside this change (microVM, executionexecutor, internal/app, internal/adapter/server, cmd/mecated, cmd/mecatui, deploy/mecatl-execution-kind). I reran all 21 failing tests on a clean main worktree:
    • 17 fail the same way on main. These are macOS environment issues, for example /dev/fd socket paths, macOS x509 verification, and Linux-only executor paths.
    • The other 4 pass when run alone on this branch. They failed only under full-suite load (cmd/mecatui/agenthook, cmd/mecatui/customization, environment/microvm/guestexec, internal/adapter/microvmmanager).
    • None of these failures comes from this change. CI on Linux is the authoritative run.
  • go run ./cmd/mecademo: shows the tool call, permission ask and approval, and result.

Possible follow-ups (not in this PR)

  • The API error mentions output_config.effort. Check whether the adaptive path sends the configured reasoning effort.
  • A test that checks every Anthropic model in the curated catalog resolves to a thinking format the model accepts. This would catch future drift.
  • Whether unknown models should default to adaptive instead of the budget format.

Fixes #2084

The Anthropic adapter picks the extended-thinking request format from a
list of model-name prefixes. That list stopped at Opus 4.8, so Claude 5
models (for example claude-opus-5-5) fell back to the older
token-budget format. These models reject that format, so sessions on
them showed no reasoning.

Add the Opus 5, Sonnet 5, and Fable 5 family prefixes to the adaptive
list. A family prefix covers every 5.x release and dated snapshot, so a
new point release does not need another list update. Extend the
thinking-config test to cover these models and update the doc comments
that list the adaptive families.

Fixes stacklok#2084
@dkoryto
dkoryto marked this pull request as ready for review October 5, 2026 11:55
@jbeda

jbeda commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for this! Looks like there are some CI issues with this PR. I'm investigating this right now and I may take your PR or just steal things from it and give you credit.

@jbeda

jbeda commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

#2084 is tracking this.

jbeda added a commit that referenced this pull request Oct 6, 2026
…espace

Credit community PR #2100 for the bare Opus/Sonnet/Fable 5 prefix slice; extend it to Mythos 5, exact anthropic/ IDs, and sparse-discovery proofs.

Co-authored-by: Mecatl <[email protected]>

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.

No reasoning shown for Opus 5.5 on the Anthropic provider

3 participants