Skip to content

fix(anthropic): resolve thinking profile for custom Anthropic-compatible providers - #92071

Closed
fsdwen wants to merge 2 commits into
openclaw:mainfrom
fsdwen:fix/anthropic-custom-provider-thinking
Closed

fsdwen wants to merge 2 commits into
openclaw:mainfrom
fsdwen:fix/anthropic-custom-provider-thinking

Conversation

@fsdwen

@fsdwen fsdwen commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Custom provider ids (e.g. jdcloud-anthropic) that use the anthropic-messages adapter were silently clamped to thinking=off. The root cause was twofold:

  1. Routing gap: resolveBundledProviderPolicySurface only matches exact provider ids (anthropic, claude-cli). Custom ids never reach the Anthropic policy surface.
  2. Policy gap: The Anthropic policy surface resolveThinkingProfile returns null for any unrecognized provider id.

Fix

  • Core routing: resolveProviderThinkingProfile now falls back to an API-family lookup when the direct provider-id match fails (e.g. anthropic-messages → anthropic).
  • Anthropic policy API: The default branch now resolves thinking profiles from the model identity instead of returning null, matching the behavior already present in the runtime registration path.
  • Context plumbing: api field is passed through ProviderDefaultThinkingPolicyContext so the routing layer can use it as a fallback key.

Files changed

File Change
extensions/anthropic/provider-policy-api.ts Fix default branch in resolveThinkingProfile
src/plugins/provider-thinking.ts Add API-family fallback in resolveProviderThinkingProfile
src/plugins/provider-thinking.types.ts Add api field to ProviderDefaultThinkingPolicyContext
src/auto-reply/thinking.ts Pass api from catalog context to provider context
src/shared/anthropic-model-contract.ts Add missing resolveClaudeModelIdentity import

Verification

Tests

  • Anthropic extension tests: 31/31 ✅
  • thinking.ts tests: 47/47 ✅

Real behavior proof

  • Behavior addressed: Custom Anthropic-compatible providers silently dropping --thinking xhigh to off (issue Native Anthropic adapter silently drops thinking to off for custom provider ids (resolveThinkingProfile only matches exact anthropic/claude-cli) #91975).
  • Real environment tested: Local checkout of openclaw/openclaw on Linux Node 24, running pnpm dev gateway.
  • Exact steps or command run after this patch:
    # After fix: custom Anthropic-compatible provider resolves thinking correctly
    pnpm openclaw agent --model jdcloud-anthropic/Claude-Opus-4.7-hq --thinking xhigh --json --message "OK"
    Before the fix, result.meta.requestShaping.thinking was "off". After the fix it is "xhigh".
  • Evidence after fix:
    $ openclaw agent --model jdcloud-anthropic/Claude-Opus-4.7-hq --thinking xhigh --json --message OK
    {
      "result": {
        "meta": {
          "requestShaping": {
            "thinking": "xhigh"
          }
        }
      }
    }
    The API-family fallback correctly routes jdcloud-anthropic (api=anthropic-messages) to the Anthropic policy surface.
  • Observed result after fix: listThinkingLevels("jdcloud-anthropic", "Claude-Opus-4.7-hq") now returns ["off", "minimal", "low", "medium", "high", "xhigh", "adaptive", "max"]. Previously only base levels ["off", "minimal", "low", "medium", "high"] were returned and xhigh was silently clamped.
  • What was not tested: End-to-end with a real third-party Anthropic proxy endpoint (jdcloud, etc.).

Fixes #91975

🤖 Generated with Claude Code

…ble providers

Custom provider ids (e.g. jdcloud-anthropic) using the anthropic-messages
adapter were silently clamped to thinking=off. The bundled policy surface
routing only matched exact provider ids ('anthropic', 'claude-cli'), and
the default branch returned null for any other provider.

- Route custom anthropic-messages providers to the Anthropic policy surface
  by adding an API-family fallback path in resolveProviderThinkingProfile.
- Fix the default branch in the Anthropic policy surface to resolve thinking
  profiles from the model identity instead of returning null.
- Pass the api field through ProviderDefaultThinkingPolicyContext so the
  routing layer can use it as a fallback key.

Fixes openclaw#91975

Co-Authored-By: Claude Fable 5 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added extensions: anthropic size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 11, 2026
@fsdwen

fsdwen commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

👋 @steipete @frankekn — this addresses #91975 by fixing the Anthropic thinking profile resolution for custom providers using the anthropic-messages adapter.

The fix is in two layers:

  1. Routing: Custom provider IDs (e.g. jdcloud-anthropic) now reach the Anthropic policy surface via an API-family fallback (anthropic-messages → anthropic)
  2. Resolution: The policy surface resolveThinkingProfile default branch now resolves from model identity instead of returning null, matching the runtime registration behavior added in feat(anthropic): support Claude Fable 5 adaptive thinking #91882

Tests pass (31 anthropic + 47 thinking). Would appreciate your review when you have a chance!

The re-export at line 6 references resolveClaudeModelIdentity but it was
never imported. This was introduced by openclaw#91882 which added the Fable 5
adaptive thinking support and accidentally dropped the import while
narrowing the import list.

Co-Authored-By: Claude Fable 5 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 11, 2026
@clawsweeper

clawsweeper Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 11, 2026, 2:47 AM ET / 06:47 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +36. Total +36 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:

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

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 +36. Total +36 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 5 41 5 +36
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 41 5 +36

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 the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 11, 2026
@fsdwen

fsdwen commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #92053 which was merged earlier. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: anthropic proof: supplied External PR includes structured after-fix real behavior proof. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. size: XS

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)

1 participant