Skip to content

fix(thinking): apply Claude profile to anthropic-messages catalog rows - #92053

Merged
vincentkoc merged 5 commits into
openclaw:mainfrom
wangwllu:fix/thinking-profile-anthropic-api
Jun 11, 2026
Merged

vincentkoc merged 5 commits into
openclaw:mainfrom
wangwllu:fix/thinking-profile-anthropic-api

Conversation

@wangwllu

@wangwllu wangwllu commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A custom provider fronting Claude Opus over the native anthropic-messages adapter (e.g. a renamed jdcloud-anthropic) had --thinking xhigh silently clamped to off. Thinking-profile resolution matches bundled plugin policy surfaces by exact provider id, so a renamed Anthropic-compatible provider never reached the anthropic plugin's policy and xhigh/adaptive/max were dropped from the resulting profile.

auto-reply/thinking.ts already had an api === "anthropic-messages" fallback that attached the Fable-5 profile for Fable models. This generalizes that fallback to call the canonical resolveClaudeThinkingProfile(modelId, params) helper — the same one the anthropic plugin uses — so Claude Opus 4.7/4.8 on any anthropic-messages route gets the correct profile (with xhigh/adaptive/max) regardless of provider id, while Fable models keep the Fable profile.

Routing keys on the catalog row's api field, not the provider id, so no brittle id matching is introduced.

Fixes #91975

Why this fix point

resolveThinkingProfile in src/auto-reply/thinking.ts is the sole non-test caller of the dispatcher's resolveProviderThinkingProfile (verified by grep) and the chokepoint behind every agent-command clamp helper (isThinkingLevelSupported, resolveSupportedThinkingLevel, listThinkingLevels, resolveThinkingDefaultForModel, …). Generalizing the existing api === "anthropic-messages" fallback here covers exactly the same surface as a dispatcher-level fix with less blast radius, no new internals, and net 5 lines of logic.

The default-level path (no explicit --thinking) goes through the same chokepoint and reads profile.defaultLevel, so it's covered automatically.

Non-regressions

  • Non-Claude model on an anthropic-messages row → resolveClaudeThinkingProfile returns the Claude base set, which is identical to the existing BASE_THINKING_LEVELS; reasoning:false rows still collapse to off-only via the existing guard.
  • A Claude-looking id on a non-Anthropic transport (e.g. openai-completions) → context.api !== "anthropic-messages", so the fallback is undefined and behavior is unchanged.

Test plan

  • New unit tests in src/auto-reply/thinking.test.ts covering: (1) Claude Opus xhigh exposed on a custom anthropic-messages provider without a plugin profile, (2) non-Claude model on anthropic-messages does not gain xhigh, (3) Claude-looking id on an openai-completions row does not infer the Claude profile.
  • Existing regression suites pass: auto-reply/thinking.test.ts, plugin-sdk/provider-model-shared.test.ts, plugins/provider-thinking.test.ts, plugins/provider-public-artifacts.test.ts, extensions/anthropic/provider-policy-api.test.ts, plus agents/agent-command.live-model-switch.test.ts and agents/cli-runner.reliability.test.ts.
  • oxlint clean on touched files.
  • pnpm build ✓ green (130.4s).

Real behavior proof

  • Behavior or issue addressed: Custom provider jdcloud-anthropic fronting Claude Opus over the native anthropic-messages adapter silently clamped --thinking xhigh to off because the bundled anthropic plugin's policy surface is keyed by provider id. After this fix, xhigh/adaptive/max survive level resolution on any anthropic-messages catalog row whose reasoning flag is true.
  • Real environment tested: Local macOS Darwin 25.4.0 (arm64), Node v26, pnpm workspace at ~/Code/openclaw checked out at PR head 450527b. Catalog input mirrors the reporter's actual jdcloud-anthropic config from issue Native Anthropic adapter silently drops thinking to off for custom provider ids (resolveThinkingProfile only matches exact anthropic/claude-cli) #91975 (provider id jdcloud-anthropic, three Claude Opus rows on api: "anthropic-messages" with mixed reasoning flags).
  • Exact steps or command run after fix:
    cd ~/Code/openclaw
    pnpm exec tsx scripts/proof-thinking-anthropic-messages.mts
    
    The harness is committed in this PR (scripts/proof-thinking-anthropic-messages.mts) and loads the patched resolveThinkingProfile/listThinkingLevels/resolveSupportedThinkingLevel directly from src/auto-reply/thinking.ts, then probes the exact reported provider/model triple against --thinking xhigh (and max on 4.8).
  • Evidence after fix: Live terminal output captured from the run above:
    jdcloud-anthropic/Claude-Opus-4.7  reasoning=false --thinking xhigh  ->  resolved=off  supported=false
      levels: [off]
    jdcloud-anthropic/Claude-Opus-4.7-hq  reasoning=true --thinking xhigh  ->  resolved=xhigh  supported=true
      levels: [off,minimal,low,medium,adaptive,high,xhigh,max]
    jdcloud-anthropic/Claude-Opus-4.8  reasoning=true --thinking xhigh  ->  resolved=xhigh  supported=true
      levels: [off,minimal,low,medium,adaptive,high,xhigh,max]
    jdcloud-anthropic/Claude-Opus-4.8  reasoning=true --thinking max  ->  resolved=max  supported=true
      levels: [off,minimal,low,medium,adaptive,high,xhigh,max]
    
  • Observed result after fix: The exact symptom from Native Anthropic adapter silently drops thinking to off for custom provider ids (resolveThinkingProfile only matches exact anthropic/claude-cli) #91975 is fixed end-to-end on the live code path. --thinking xhigh resolves to xhigh (not off) on Claude-Opus-4.7-hq and Claude-Opus-4.8; max also resolves to max on 4.8. Claude-Opus-4.7 (reasoning: false) correctly stays off-only via the pre-existing reasoning guard, confirming the fallback didn't widen non-thinking rows. Level lists now expose [off,minimal,low,medium,adaptive,high,xhigh,max] on the thinking-capable rows, matching the bundled anthropic plugin's policy surface.
  • What was not tested: End-to-end network round-trip to a real jdcloud Anthropic-compatible endpoint with --thinking xhigh is out of scope here — that depends on the upstream API accepting the thinking payload and is independent of the OpenClaw clamp this PR fixes. The unit tests + this live proof together verify the clamp logic on the exact reporter input.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 10, 2026
@clawsweeper

clawsweeper Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 11, 2026, 1:58 AM ET / 05:58 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +8, Tests +127, Other +52. Total +187 across 5 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 418d7e1e83c5.

Label changes

Label changes:

  • remove P2: Current review triage priority is none.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 auth-provider: Current PR review selected no merge-risk labels.

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

PR surface:

Source +8, Tests +127, Other +52. Total +187 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 75 67 +8
Tests 1 127 0 +127
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 52 0 +52
Total 5 254 67 +187

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this PR with exit 1.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 10, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

Addressed the P2 in d827582791: pass { includeNativeMax: true } to resolveClaudeThinkingProfile in the anthropic-messages fallback, matching the bundled anthropic plugin (extensions/anthropic/provider-policy-api.ts:38,45). Added a regression test on claude-sonnet-4-6 that exercises the adaptive-default branch and asserts max is exposed — verified by toggling the option off, which makes the new test fail with expected [...] to include 'max', then restoring the fix to make it pass.

Native-xhigh families (Opus 4.7/4.8) were unaffected; this only restores parity for adaptive families on custom anthropic-messages providers.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 10, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

Follow-up self-review note on b2ff752207:

While re-reading the change, I realized the generalized fallback has a subtle behavior change worth documenting: a non-Claude model on the anthropic-messages transport, with compat.supportedReasoningEfforts: ["xhigh"] in its catalog row, used to receive xhigh via catalogSupportsXHigh (thinking.ts:236). After this PR it stays on the Claude base set, because the anthropicMessagesProfile falls back is now satisfied for every anthropic-messages row.

I think this is the correct behavior — anthropic-messages is a Claude-family protocol; xhigh on it is a Claude capability, not a generic transport feature. But it was previously implicit and easy to undo. So this commit just adds an inline comment at the resolver site and a regression test that locks the suppression. No code-path change beyond the comment and test.

If you'd rather treat this differently (e.g. preserve the compat-based upgrade for non-Claude rows on this transport, or gate the fallback strictly on Claude id detection), happy to follow up — but I think the current behavior is consistent with the bundled anthropic plugin's stance.

@gregs535

Copy link
Copy Markdown

Review: Approve with notes (pending write access)

LGTM. Clean targeted fix that generalizes the existing anthropic-messages fallback to call resolveClaudeThinkingProfile() for Claude models on any anthropic-messages route.

Key points verified:

  • Non-Claude models on anthropic-messages don't gain xhigh (correct)
  • Claude-looking IDs on non-Anthropic transports unchanged
  • Test coverage covers the three critical cases
  • Build passes, oxlint clean
  • Integration check confirms jdcloud-anthropic/Claude-Opus-4.7 now exposes xhigh correctly

Note: This competes with #92040 (more general approach). Recommend merging this targeted fix first, then evaluating #92040 separately for broader API-family policy routing.

@wangwllu
wangwllu force-pushed the fix/thinking-profile-anthropic-api branch from b2ff752 to 24bf002 Compare June 11, 2026 02:00
@openclaw-barnacle openclaw-barnacle Bot added size: M scripts Repository scripts proof: supplied External PR includes structured after-fix real behavior proof. and removed size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 11, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

P2 (includeNativeMax: true) 已在d827582修复,新加了adaptive/max regression test。Real behavior proof也补齐了 (proof: suppliedlabel已切换),head 现在是450527b。能否重新审一下,确认P2 resolved + proof OK?

@clawsweeper

clawsweeper Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

03:34 那次 re-review queue 已 >4h 仍未出 verdict(原 review comment updated_at 仍是 2026-06-10T23:26:01Z),head 仍是 450527b。再 poke 一次。如果 bot 端有 backlog 阻塞欢迎告知。

@clawsweeper

clawsweeper Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 11, 2026
wanglu241 added 4 commits June 11, 2026 19:15
Address ClawSweeper P2 review on openclaw#92053. The anthropic-messages fallback
in `resolveThinkingProfile` calls `resolveClaudeThinkingProfile` but
omits the `{ includeNativeMax: true }` option that the bundled anthropic
plugin uses (extensions/anthropic/provider-policy-api.ts:38,45).

For native-xhigh Claude families (Opus 4.7/4.8) this had no effect since
the native-xhigh branch already exposes `max`. But adaptive Claude
families that take the adaptive-default branch (e.g. claude-sonnet-4-6,
claude-opus-4-6) silently lost `max` parity on custom anthropic-messages
providers compared to native Anthropic policy.

Also add a regression test on `claude-sonnet-4-6` that verifies the
adaptive-branch path keeps `max` for custom providers.
…messages

Self-review surfaced a subtle behavior change worth documenting: when the
anthropic-messages fallback was generalized, non-Claude models on this
transport stop honoring catalog `compat.supportedReasoningEfforts: ["xhigh"]`
because they take the Claude base profile instead of falling through to the
later `catalogSupportsXHigh` upgrade path.

This is intentional — anthropic-messages does not carry a generic xhigh
contract; xhigh on this protocol is a Claude-family capability. Add an
inline comment at the resolver site and a regression test that locks the
suppression so the next reader (or a future patch) doesn't accidentally
restore the upgrade path.
The previous commits added a `resolveClaudeThinkingProfile` import from
`auto-reply/thinking.ts` to `plugin-sdk/provider-model-shared.ts`. The
shared barrel re-exports `provider-replay-helpers` and `plugins/types`,
which transitively reach back into `auto-reply` via the gateway server
methods chain — creating the madge cycle reported by
`check:madge-import-cycles`:

    auto-reply/thinking.ts
      -> ... -> plugin-sdk/provider-model-shared.ts
      -> plugins/{config-schema, host-hooks, ...} -> plugins/types.ts

Move `BASE_CLAUDE_THINKING_LEVELS`, `isClaudeAdaptiveThinkingDefaultModelId`,
and `resolveClaudeThinkingProfile` to a new leaf module
`src/plugins/provider-claude-thinking.ts` whose only imports are
`@openclaw/llm-core` and the existing leaf `provider-thinking.types`.

`provider-model-shared.ts` continues to re-export both helpers so existing
consumers (`extensions/anthropic/*`, the public test surface) are
unaffected. `auto-reply/thinking.ts` now imports the leaf directly,
breaking the cycle.
@vincentkoc
vincentkoc force-pushed the fix/thinking-profile-anthropic-api branch from 450527b to 31cdca3 Compare June 11, 2026 10:24
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer verification complete.

  • Confirmed the canonical Claude thinking profile is selected for catalog rows using anthropic-messages, regardless of custom provider id.
  • Provider-specific profiles retain precedence; non-Claude and non-Anthropic routes remain unchanged.
  • Focused proof: node scripts/run-vitest.mjs src/auto-reply/thinking.test.ts — 52 passed.
  • Fresh autoreview: clean; no accepted/actionable findings.

Best-fix judgment: landable. Routing by the catalog API contract is the correct owner boundary.

@vincentkoc
vincentkoc merged commit 43b4e27 into openclaw:main Jun 11, 2026
156 of 157 checks passed
@wangwllu

Copy link
Copy Markdown
Contributor Author

Thanks @vincentkoc for the manual verification and merge — appreciated, especially given the ClawSweeper Codex backend had been failing on this item all afternoon. And thanks @gregs535 for the early review.

@wangwllu
wangwllu deleted the fix/thinking-profile-anthropic-api branch June 12, 2026 01:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 12, 2026
openclaw#92053)

* fix(thinking): apply Claude profile to anthropic-messages catalog rows

When a custom provider (e.g. `jdcloud-anthropic`) fronted Claude Opus over
the native anthropic-messages adapter, `--thinking xhigh` was silently
clamped to `off`. The thinking-profile dispatcher resolves bundled plugin
policy surfaces by exact provider id, so a renamed Anthropic-compatible
provider never reached the anthropic plugin's policy and `xhigh` was not
in the resulting profile.

`auto-reply/thinking.ts` already had a fallback keyed on
`context.api === "anthropic-messages"` that attached
`CLAUDE_FABLE_5_THINKING_PROFILE` for Fable models. Generalize it to use
`resolveClaudeThinkingProfile(modelId, params)` instead — the same
canonical helper the anthropic plugin uses — which still returns the Fable
profile for Fable models and now returns the correct Opus 4.7/4.8 profile
(with `xhigh`/`adaptive`/`max`) for Claude Opus regardless of provider id.

Non-Claude models on anthropic-messages routes still get the base
profile, and a Claude id on a non-Anthropic transport (e.g. an
openai-completions catalog row) is unaffected.

Fixes openclaw#91975

* fix(thinking): match native Anthropic includeNativeMax in fallback

Address ClawSweeper P2 review on openclaw#92053. The anthropic-messages fallback
in `resolveThinkingProfile` calls `resolveClaudeThinkingProfile` but
omits the `{ includeNativeMax: true }` option that the bundled anthropic
plugin uses (extensions/anthropic/provider-policy-api.ts:38,45).

For native-xhigh Claude families (Opus 4.7/4.8) this had no effect since
the native-xhigh branch already exposes `max`. But adaptive Claude
families that take the adaptive-default branch (e.g. claude-sonnet-4-6,
claude-opus-4-6) silently lost `max` parity on custom anthropic-messages
providers compared to native Anthropic policy.

Also add a regression test on `claude-sonnet-4-6` that verifies the
adaptive-branch path keeps `max` for custom providers.

* docs(thinking): document deliberate compat.xhigh bypass on anthropic-messages

Self-review surfaced a subtle behavior change worth documenting: when the
anthropic-messages fallback was generalized, non-Claude models on this
transport stop honoring catalog `compat.supportedReasoningEfforts: ["xhigh"]`
because they take the Claude base profile instead of falling through to the
later `catalogSupportsXHigh` upgrade path.

This is intentional — anthropic-messages does not carry a generic xhigh
contract; xhigh on this protocol is a Claude-family capability. Add an
inline comment at the resolver site and a regression test that locks the
suppression so the next reader (or a future patch) doesn't accidentally
restore the upgrade path.

* fix(thinking): extract Claude profile to leaf to break import cycle

The previous commits added a `resolveClaudeThinkingProfile` import from
`auto-reply/thinking.ts` to `plugin-sdk/provider-model-shared.ts`. The
shared barrel re-exports `provider-replay-helpers` and `plugins/types`,
which transitively reach back into `auto-reply` via the gateway server
methods chain — creating the madge cycle reported by
`check:madge-import-cycles`:

    auto-reply/thinking.ts
      -> ... -> plugin-sdk/provider-model-shared.ts
      -> plugins/{config-schema, host-hooks, ...} -> plugins/types.ts

Move `BASE_CLAUDE_THINKING_LEVELS`, `isClaudeAdaptiveThinkingDefaultModelId`,
and `resolveClaudeThinkingProfile` to a new leaf module
`src/plugins/provider-claude-thinking.ts` whose only imports are
`@openclaw/llm-core` and the existing leaf `provider-thinking.types`.

`provider-model-shared.ts` continues to re-export both helpers so existing
consumers (`extensions/anthropic/*`, the public test surface) are
unaffected. `auto-reply/thinking.ts` now imports the leaf directly,
breaking the cycle.

* test(thinking): add live proof harness for openclaw#91975 anthropic-messages clamp

---------

Co-authored-by: wanglu241 <[email protected]>
wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Jun 17, 2026
openclaw#92053)

* fix(thinking): apply Claude profile to anthropic-messages catalog rows

When a custom provider (e.g. `jdcloud-anthropic`) fronted Claude Opus over
the native anthropic-messages adapter, `--thinking xhigh` was silently
clamped to `off`. The thinking-profile dispatcher resolves bundled plugin
policy surfaces by exact provider id, so a renamed Anthropic-compatible
provider never reached the anthropic plugin's policy and `xhigh` was not
in the resulting profile.

`auto-reply/thinking.ts` already had a fallback keyed on
`context.api === "anthropic-messages"` that attached
`CLAUDE_FABLE_5_THINKING_PROFILE` for Fable models. Generalize it to use
`resolveClaudeThinkingProfile(modelId, params)` instead — the same
canonical helper the anthropic plugin uses — which still returns the Fable
profile for Fable models and now returns the correct Opus 4.7/4.8 profile
(with `xhigh`/`adaptive`/`max`) for Claude Opus regardless of provider id.

Non-Claude models on anthropic-messages routes still get the base
profile, and a Claude id on a non-Anthropic transport (e.g. an
openai-completions catalog row) is unaffected.

Fixes openclaw#91975

* fix(thinking): match native Anthropic includeNativeMax in fallback

Address ClawSweeper P2 review on openclaw#92053. The anthropic-messages fallback
in `resolveThinkingProfile` calls `resolveClaudeThinkingProfile` but
omits the `{ includeNativeMax: true }` option that the bundled anthropic
plugin uses (extensions/anthropic/provider-policy-api.ts:38,45).

For native-xhigh Claude families (Opus 4.7/4.8) this had no effect since
the native-xhigh branch already exposes `max`. But adaptive Claude
families that take the adaptive-default branch (e.g. claude-sonnet-4-6,
claude-opus-4-6) silently lost `max` parity on custom anthropic-messages
providers compared to native Anthropic policy.

Also add a regression test on `claude-sonnet-4-6` that verifies the
adaptive-branch path keeps `max` for custom providers.

* docs(thinking): document deliberate compat.xhigh bypass on anthropic-messages

Self-review surfaced a subtle behavior change worth documenting: when the
anthropic-messages fallback was generalized, non-Claude models on this
transport stop honoring catalog `compat.supportedReasoningEfforts: ["xhigh"]`
because they take the Claude base profile instead of falling through to the
later `catalogSupportsXHigh` upgrade path.

This is intentional — anthropic-messages does not carry a generic xhigh
contract; xhigh on this protocol is a Claude-family capability. Add an
inline comment at the resolver site and a regression test that locks the
suppression so the next reader (or a future patch) doesn't accidentally
restore the upgrade path.

* fix(thinking): extract Claude profile to leaf to break import cycle

The previous commits added a `resolveClaudeThinkingProfile` import from
`auto-reply/thinking.ts` to `plugin-sdk/provider-model-shared.ts`. The
shared barrel re-exports `provider-replay-helpers` and `plugins/types`,
which transitively reach back into `auto-reply` via the gateway server
methods chain — creating the madge cycle reported by
`check:madge-import-cycles`:

    auto-reply/thinking.ts
      -> ... -> plugin-sdk/provider-model-shared.ts
      -> plugins/{config-schema, host-hooks, ...} -> plugins/types.ts

Move `BASE_CLAUDE_THINKING_LEVELS`, `isClaudeAdaptiveThinkingDefaultModelId`,
and `resolveClaudeThinkingProfile` to a new leaf module
`src/plugins/provider-claude-thinking.ts` whose only imports are
`@openclaw/llm-core` and the existing leaf `provider-thinking.types`.

`provider-model-shared.ts` continues to re-export both helpers so existing
consumers (`extensions/anthropic/*`, the public test surface) are
unaffected. `auto-reply/thinking.ts` now imports the leaf directly,
breaking the cycle.

* test(thinking): add live proof harness for openclaw#91975 anthropic-messages clamp

---------

Co-authored-by: wanglu241 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native Anthropic adapter silently drops thinking to off for custom provider ids (resolveThinkingProfile only matches exact anthropic/claude-cli)

3 participants