Repository navigation
feat(anthropic): gate live model discovery on contract coverage - #113757
Conversation
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]>
|
Codex review: found issues before merge. Reviewed July 25, 2026, 12:54 PM ET / 16:54 UTC. ClawSweeper reviewWhat this changesAdds 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 readinessKeep 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 Review scores
Verification
How this fits togetherAnthropic’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]
Decision needed
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
Findings
Agent review detailsSecurityNone. PR surfaceSource +83, Tests +147, Docs +15. Total +245 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e2790760102a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
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]>
|
Resolving the ClawSweeper review (1 actionable finding, no security findings). [P1] Confirm and document the new Plugin SDK callback — done in 3e5198a. 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 Nothing else changed: the gate, its placement after the manifest exact-match early return, and all nine focused tests are untouched. |
|
Merged via squash.
|
…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]>
…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]>
…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]>
What Problem This Solves
Live Anthropic model discovery already ships (#112412 wired
/v1/modelsinto the Anthropic catalog hook), but it has no notion of whether OpenClaw can actually shape requests for what it discovers.buildOpenAICompatibleLiveModelreturns 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 inpackages/llm-core/src/model-contracts/anthropic.ts. A model those predicates do not match is shaped like a pre-4.6 model: manualthinking: {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
supportsClaudeAdaptiveThinkingalone 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.src/plugin-sdk/provider-catalog-live-runtime.ts): new optionalmodelDiscovery.acceptUnknownModelhook, threaded into the normalizer. Providers that do not opt in are unchanged.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.extensions/anthropic/live-model-contract-gate.ts): Claude-specific logic stays in the Anthropic plugin per the owner-boundary rule. It comparesthinking.types.adaptive,effort.xhigh, andeffort.maxagainstsupportsClaudeAdaptiveThinking,supportsClaudeNativeXhighEffort, andsupportsClaudeNativeMaxEffort, and fails closed when the capability tree is missing or unreadable.Pricing stays manifest-authoritative because
/v1/modelspublishes 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.
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.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.extensions/anthropicplus the live-catalog tests — 243 passed.src/plugin-sdkrun shows 3 failures (forwards durable delivery options…,returns durable no-send results…,ignores operator runner metadata…). Proof they are unrelated: they reproduce identically on cleanmainwith 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 stalenode_modulesafter pullingmain, cleared bypnpm install.$autoreview(Codexgpt-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