Skip to content

feat(anthropic): gate live model discovery on contract coverage - #113757

Merged
fuller-stack-dev merged 2 commits into
mainfrom
feat/anthropic-live-model-discovery
Jul 25, 2026
Merged

fuller-stack-dev merged 2 commits into
mainfrom
feat/anthropic-live-model-discovery

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

What Problem This Solves

Live Anthropic model discovery already ships (#112412 wired /v1/models into the Anthropic catalog hook), but it has no notion of whether OpenClaw can actually shape requests for what it discovers.

buildOpenAICompatibleLiveModel returns the manifest entry for an id the catalog already publishes, and otherwise clones a template model for the discovered id. So a Claude model generation OpenClaw has never seen becomes selectable immediately, with borrowed metadata — while request shaping is chosen by version-pinned predicates in packages/llm-core/src/model-contracts/anthropic.ts. A model those predicates do not match is shaped like a pre-4.6 model: manual thinking: {type: "enabled", budget_tokens: N} plus caller sampling parameters. Every current Claude model rejects both with a 400.

The net effect is the failure mode the Opus 5 rollout demonstrated by hand, but automatic: the model appears in the picker on release day and every request fails. That is strictly worse than not offering it.

This is stage 1 of #113411, taking the safest option from that issue's open question — gate discovered models on contract coverage — so discovery is shippable before capability-driven contracts exist.

Why This Change Was Made

The gate is a consistency check between Anthropic's advertised capabilities and the contracts we would apply, not a hand-maintained family allowlist.

An allowlist was rejected because it cannot distinguish the two cases that matter: an unknown new model and a known legacy model both fail every modern predicate. Gating on supportsClaudeAdaptiveThinking alone would wrongly drop Haiku 4.5 while still admitting a hypothetical Opus 6. Comparing advertised capability against predicted contract separates them exactly — a model we would mis-shape is precisely a model where the two disagree — and it needs no list to maintain.

  • Shared seam (src/plugin-sdk/provider-catalog-live-runtime.ts): new optional modelDiscovery.acceptUnknownModel hook, threaded into the normalizer. Providers that do not opt in are unchanged.
  • Gate placement (provider-catalog-live-normalize.internal.ts): applied only after the manifest-exact-match early return, so ids the catalog publishes bypass it entirely and keep their published metadata and pricing.
  • Provider policy (extensions/anthropic/live-model-contract-gate.ts): Claude-specific logic stays in the Anthropic plugin per the owner-boundary rule. It compares thinking.types.adaptive, effort.xhigh, and effort.max against supportsClaudeAdaptiveThinking, supportsClaudeNativeXhighEffort, and supportsClaudeNativeMaxEffort, and fails closed when the capability tree is missing or unreadable.

Pricing stays manifest-authoritative because /v1/models publishes none, and discovery remains advisory: no API key or an unreachable endpoint falls back to the shipped catalog unchanged.

User Impact

Newly published snapshots of already-supported Claude families keep appearing automatically. A brand-new model generation now stays hidden until OpenClaw's contracts are updated, instead of appearing and failing every request. No behavior change for any model the shipped catalog already describes, and none for other providers, which do not set the hook.

Evidence

Regression risk here is "does the gate drop something it shouldn't", so the tests target that directly.

  • Gate policy (extensions/anthropic/live-model-contract-gate.test.ts, 5 tests): current models with matching capabilities are accepted (claude-opus-5, claude-sonnet-5, claude-fable-5, claude-opus-4-8); legacy models are accepted (claude-haiku-4-5, claude-sonnet-4-5, claude-3-opus-20240229) — the case a naive allowlist breaks; unrecognized generations are rejected (claude-opus-6, claude-sonnet-6, claude-zephyr-1); a known model whose advertised capabilities drift is rejected; and a missing/unreadable capability tree fails closed.
  • Seam behavior (src/plugin-sdk/provider-catalog-live-normalize.gate.test.ts, 4 tests): with no gate, discovery is byte-identical to today; with a rejecting gate, only the unknown id is dropped and the manifest entry is returned verbatim; the gate is never consulted for manifest-published ids; an accepting gate admits unknown ids.
  • Suites green after the change: extensions/anthropic plus the live-catalog tests — 243 passed.
  • Pre-existing failures identified, not caused here. A full src/plugin-sdk run shows 3 failures (forwards durable delivery options…, returns durable no-send results…, ignores operator runner metadata…). Proof they are unrelated: they reproduce identically on clean main with these source changes stashed, one times out at 133s, neither file references any changed module, and both pass in isolation with the change applied. Separately, an initial run failed ~125 files with "./durability" is not exported from @openclaw/fs-safe — that was stale node_modules after pulling main, cleared by pnpm install.
  • $autoreview (Codex gpt-5.6-sol, high): clean — no accepted/actionable findings; "patch is correct (0.99)".

Advances #113411 (stage 1). Stage 2, capability-driven contracts that would let a new generation work on day one rather than merely be hidden safely, remains open there.

🤖 Generated with Claude Code

Live catalog discovery cloned a template for any newly discovered Claude id, so
a future model generation would be selectable while request shaping treated it
as pre-4.6 and 400d. Add an opt-in acceptUnknownModel gate to the shared live
catalog seam and have the Anthropic plugin accept a discovered model only when
Anthropic's advertised capabilities agree with the contracts we would apply.
Manifest-published ids bypass the gate and keep their metadata.

Co-Authored-By: Claude Fable 5 <[email protected]>
@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review July 25, 2026 16:50
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: anthropic size: M maintainer Maintainer-authored PR labels Jul 25, 2026
@clawsweeper clawsweeper Bot added 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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 25, 2026, 12:54 PM ET / 16:54 UTC.

ClawSweeper review

What this changes

Adds an Anthropic-specific gate that hides newly discovered Claude model IDs unless their advertised capabilities match OpenClaw’s current request-shaping contracts, plus an optional live-catalog callback used to apply that gate.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open for maintainer review. It is a focused mitigation for a credible Anthropic live-discovery failure mode, but it also adds a provider-facing Plugin SDK callback while the linked product-direction issue still leaves the stage-1 policy choice open.

Priority: P2
Reviewed head: 907625ce3c4ce218e5a16eef78a27b4b5d4ed551
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and focused tests are coherent, but the new public extension contract needs an explicit maintainer decision and SDK documentation before it is merge-ready.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor real-behavior-proof gate; the included focused tests are useful supplemental evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor real-behavior-proof gate; the included focused tests are useful supplemental evidence.
Evidence reviewed 4 items New Plugin SDK decision surface: The PR adds modelDiscovery.acceptUnknownModel, an optional callback on the shared live-catalog options. This is a new provider-facing contract rather than Anthropic-only implementation detail.
Linked policy decision remains open: The PR explicitly advances the first stage of #113411, whose stated open question is whether unsupported discovered models should be hidden, capability-shaped, or surfaced as degraded. That issue is still open and marked for maintainer/product review.
Existing live discovery provenance: The related merged PR #112412 introduced the shared live-catalog path; this PR extends that established surface rather than duplicating discovery.
Findings 1 actionable finding [P1] Confirm and document the new Plugin SDK callback
Security None None.

How this fits together

Anthropic’s provider plugin refreshes its model catalog from the vendor API and passes discovered rows through the shared Plugin SDK normalizer. The normalizer preserves manifest-known models and turns accepted unknown rows into selectable catalog entries that later feed request shaping.

flowchart LR
  A[Anthropic Models API] --> B[Live catalog discovery]
  B --> C{Model in shipped manifest?}
  C -->|Yes| D[Published metadata and pricing]
  C -->|No| E[Anthropic contract gate]
  E -->|Capabilities match| F[Selectable discovered model]
  E -->|Mismatch or unreadable| G[Keep static catalog only]
Loading

Decision needed

Question Recommendation
Should OpenClaw support a documented provider-level acceptUnknownModel admission hook as the stage-1 solution for Anthropic discovery, or defer this policy surface until capability-driven contracts are defined? Approve the narrow stage-1 hook: Accept the hidden-until-supported policy, document the callback’s supported semantics and fallback behavior, and retain the focused compatibility tests.

Why: The branch is mechanically narrow, but it creates a Plugin SDK contract and selects one of the alternatives still explicitly open in the canonical product discussion.

Before merge

  • Confirm and document the new Plugin SDK callback (P1) - acceptUnknownModel expands the shared provider discovery contract, but the linked canonical discussion still leaves this policy choice open and this PR updates only Anthropic user docs. Obtain explicit maintainer direction and document the supported callback semantics, including its failure and manifest-bypass behavior, before exposing it to provider plugins.
  • Resolve merge risk (P1) - Merging would establish an undocumented public Plugin SDK callback for provider-specific admission policy before maintainers choose and document the durable stage-1/stage-2 contract boundary.
  • Complete next step (P2) - A maintainer must choose the permanent provider-discovery policy and Plugin SDK contract before an automated repair or merge path is appropriate.

Findings

  • [P1] Confirm and document the new Plugin SDK callback — src/plugin-sdk/provider-catalog-live-runtime.ts:102
Agent review details

Security

None.

PR surface

Source +83, Tests +147, Docs +15. Total +245 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 86 3 +83
Tests 2 147 0 +147
Docs 2 15 0 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 248 3 +245

Review metrics

Metric Value Why it matters
Plugin SDK discovery surface 1 optional callback added The new callback changes the supported extension contract for every provider that uses the shared live-model discovery options.

Stored data model

Persistent data-model change detected: vector/embedding metadata: docs/providers/anthropic.md. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #113411
Summary: This PR is a candidate implementation of the stage-1 mitigation discussed in the canonical Anthropic catalog direction issue; the earlier live-discovery PR is the already-merged prerequisite.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Confirm and document the Plugin SDK boundary (recommended)
    Before merge, record maintainer approval for the stage-1 hiding policy and document the callback’s provider-facing compatibility contract.
  2. Pause for the capability-driven design
    Defer this branch if maintainers want newly discovered models to use capability-derived shaping rather than a new admission hook.

Technical review

Best possible solution:

Resolve the policy question in #113411, then either approve and document this narrow provider admission hook as supported SDK behavior or defer the hook until capability-driven request contracts are designed.

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

Yes, from source: an unknown live-discovered Anthropic ID reaches template-based catalog construction while request shaping remains version-predicate based. The PR’s focused tests exercise the intended admission and rejection paths, though no independent live Anthropic API run was available in this read-only review.

Is this the best way to solve the issue?

Unclear. Hiding models whose known contract predicates disagree with advertised capabilities is a conservative implementation, but the linked canonical issue still requires maintainers to choose whether that new Plugin SDK policy surface is preferable to capability-driven shaping.

Full review comments:

  • [P1] Confirm and document the new Plugin SDK callback — src/plugin-sdk/provider-catalog-live-runtime.ts:102
    acceptUnknownModel expands the shared provider discovery contract, but the linked canonical discussion still leaves this policy choice open and this PR updates only Anthropic user docs. Obtain explicit maintainer direction and document the supported callback semantics, including its failure and manifest-bypass behavior, before exposing it to provider plugins.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The change addresses a bounded provider-catalog reliability problem affecting newly discovered Anthropic models, without evidence of a current broad outage.
  • add merge-risk: 🚨 compatibility: The PR adds a new provider-facing Plugin SDK callback whose permanent support and documentation boundary require maintainer confirmation.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This member-authored PR is exempt from the external-contributor real-behavior-proof gate; the included focused tests are useful supplemental evidence.

Label justifications:

  • P2: The change addresses a bounded provider-catalog reliability problem affecting newly discovered Anthropic models, without evidence of a current broad outage.
  • merge-risk: 🚨 compatibility: The PR adds a new provider-facing Plugin SDK callback whose permanent support and documentation boundary require maintainer confirmation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This member-authored PR is exempt from the external-contributor real-behavior-proof gate; the included focused tests are useful supplemental evidence.

Evidence

What I checked:

Likely related people:

  • fuller-stack-dev: Authored the previously merged live provider catalog work and this follow-up, tying them to both the shared catalog seam and the Anthropic policy layer. (role: introduced related live-discovery behavior; confidence: high; commits: 55cf9523e015, 907625ce3c4c; files: src/plugin-sdk/provider-catalog-live-runtime.ts, src/plugin-sdk/provider-catalog-live-normalize.internal.ts, extensions/anthropic/register.runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

Record acceptUnknownModel in the provider-plugin SDK reference: when to use
it, that manifest-published ids bypass it, and the fail-closed guidance.

Co-Authored-By: Claude Fable 5 <[email protected]>
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Resolving the ClawSweeper review (1 actionable finding, no security findings).

[P1] Confirm and document the new Plugin SDK callback — done in 3e5198a. docs/plugins/sdk-provider-plugins.md now documents acceptUnknownModel alongside the other live-discovery options, covering exactly the semantics called out: when a provider should set it, that it is consulted only for ids the static catalog does not publish (known ids bypass it and keep published metadata), that returning false drops the row, that providers omitting it are unchanged, and the guidance to compare vendor-advertised capabilities against the provider's own contract checks rather than a hand-maintained list, failing closed when a row carries no capability data.

Decision needed — already made, and it matches ClawSweeper's recommendation. The maintainer direction on #113411's open question was to take the safest option that is shippable before capability-driven contracts exist: hide discovered models we cannot yet shape. That is the "Approve the narrow stage-1 hook" path. Worth being explicit that this PR does not close #113411 — stage 2 (capability-driven contracts, which would let a new generation actually work on day one rather than only be hidden safely) stays open there.

One clarification on the finding's framing: this PR does not choose between "hidden / capability-shaped / degraded" for all providers. The shared seam only gains an optional hook and keeps its current behavior for every provider that omits it; the hidden-until-supported policy is Anthropic-local, in extensions/anthropic/live-model-contract-gate.ts, per the extensions owner-boundary rule. A future provider is free to make the opposite call.

Nothing else changed: the gate, its placement after the manifest exact-match early return, and all nine focused tests are untouched.

@fuller-stack-dev
fuller-stack-dev merged commit 8028a3a into main Jul 25, 2026
115 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the feat/anthropic-live-model-discovery branch July 25, 2026 17:28
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 26, 2026
…claw#113757)

* feat(anthropic): gate live model discovery on contract coverage

Live catalog discovery cloned a template for any newly discovered Claude id, so
a future model generation would be selectable while request shaping treated it
as pre-4.6 and 400d. Add an opt-in acceptUnknownModel gate to the shared live
catalog seam and have the Anthropic plugin accept a discovered model only when
Anthropic's advertised capabilities agree with the contracts we would apply.
Manifest-published ids bypass the gate and keep their metadata.

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs(plugins): document the live-discovery admission hook

Record acceptUnknownModel in the provider-plugin SDK reference: when to use
it, that manifest-published ids bypass it, and the fail-closed guidance.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
obviyus added a commit that referenced this pull request Oct 9, 2026
…law release (#167658)

## What Problem This Solves

Fixes: new Claude models that an Anthropic API key already lists stay hidden from the model picker until an OpenClaw release, and a typed-in unknown ID can be sent a request shape the model rejects.

## User Impact

User impact: Anthropic API-key users see newly listed Claude models as soon as `/v1/models` returns them, and the first turn uses the thinking type and effort levels Anthropic advertises for that model. Shipped rows Anthropic does not list, configured rows, and catalogs saved before discovery runs keep today's model-ID rules.

## Why This Change Was Made

Request shaping keyed only on model-ID rules, so #113757 hid any unknown model whose advertised capabilities disagreed with them. This change makes shaping follow the listing:

- The Anthropic plugin owns its `/v1/models` projection through the existing `modelDiscovery.projectRows` hook. It runs the shared default projection first, so a listed ID that the manifest does not ship still inherits `compat` (including Code Mode) and `thinkingLevelMap` from the closest shipped model, exactly as before. It then adds the advertised flags to each listed row as `params.claudeCapabilities` (`adaptiveThinking`, `xhighEffort`, `maxEffort`, and `disabledThinking` when listed) and sets `thinkingLevelMap.xhigh`/`max` to match.
- The shared Claude predicates `supportsClaudeAdaptiveThinking`, `supportsClaudeNativeXhighEffort`, `supportsClaudeNativeMaxEffort`, and `requiresClaudeMandatoryAdaptiveThinking` read a listed flag first and use the ID rule only when that flag is missing. Sonnet 5.5's between-tools off mode is preserved. `supportsClaude1MContext` still uses ID rules only.
- The Claude thinking profile reads row params, so the picker offers the levels a listed model advertises.
- The agreement gate is deleted. An unknown row with no readable capability data stays hidden.

No schema changes. One export is added to the private-local `plugin-sdk/provider-catalog-live-runtime` subpath: `buildOpenAICompatibleLiveModels`, the existing default projection, so the Anthropic projection composes with it instead of copying its template inheritance. `params` is the existing free-form model-params field; `params.canonicalModelId` is the precedent. The Anthropic provider docs now name the key. `compat.supportedReasoningEfforts` was not used because Copilot's `anthropic-messages` Claude rows already set it without any adaptive marker, so the shared predicates would misread those rows.

The public SDK option `acceptUnknownModel` is unchanged. The Anthropic plugin no longer sets it, and instead passes the same kind of gate (listed capabilities present) straight to the shared projection. Bedrock, Vertex, Copilot, Foundry, OpenRouter, and Claude CLI rows never carry `params.claudeCapabilities`, so they behave as before.

## Evidence

- Regression tests, each failing on `origin/main` code and passing here:
  - `packages/llm-core/src/model-contracts/anthropic.test.ts`: listed flags override ID rules one flag at a time.
  - `packages/ai/src/anthropic-listed-capabilities-transport-parity.test.ts`: provider and transport builders send adaptive + `xhigh` for an unknown listed model, budget thinking when adaptive is withheld, and keep thinking on when disabled thinking is rejected.
  - `extensions/anthropic/live-discovery-auth.test.ts`: an unknown listed model appears with its capabilities; a row without capabilities stays hidden; a listed ID the manifest does not ship (`claude-sonnet-4-6`) keeps the shipped Sonnet row's `compat.codeMode: "preferred"` while its effort map follows the listing (this case fails on `80606329c81`).
  - `extensions/anthropic/provider-policy-api.test.ts`: the effort ladder follows listed capabilities.
- Real `pnpm openclaw` Gateway turns in an isolated profile. Traffic to `api.anthropic.com` went through a loopback forward proxy (`proxy.proxyUrl` plus a proof CA) into a fake API that lists `claude-sonnet-5` (known), `claude-sonnet-9` (unknown, adaptive + xhigh + max), and `claude-haiku-9` (unknown, no adaptive, no effort):
  - `origin/main`: neither unknown ID is listed. A typed `claude-haiku-9` is sent `thinking: adaptive` with `effort` `high`/`low`, which this model rejects. `claude-sonnet-9 --thinking xhigh` is refused with "not supported".
  - This branch: both unknown IDs are listed. `claude-sonnet-9` gets adaptive thinking with effort `high`/`xhigh`/`max` and thinking `disabled` by default. `claude-haiku-9` gets `thinking: enabled` with `budget_tokens` 16384/8192 plus the interleaved-thinking beta. `claude-sonnet-5` is unchanged.
- Real Anthropic API key, isolated `--profile` Gateways, the same loopback forward proxy now forwarding each request unchanged to the real `api.anthropic.com` and recording the outgoing `/v1/messages` shape and the real status. The baseline is this PR's merge base `447144510b8`; the branch is `80606329c81`.
  - `/v1/models` lists 14 Claude IDs, and every row has a capability tree. The picker (`models list --provider anthropic --all --refresh --plain`, with and without a Gateway) shows the same 16 rows on both builds: the 14 listed IDs plus the shipped `claude-mythos-5` and `claude-haiku-4-5`. The real listing has no ID that the baseline hides.
  - Request parity covered all 14 listed models at `default`, `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, `adaptive`, and `ultra`. Sonnet and Haiku models got real turns at `default`/`off`/`low`/`high`/`xhigh`/`max`. Opus and Fable models got one real turn each at `default` on each build. All other cells were captured with a proxy stub, so the request was recorded but not sent. The `anthropic-beta` header, `thinking` (type, budget, display, block binding), `output_config.effort`, `max_tokens`, `context_management`, `service_tier`, sampling fields, and top-level keys are identical for every model and level. Both builds reject the same levels (for example `off` on `claude-opus-5-5`/`claude-fable-5`/`claude-fable-5-1`, `xhigh` on `claude-sonnet-4-6`/`claude-opus-4-6`). All 80 real requests returned 200.
  - **Regression found on `80606329c81`, fixed in `2022ebb00d5`:** the five listed IDs the manifest does not ship (`claude-sonnet-4-6`, `claude-sonnet-4-5-20250929`, `claude-opus-4-7`, `claude-opus-4-6`, `claude-opus-4-5-20251101`) were sent `[tool_call, tool_describe, tool_search]` instead of the baseline's Code Mode tools `[exec, wait]`. The baseline's default projection copies `compat` and `thinkingLevelMap` from the shipped model with the longest shared ID prefix; `projectAnthropicLiveModels` had built those rows from scratch. It now runs that default projection and only adds the listed flags.
  - Rerun on `2022ebb00d5` (same real key, same proxy, compared with the frozen baseline captures): 46 requests across those five models at every level the baseline accepts, plus `claude-haiku-4-5-20251001` and `claude-sonnet-5` at `default`. Real turns: `claude-sonnet-4-6`, `claude-opus-4-6`, and `claude-sonnet-5` (unchanged control) at `default`, all 200. Everything else used the proxy stub. Every request equals its baseline capture on every recorded field: `anthropic-beta`, `thinking`, `output_config`, `max_tokens`, `context_management`, sampling fields, top-level keys, message/system counts, and the tool list hash. The five models now send `[exec, wait]`, and Haiku 4.5 still sends `[tool_call, tool_describe, tool_search]` on both builds. The branch still refuses the same levels as the baseline (`xhigh` on `claude-sonnet-4-6`/`claude-opus-4-6`; `xhigh`/`max`/`adaptive` on `claude-sonnet-4-5-20250929`/`claude-opus-4-5-20251101`).
  - Unknown-model path: the real listing has no hidden ID, so a throwaway local build of `80606329c81` masked the ID rules for `claude-opus-4-7`. With the mask, the request came only from the advertised capabilities: thinking `disabled` by default and adaptive thinking with `xhigh`/`max` effort, the same as the unmasked branch. Real turns at `default`, `xhigh`, and `max` returned 200. This simulation was not repeated on `2022ebb00d5`. The fix changes only what an unknown row inherits from its template (`compat`, thinking-map entries other than `xhigh`/`max`, and input). The listed flags that shape the request are set the same way.
  - Known gap, not fixed here: masking `claude-sonnet-5`, which the manifest ships, sent the advertised adaptive thinking but made the CLI refuse `xhigh`/`max`. The CLI level check (`src/agents/command/model-selection.ts`, via `prepareCommandModelCatalog`) reads the manifest catalog row, and `needsThinkHydration` skips the live, provider-scoped catalog whenever that row already declares `reasoning`. So listed capabilities never reach the ladder for a shipped ID. Fixing this means changing the shared thinking-catalog hydration policy, which is used by several callers (`model-selection.ts`, `run-embedded-attempt.ts`, `agent-runner-run-params.ts`) and every provider. That is out of scope here. Today the ID rules for every shipped model match their listing, so nothing is visible.
- `node scripts/check-changed.mjs` on `2022ebb00d5`: typecheck, boundary, Plugin SDK export/surface, format, and ratchet lanes pass. The dead-export scan fails only on pre-existing unused exports in files this PR does not touch (`src/config/sessions/session-accessor.sqlite-entry-cache-publication.ts`, `src/infra/heartbeat-events-filter.ts`). With `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1` the run exits 0. `oxlint --type-aware` is clean on the changed files.

## Merge danger

- For known models that Anthropic lists, the listed capabilities now override the ID rules. Request shapes change only if Anthropic's listing disagrees with the curated rules.
- An unknown listed model inherits `compat` (including Code Mode), `thinkingLevelMap`, and input modalities from the shipped model with the longest shared ID prefix, as the shared projection already did before this PR. It gets zero pricing and ID-rule image sizing until OpenClaw ships its entry. Listed `xhigh`/`max` flags override the inherited thinking map.
- For a shipped ID, the CLI/agent thinking-level check still uses the manifest row's ID rules, not the listed capabilities (see the known gap in Evidence).
- The behavior depends on Anthropic's capability fields staying as documented. Real-key proof shows that today's listing matches the ID rules for every listed model.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…law release (openclaw#167658)

## What Problem This Solves

Fixes: new Claude models that an Anthropic API key already lists stay hidden from the model picker until an OpenClaw release, and a typed-in unknown ID can be sent a request shape the model rejects.

## User Impact

User impact: Anthropic API-key users see newly listed Claude models as soon as `/v1/models` returns them, and the first turn uses the thinking type and effort levels Anthropic advertises for that model. Shipped rows Anthropic does not list, configured rows, and catalogs saved before discovery runs keep today's model-ID rules.

## Why This Change Was Made

Request shaping keyed only on model-ID rules, so openclaw#113757 hid any unknown model whose advertised capabilities disagreed with them. This change makes shaping follow the listing:

- The Anthropic plugin owns its `/v1/models` projection through the existing `modelDiscovery.projectRows` hook. It runs the shared default projection first, so a listed ID that the manifest does not ship still inherits `compat` (including Code Mode) and `thinkingLevelMap` from the closest shipped model, exactly as before. It then adds the advertised flags to each listed row as `params.claudeCapabilities` (`adaptiveThinking`, `xhighEffort`, `maxEffort`, and `disabledThinking` when listed) and sets `thinkingLevelMap.xhigh`/`max` to match.
- The shared Claude predicates `supportsClaudeAdaptiveThinking`, `supportsClaudeNativeXhighEffort`, `supportsClaudeNativeMaxEffort`, and `requiresClaudeMandatoryAdaptiveThinking` read a listed flag first and use the ID rule only when that flag is missing. Sonnet 5.5's between-tools off mode is preserved. `supportsClaude1MContext` still uses ID rules only.
- The Claude thinking profile reads row params, so the picker offers the levels a listed model advertises.
- The agreement gate is deleted. An unknown row with no readable capability data stays hidden.

No schema changes. One export is added to the private-local `plugin-sdk/provider-catalog-live-runtime` subpath: `buildOpenAICompatibleLiveModels`, the existing default projection, so the Anthropic projection composes with it instead of copying its template inheritance. `params` is the existing free-form model-params field; `params.canonicalModelId` is the precedent. The Anthropic provider docs now name the key. `compat.supportedReasoningEfforts` was not used because Copilot's `anthropic-messages` Claude rows already set it without any adaptive marker, so the shared predicates would misread those rows.

The public SDK option `acceptUnknownModel` is unchanged. The Anthropic plugin no longer sets it, and instead passes the same kind of gate (listed capabilities present) straight to the shared projection. Bedrock, Vertex, Copilot, Foundry, OpenRouter, and Claude CLI rows never carry `params.claudeCapabilities`, so they behave as before.

## Evidence

- Regression tests, each failing on `origin/main` code and passing here:
  - `packages/llm-core/src/model-contracts/anthropic.test.ts`: listed flags override ID rules one flag at a time.
  - `packages/ai/src/anthropic-listed-capabilities-transport-parity.test.ts`: provider and transport builders send adaptive + `xhigh` for an unknown listed model, budget thinking when adaptive is withheld, and keep thinking on when disabled thinking is rejected.
  - `extensions/anthropic/live-discovery-auth.test.ts`: an unknown listed model appears with its capabilities; a row without capabilities stays hidden; a listed ID the manifest does not ship (`claude-sonnet-4-6`) keeps the shipped Sonnet row's `compat.codeMode: "preferred"` while its effort map follows the listing (this case fails on `80606329c81`).
  - `extensions/anthropic/provider-policy-api.test.ts`: the effort ladder follows listed capabilities.
- Real `pnpm openclaw` Gateway turns in an isolated profile. Traffic to `api.anthropic.com` went through a loopback forward proxy (`proxy.proxyUrl` plus a proof CA) into a fake API that lists `claude-sonnet-5` (known), `claude-sonnet-9` (unknown, adaptive + xhigh + max), and `claude-haiku-9` (unknown, no adaptive, no effort):
  - `origin/main`: neither unknown ID is listed. A typed `claude-haiku-9` is sent `thinking: adaptive` with `effort` `high`/`low`, which this model rejects. `claude-sonnet-9 --thinking xhigh` is refused with "not supported".
  - This branch: both unknown IDs are listed. `claude-sonnet-9` gets adaptive thinking with effort `high`/`xhigh`/`max` and thinking `disabled` by default. `claude-haiku-9` gets `thinking: enabled` with `budget_tokens` 16384/8192 plus the interleaved-thinking beta. `claude-sonnet-5` is unchanged.
- Real Anthropic API key, isolated `--profile` Gateways, the same loopback forward proxy now forwarding each request unchanged to the real `api.anthropic.com` and recording the outgoing `/v1/messages` shape and the real status. The baseline is this PR's merge base `1612ead394c`; the branch is `80606329c81`.
  - `/v1/models` lists 14 Claude IDs, and every row has a capability tree. The picker (`models list --provider anthropic --all --refresh --plain`, with and without a Gateway) shows the same 16 rows on both builds: the 14 listed IDs plus the shipped `claude-mythos-5` and `claude-haiku-4-5`. The real listing has no ID that the baseline hides.
  - Request parity covered all 14 listed models at `default`, `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, `adaptive`, and `ultra`. Sonnet and Haiku models got real turns at `default`/`off`/`low`/`high`/`xhigh`/`max`. Opus and Fable models got one real turn each at `default` on each build. All other cells were captured with a proxy stub, so the request was recorded but not sent. The `anthropic-beta` header, `thinking` (type, budget, display, block binding), `output_config.effort`, `max_tokens`, `context_management`, `service_tier`, sampling fields, and top-level keys are identical for every model and level. Both builds reject the same levels (for example `off` on `claude-opus-5-5`/`claude-fable-5`/`claude-fable-5-1`, `xhigh` on `claude-sonnet-4-6`/`claude-opus-4-6`). All 80 real requests returned 200.
  - **Regression found on `80606329c81`, fixed in `2022ebb00d5`:** the five listed IDs the manifest does not ship (`claude-sonnet-4-6`, `claude-sonnet-4-5-20250929`, `claude-opus-4-7`, `claude-opus-4-6`, `claude-opus-4-5-20251101`) were sent `[tool_call, tool_describe, tool_search]` instead of the baseline's Code Mode tools `[exec, wait]`. The baseline's default projection copies `compat` and `thinkingLevelMap` from the shipped model with the longest shared ID prefix; `projectAnthropicLiveModels` had built those rows from scratch. It now runs that default projection and only adds the listed flags.
  - Rerun on `2022ebb00d5` (same real key, same proxy, compared with the frozen baseline captures): 46 requests across those five models at every level the baseline accepts, plus `claude-haiku-4-5-20251001` and `claude-sonnet-5` at `default`. Real turns: `claude-sonnet-4-6`, `claude-opus-4-6`, and `claude-sonnet-5` (unchanged control) at `default`, all 200. Everything else used the proxy stub. Every request equals its baseline capture on every recorded field: `anthropic-beta`, `thinking`, `output_config`, `max_tokens`, `context_management`, sampling fields, top-level keys, message/system counts, and the tool list hash. The five models now send `[exec, wait]`, and Haiku 4.5 still sends `[tool_call, tool_describe, tool_search]` on both builds. The branch still refuses the same levels as the baseline (`xhigh` on `claude-sonnet-4-6`/`claude-opus-4-6`; `xhigh`/`max`/`adaptive` on `claude-sonnet-4-5-20250929`/`claude-opus-4-5-20251101`).
  - Unknown-model path: the real listing has no hidden ID, so a throwaway local build of `80606329c81` masked the ID rules for `claude-opus-4-7`. With the mask, the request came only from the advertised capabilities: thinking `disabled` by default and adaptive thinking with `xhigh`/`max` effort, the same as the unmasked branch. Real turns at `default`, `xhigh`, and `max` returned 200. This simulation was not repeated on `2022ebb00d5`. The fix changes only what an unknown row inherits from its template (`compat`, thinking-map entries other than `xhigh`/`max`, and input). The listed flags that shape the request are set the same way.
  - Known gap, not fixed here: masking `claude-sonnet-5`, which the manifest ships, sent the advertised adaptive thinking but made the CLI refuse `xhigh`/`max`. The CLI level check (`src/agents/command/model-selection.ts`, via `prepareCommandModelCatalog`) reads the manifest catalog row, and `needsThinkHydration` skips the live, provider-scoped catalog whenever that row already declares `reasoning`. So listed capabilities never reach the ladder for a shipped ID. Fixing this means changing the shared thinking-catalog hydration policy, which is used by several callers (`model-selection.ts`, `run-embedded-attempt.ts`, `agent-runner-run-params.ts`) and every provider. That is out of scope here. Today the ID rules for every shipped model match their listing, so nothing is visible.
- `node scripts/check-changed.mjs` on `2022ebb00d5`: typecheck, boundary, Plugin SDK export/surface, format, and ratchet lanes pass. The dead-export scan fails only on pre-existing unused exports in files this PR does not touch (`src/config/sessions/session-accessor.sqlite-entry-cache-publication.ts`, `src/infra/heartbeat-events-filter.ts`). With `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1` the run exits 0. `oxlint --type-aware` is clean on the changed files.

## Merge danger

- For known models that Anthropic lists, the listed capabilities now override the ID rules. Request shapes change only if Anthropic's listing disagrees with the curated rules.
- An unknown listed model inherits `compat` (including Code Mode), `thinkingLevelMap`, and input modalities from the shipped model with the longest shared ID prefix, as the shared projection already did before this PR. It gets zero pricing and ID-rule image sizing until OpenClaw ships its entry. Listed `xhigh`/`max` flags override the inherited thinking map.
- For a shipped ID, the CLI/agent thinking-level check still uses the manifest row's ID rules, not the listed capabilities (see the known gap in Evidence).
- The behavior depends on Anthropic's capability fields staying as documented. Real-key proof shows that today's listing matches the ID rules for every listed model.

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

Labels

docs Improvements or additions to documentation extensions: anthropic maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant