Skip to content

fix(anthropic): newly listed Claude models stay hidden until an OpenClaw release - #167658

Merged
obviyus merged 2 commits into
mainfrom
fix/anthropic-listed-capabilities
Oct 9, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/anthropic-listed-capabilities

Conversation

@obviyus

@obviyus obviyus commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: anthropic size: M labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR uses Anthropic’s advertised thinking capabilities to make newly listed Claude models selectable and shape their requests without waiting for an OpenClaw release.

Example: Anthropic lists claude-sonnet-9 with adaptive thinking and xhigh/max effort.

  • Before: OpenClaw hides the model because its advertised capabilities disagree with the built-in model-ID rules.
  • After: The model appears and supports adaptive-thinking requests with xhigh or max effort.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, scoped work with sufficient runtime evidence, preserved compatibility, and a resolved product decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied CLI/Gateway evidence exercises catalog projection and inference shaping, separates synthetic unknown models from real Anthropic responses, and records current-head restoration of template tools with successful real turns. Earlier capability-overlay proof remains applicable to the final inheritance repair; existing optional params and absent-flag fallback verify compatibility without migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: A newly listed Claude model can remain unavailable until OpenClaw ships matching request rules.
Reason: The existing gate was intentional, so replacing it is a capability expansion rather than a broken-contract repair. The recorded choice supports the scoped direct-provider behavior, and its value exceeds the bounded implementation cost.

Merge readiness

✅ Ready for maintainer review

The previous product-decision blocker is resolved by the recorded choice from a repository writer with prior merged catalog work. The compatibility repair remains intact, and no actionable patch defect was found.

Priority: P2
Reviewed head: 2022ebb00d595d368050a0255f7d5e61ab728313

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Anthropic plugin converts the provider’s model listing into OpenClaw’s model catalog. Shared Claude contracts consume that catalog metadata to offer thinking controls and construct inference requests.

flowchart TD
 A[Anthropic model listing] --> B[Anthropic catalog projection]
 C[Shipped model templates] --> B
 B --> D[Model picker and thinking controls]
 B --> E[Shared Claude request contracts]
 D --> E
 E --> F[Anthropic inference request]
Loading

Technical review

Best possible solution:

Keep the plugin-owned projection and shared Claude contracts with the recorded live-capability precedence and preserved template metadata.

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

Yes for the admission mechanism: current-main source rejects unfamiliar IDs whose advertised capabilities disagree with its predicates, and the supplied synthetic Gateway run demonstrates that path. The real API currently lists no ID hidden by the baseline.

Is this the best way to solve the issue?

Yes: composing the existing projection preserves template metadata and keeps request decisions in the shared Claude contract owner. The recorded discussion now settles live-versus-curated precedence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a799f4a42891.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Recorded direction resolves the prior blocker: fix(anthropic): newly listed Claude models stay hidden until an OpenClaw release #167658 (comment) explicitly chooses live thinking flags over curated rules for listed models, while preserving unrelated metadata and authored settings. GitHub verifies obviyus has write permission; fix(models): show every chat model a signed-in provider lists #167462 verifies their prior merged work on the shared catalog owner.
  • Current main still retains the agreement gate: Fetched main rejects unknown models unless adaptive, xhigh, and max capabilities agree with ID-based predicates. The relevant registration, shared contracts, and thinking-profile files have no changes between the merge base and fetched main, so this distinct capability-driven work remains necessary. (extensions/anthropic/live-model-contract-gate.ts:39, a799f4a42891)
  • Prior compatibility finding is fixed: The Anthropic projection first invokes the shared projection, then overlays capability flags without mutating shipped rows. The catalog regression verifies claude-sonnet-4-6 retains preferred Code Mode. (extensions/anthropic/live-model-projection.ts:63, 2022ebb00d59)
  • Contributor runtime evidence: The supplied full body, captured under sourceRevision ad19bbaeb8995c719016310fa159fba97cd984adc7793dfe7fc7ed219dba5028, distinguishes synthetic Gateway scenarios, stubbed captures, modified-build experiments, and real Anthropic requests. On the reviewed head, real default turns for claude-sonnet-4-6, claude-opus-4-6, and claude-sonnet-5 return 200, and the affected models regain baseline tool hashes. Earlier unknown-model proof exercises the same capability overlay; the final commit changes template inheritance. (2022ebb00d59)
  • Existing-state compatibility: The existing schema accepts arbitrary model params, generated catalogs serialize provider objects, and authored model fields retain merge precedence. Older rows without capability flags continue using ID rules; no format migration is required. (src/config/zod-schema.core.ts:289, 2022ebb00d59)
  • Accepted compatibility tradeoff: Live flags may change request shaping when Anthropic’s listing disagrees with curated rules; the recorded decision expressly accepts that precedence. The body discloses that shipped-model thinking hydration still uses manifest facts, while today’s real listing matches those facts. Broader catalog automation remains tracked by Automatic Anthropic model catalog: live Models API discovery + capability-driven contracts #113411. (packages/llm-core/src/model-contracts/anthropic.ts:228, 2022ebb00d59)

PR surface

Source +81, Tests +88, Docs +4. Total +173 across 14 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 7 135 54 +81
Tests 5 196 108 +88
Docs 2 15 11 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 346 173 +173

Review metrics

Metric Value Why it matters
Production versus test LOC Production +81 (+135/−54); tests +88 (+196/−108) The bounded production growth replaces the agreement gate with capability projection while reusing the existing template owner.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #113411
Summary: This PR addresses direct Anthropic capability-driven shaping within the broader catalog-automation request.

Members:

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded catalog improvement; the current real listing exposes no model hidden by the baseline.
  • merge-risk: 🚨 compatibility: Listed flags can override existing request contracts when provider metadata changes; the recorded decision explicitly accepts that precedence.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-09T06:29:08.848Z sha 8060632 :: blocked before merge. :: none
  • reviewed 2026-10-09T17:14:48.535Z sha 8060632 :: blocked before merge. :: [P1] Preserve template compatibility for non-manifest listed models
  • reviewed 2026-10-09T17:53:55.253Z sha 2022ebb :: blocked before merge. :: none

Reviewed October 9, 2026, 2:24 PM ET / 18:24 UTC (Revision 4).

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
…ed models

Listed Claude models the manifest does not ship lost Code Mode tools because the Anthropic projection built their rows from scratch. Compose with the shared live projection so they keep the closest shipped model's compat and thinking map, and only add the listed capability flags.
@obviyus
obviyus marked this pull request as ready for review October 9, 2026 17:47
@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Oct 9, 2026
@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer decision: use live flags for listed models. Anthropic's advertised capabilities (adaptive thinking, xhigh/max effort, disabled thinking) take precedence over the curated ID rules for every listed Anthropic API-key model, shipped or new; curated metadata the listing doesn't cover (Code Mode, limits, image sizing, cost, other request contracts) and authored settings stay as they are. Real-key parity on the current listing shows identical requests to the merge base for every listed model and level.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 9, 2026
@obviyus
obviyus merged commit b340251 into main Oct 9, 2026
199 of 202 checks passed
@obviyus
obviyus deleted the fix/anthropic-listed-capabilities branch October 9, 2026 18:26
@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in b340251. Anthropic API-key users now see newly listed Claude models as soon as /v1/models returns them, and requests follow the thinking type and effort levels Anthropic advertises (ID rules remain the fallback). Proof: real-key listing of 14 models, 46/46 captured requests identical to the merge base (incl. Code Mode tools), real 200s, and an unknown-ID simulation that built its request from advertised capabilities. Known gap: the CLI thinking-level check for shipped IDs still uses ID rules.

obviyus added a commit that referenced this pull request Oct 9, 2026
…ls fail their first turn (#167941)

## What Problem This Solves

Fixes: GitHub Copilot models fail on their first turn when the account lists a chat model that only serves Chat Completions (`kimi-k3` today), or a Claude model OpenClaw does not recognize yet (a newly launched Claude).

## User Impact

User impact: every chat model a Copilot account shows in the picker now answers its first turn, including Claude models released after the installed OpenClaw version. No config, schema, or protocol changes.

Merge danger: low. Shipped models keep their current transport and thinking shape (the transport only changes when the account's listing says the default endpoint is unsupported; Claude capabilities are only derived for rows that list `xhigh`, which every currently listed adaptive Claude model already matches by ID). Older listings without `supported_endpoints` keep the ID rules.

## Why This Change Was Made

Copilot's `/models` already says how each model can be called:

- `supported_endpoints` names the endpoints a model accepts. OpenClaw picked the transport from the model ID only, so a non-Claude, non-Gemini ID always went to `/responses`. `kimi-k3` lists only `/chat/completions` and was rejected (`unsupported_api_for_model`). The Copilot plugin now keeps the family transport when it is listed and otherwise uses a listed endpoint, with the existing Copilot Chat Completions request options.
- Copilot lists effort levels instead of Anthropic's capability tree, so Claude request shaping fell back to ID rules. An unknown Claude ID got manual `thinking.type: enabled` budgets, which current Claude models reject (`Use thinking.type.adaptive and output_config.effort`). Claude rows that list `xhigh` (only adaptive-thinking Claude models offer it) now carry the existing `params.claudeCapabilities` contract (#167658), so they get adaptive thinking and the listed xhigh/max levels before OpenClaw learns their ID.

The `fetchCopilotUsage` tests moved from `models.test.ts` to `usage.test.ts` (their owner) to keep `models.test.ts` under the line cap; no test was removed.

## Evidence

Real GitHub Copilot (Individual) account, device-flow sign-in on isolated profiles and loopback Gateways.

- Sign-in with the Gateway running: Copilot picker 0 → 29 rows, no restart. Account `/models` returned 54 rows; the picker equals the listed `type: chat` + `model_picker_enabled: true` rows exactly (context/prompt limits and vision match). Hidden: 3 embeddings, 7 internal Fireworks rows (copilot-search/exec-agent/trajectory-compaction), `gpt-5.6-luna-utility`, `gpt-5.4-nano`, and legacy GPT-3.5/4/4o/4.1 rows, all `model_picker_enabled: false`.
- One `reply OK` turn per picker model on `origin/main` (164210c): 27/29 ok. `kimi-k3` failed with HTTP 400 `unsupported_api_for_model` on `openai-responses`. `claude-haiku-4.5` at `--thinking low` was refused locally (the listing gives it no efforts); it passes at default/off.
- With this branch: `kimi-k3` 200 on `openai-completions` (low and medium). Regression set across transports and vendors: `gpt-5-mini`, `grok-4.7`, `mai-code-1.1-flash` (Responses), `gemini-3.8-flash` (Chat Completions), `claude-haiku-5.5` (Messages): all 200.
- New-model simulation (throwaway worktree, never pushed): removed `gpt-5.6-terra` and `claude-haiku-5.5` from the bundled manifests, ID rules/aliases, the recommended list, and a local copy of catalog.openclaw.ai served through `models.catalogRefresh.url`. Both still appeared after sign-in (29 rows). On main, `gpt-5.6-terra` worked (default/low) but `claude-haiku-5.5` failed with HTTP 400 (`thinking.type.enabled is not supported`). With this branch applied, both returned 200 at default, low, max, and off.
- `node scripts/run-vitest.mjs extensions/github-copilot`: 17 files, 214 tests pass. The new Claude test fails without the fix (manual budget payload) and passes with it.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Oct 9, 2026
…167949)

## What Problem This Solves

Fixes: some Grok models on an xAI subscription (OAuth) sign-in offer only `off`/`ultra` thinking, reject `--thinking low`, and run with reasoning on even at "off". This happens whenever the account's model listing names effort levels for a model OpenClaw's built-in model-ID rules don't cover (today: `grok-4.7-build-fast`).

## User Impact

User impact: for Grok subscription sign-ins, the thinking levels in the picker and the reasoning effort sent with each request now follow the efforts the account's listing reports. Models whose listing has no `none` effort no longer offer `off`. Every other Grok model keeps exactly the same levels and requests as before. Accounts that signed in before this change need to sign in again to refresh their saved model rows (documented).

## Why This Change Was Made

`cli-chat-proxy.grok.com/v1/models` reports `supports_reasoning_effort` and `reasoning_efforts` for each model, but the xAI plugin chose effort support by model ID alone. `grok-4.7-build-fast` lists `low/medium/high/xhigh` (default `high`). OpenClaw offered `off`/`ultra`, and "off" left out the effort field, so the proxy ran it at its default `high`.

- The OAuth listing projection now copies the listed efforts into the existing `compat.supportedReasoningEfforts` field.
- The xAI runtime compat reads that field first and maps each level to the listed effort, or to the nearest listed one. `off` sends `none` only when `none` is listed; otherwise `off` is unsupported, the same as current Grok 4.5+ behavior. Model-ID rules apply only to rows that list no efforts.
- The xAI thinking profile offers the listed levels. Rows that runtime normalization stamped with their own ID-rule list keep their existing ladder; this keeps Grok 4.3's `minimal` level and `low` default.

There are no schema, config, SDK, or core changes. **Known gap (not fixed here):** agent runs take thinking options from the model rows saved in config at sign-in (`src/agents/command/prepare.ts:303` `buildConfiguredModelCatalog`; `src/agents/command/model-selection.ts:524-531` skips hydration through `needsThinkHydration` because the saved row counts as resolved). The picker uses the live listing instead. So until an account signs in again, the picker can offer `low` while `--thinking low` is still rejected. This is the same shared gap the Anthropic listed-capabilities work (#167658) hit, and it is tracked as one core follow-up.

## Evidence

- Regression tests, both failing on `origin/main` code and passing here:
  - `extensions/xai/index.test.ts`: a listed row with efforts reaches the thinking profile (`low..xhigh`, default `high`) and runtime compat (`off: null`, `low: "low"`, …).
  - `extensions/xai/runtime-model-compat.test.ts`: `off` sends `none` only when it is listed; unknown efforts are dropped; nearest-effort mapping.
  - `extensions/xai/provider-policy-api.test.ts`: Grok 4.3's ladder is unchanged after runtime normalization stamps its efforts.
- Real Grok subscription account (device-code sign-in), isolated `--profile` Gateways. A loopback forward proxy (`proxy.proxyUrl` plus a proof-only CA) recorded each outgoing `/v1/responses` shape. Cells marked stub got a canned stream; the rest were forwarded unchanged to the real proxy.
  - Listing: 4 rows (`grok-4.7`, `grok-4.7-build-fast`, `grok-4.6`, `grok-4.5`), all `api_backend: responses`, all `supports_reasoning_effort: true`.
  - Picker levels on merge base `164210c` and on this branch for all 8 shown xAI rows: identical except `grok-4.7-build-fast` (`off,ultra` default `off` → `low,medium,high,xhigh,ultra` default `high`).
  - Request parity: 8 models × `default/off/minimal/low/medium/high/xhigh/ultra`, 64 cells per build. Accepted/rejected levels and the `reasoning` field match for every cell. Two cells differ only because a background `grok-4.6` request (effort `high`, 12 tools) landed in a different cell on each build; that request has the same shape on both builds.
  - Fresh sign-in on this branch: models appear without restart; saved rows carry the listed efforts. Real turns: `grok-4.7-build-fast` default → sent `effort: high`, 200, proxy echoed `high`. `--thinking low` → sent `low`, 200, proxy echoed `low`. `--thinking off` → rejected: "Use one of: low, medium, high, xhigh, ultra". Control `grok-4.7` default → `high`, 200 on both builds.
  - Before (merge base): `grok-4.7-build-fast` default sent no `reasoning`; `--thinking low` was rejected ("Use one of: off, ultra").
- `pnpm exec oxlint --type-aware` on the changed files; `node scripts/check-changed.mjs`; `node scripts/run-vitest.mjs extensions/xai/` (563 passed before the final small type/lint fixups; focused files rerun after them).

**Merge danger:** low. Only the xAI plugin changes. On the real account, request bodies for every model except `grok-4.7-build-fast` are byte-identical in the recorded fields. Risk: a future listing that reports efforts differing from the ID rules for a known model (for example, dropping `xhigh`) will now change that model's ladder. That is intended.

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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…ls fail their first turn (openclaw#167941)

## What Problem This Solves

Fixes: GitHub Copilot models fail on their first turn when the account lists a chat model that only serves Chat Completions (`kimi-k3` today), or a Claude model OpenClaw does not recognize yet (a newly launched Claude).

## User Impact

User impact: every chat model a Copilot account shows in the picker now answers its first turn, including Claude models released after the installed OpenClaw version. No config, schema, or protocol changes.

Merge danger: low. Shipped models keep their current transport and thinking shape (the transport only changes when the account's listing says the default endpoint is unsupported; Claude capabilities are only derived for rows that list `xhigh`, which every currently listed adaptive Claude model already matches by ID). Older listings without `supported_endpoints` keep the ID rules.

## Why This Change Was Made

Copilot's `/models` already says how each model can be called:

- `supported_endpoints` names the endpoints a model accepts. OpenClaw picked the transport from the model ID only, so a non-Claude, non-Gemini ID always went to `/responses`. `kimi-k3` lists only `/chat/completions` and was rejected (`unsupported_api_for_model`). The Copilot plugin now keeps the family transport when it is listed and otherwise uses a listed endpoint, with the existing Copilot Chat Completions request options.
- Copilot lists effort levels instead of Anthropic's capability tree, so Claude request shaping fell back to ID rules. An unknown Claude ID got manual `thinking.type: enabled` budgets, which current Claude models reject (`Use thinking.type.adaptive and output_config.effort`). Claude rows that list `xhigh` (only adaptive-thinking Claude models offer it) now carry the existing `params.claudeCapabilities` contract (openclaw#167658), so they get adaptive thinking and the listed xhigh/max levels before OpenClaw learns their ID.

The `fetchCopilotUsage` tests moved from `models.test.ts` to `usage.test.ts` (their owner) to keep `models.test.ts` under the line cap; no test was removed.

## Evidence

Real GitHub Copilot (Individual) account, device-flow sign-in on isolated profiles and loopback Gateways.

- Sign-in with the Gateway running: Copilot picker 0 → 29 rows, no restart. Account `/models` returned 54 rows; the picker equals the listed `type: chat` + `model_picker_enabled: true` rows exactly (context/prompt limits and vision match). Hidden: 3 embeddings, 7 internal Fireworks rows (copilot-search/exec-agent/trajectory-compaction), `gpt-5.6-luna-utility`, `gpt-5.4-nano`, and legacy GPT-3.5/4/4o/4.1 rows, all `model_picker_enabled: false`.
- One `reply OK` turn per picker model on `origin/main` (2fd61a9): 27/29 ok. `kimi-k3` failed with HTTP 400 `unsupported_api_for_model` on `openai-responses`. `claude-haiku-4.5` at `--thinking low` was refused locally (the listing gives it no efforts); it passes at default/off.
- With this branch: `kimi-k3` 200 on `openai-completions` (low and medium). Regression set across transports and vendors: `gpt-5-mini`, `grok-4.7`, `mai-code-1.1-flash` (Responses), `gemini-3.8-flash` (Chat Completions), `claude-haiku-5.5` (Messages): all 200.
- New-model simulation (throwaway worktree, never pushed): removed `gpt-5.6-terra` and `claude-haiku-5.5` from the bundled manifests, ID rules/aliases, the recommended list, and a local copy of catalog.openclaw.ai served through `models.catalogRefresh.url`. Both still appeared after sign-in (29 rows). On main, `gpt-5.6-terra` worked (default/low) but `claude-haiku-5.5` failed with HTTP 400 (`thinking.type.enabled is not supported`). With this branch applied, both returned 200 at default, low, max, and off.
- `node scripts/run-vitest.mjs extensions/github-copilot`: 17 files, 214 tests pass. The new Claude test fails without the fix (manual budget payload) and passes with it.

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

## What Problem This Solves

Fixes: some Grok models on an xAI subscription (OAuth) sign-in offer only `off`/`ultra` thinking, reject `--thinking low`, and run with reasoning on even at "off". This happens whenever the account's model listing names effort levels for a model OpenClaw's built-in model-ID rules don't cover (today: `grok-4.7-build-fast`).

## User Impact

User impact: for Grok subscription sign-ins, the thinking levels in the picker and the reasoning effort sent with each request now follow the efforts the account's listing reports. Models whose listing has no `none` effort no longer offer `off`. Every other Grok model keeps exactly the same levels and requests as before. Accounts that signed in before this change need to sign in again to refresh their saved model rows (documented).

## Why This Change Was Made

`cli-chat-proxy.grok.com/v1/models` reports `supports_reasoning_effort` and `reasoning_efforts` for each model, but the xAI plugin chose effort support by model ID alone. `grok-4.7-build-fast` lists `low/medium/high/xhigh` (default `high`). OpenClaw offered `off`/`ultra`, and "off" left out the effort field, so the proxy ran it at its default `high`.

- The OAuth listing projection now copies the listed efforts into the existing `compat.supportedReasoningEfforts` field.
- The xAI runtime compat reads that field first and maps each level to the listed effort, or to the nearest listed one. `off` sends `none` only when `none` is listed; otherwise `off` is unsupported, the same as current Grok 4.5+ behavior. Model-ID rules apply only to rows that list no efforts.
- The xAI thinking profile offers the listed levels. Rows that runtime normalization stamped with their own ID-rule list keep their existing ladder; this keeps Grok 4.3's `minimal` level and `low` default.

There are no schema, config, SDK, or core changes. **Known gap (not fixed here):** agent runs take thinking options from the model rows saved in config at sign-in (`src/agents/command/prepare.ts:303` `buildConfiguredModelCatalog`; `src/agents/command/model-selection.ts:524-531` skips hydration through `needsThinkHydration` because the saved row counts as resolved). The picker uses the live listing instead. So until an account signs in again, the picker can offer `low` while `--thinking low` is still rejected. This is the same shared gap the Anthropic listed-capabilities work (openclaw#167658) hit, and it is tracked as one core follow-up.

## Evidence

- Regression tests, both failing on `origin/main` code and passing here:
  - `extensions/xai/index.test.ts`: a listed row with efforts reaches the thinking profile (`low..xhigh`, default `high`) and runtime compat (`off: null`, `low: "low"`, …).
  - `extensions/xai/runtime-model-compat.test.ts`: `off` sends `none` only when it is listed; unknown efforts are dropped; nearest-effort mapping.
  - `extensions/xai/provider-policy-api.test.ts`: Grok 4.3's ladder is unchanged after runtime normalization stamps its efforts.
- Real Grok subscription account (device-code sign-in), isolated `--profile` Gateways. A loopback forward proxy (`proxy.proxyUrl` plus a proof-only CA) recorded each outgoing `/v1/responses` shape. Cells marked stub got a canned stream; the rest were forwarded unchanged to the real proxy.
  - Listing: 4 rows (`grok-4.7`, `grok-4.7-build-fast`, `grok-4.6`, `grok-4.5`), all `api_backend: responses`, all `supports_reasoning_effort: true`.
  - Picker levels on merge base `2fd61a9` and on this branch for all 8 shown xAI rows: identical except `grok-4.7-build-fast` (`off,ultra` default `off` → `low,medium,high,xhigh,ultra` default `high`).
  - Request parity: 8 models × `default/off/minimal/low/medium/high/xhigh/ultra`, 64 cells per build. Accepted/rejected levels and the `reasoning` field match for every cell. Two cells differ only because a background `grok-4.6` request (effort `high`, 12 tools) landed in a different cell on each build; that request has the same shape on both builds.
  - Fresh sign-in on this branch: models appear without restart; saved rows carry the listed efforts. Real turns: `grok-4.7-build-fast` default → sent `effort: high`, 200, proxy echoed `high`. `--thinking low` → sent `low`, 200, proxy echoed `low`. `--thinking off` → rejected: "Use one of: low, medium, high, xhigh, ultra". Control `grok-4.7` default → `high`, 200 on both builds.
  - Before (merge base): `grok-4.7-build-fast` default sent no `reasoning`; `--thinking low` was rejected ("Use one of: off, ultra").
- `pnpm exec oxlint --type-aware` on the changed files; `node scripts/check-changed.mjs`; `node scripts/run-vitest.mjs extensions/xai/` (563 passed before the final small type/lint fixups; focused files rerun after them).

**Merge danger:** low. Only the xAI plugin changes. On the real account, request bodies for every model except `grok-4.7-build-fast` are byte-identical in the recorded fields. Risk: a future listing that reports efforts differing from the ID rules for a known model (for example, dropping `xhigh`) will now change that model's ladder. That is intended.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
… Anthropic API-key routes (#168164)

Backport of 77e2261 (#168164) adapted for 2026.10.2.

Adaptations for the release line:
- attempt-stream.ts: 10.1 predates installStreamWrapper (#166690); keep the
  direct session.agent.streamFn wrapping and split the compaction-replay
  repair (Responses or compactionReplayEnabled) from the Responses-only
  message transform, as on main.
- Extract supportsNativeOpenAIResponsesEndpoint/isOfficialOpenAIResponsesBaseUrl
  into transports/openai-responses-endpoint.ts and re-export it from
  @openclaw/ai/internal/openai-responses-payload-policy, matching main's
  layout (introduced there by #164597) without pulling that feature in.
- supportsClaudeServerCompaction delegates to supportsClaudeAdaptiveThinking,
  which is already id-based on 10.1 (main's ById split came with #167658).
- Tests: keep release-only cases (context-management preservation, xAI
  opt-out, release gate rows without the removed purpose argument), export
  createRawSseResponse from the new Anthropic transport test-support.

(cherry picked from commit 77e2261)
obviyus added a commit that referenced this pull request Oct 29, 2026
## What Problem This Solves

The repo has no written rules for agents that work on model listing, provider plugins or usage/cost. So the same classes of bugs keep coming back across providers and on the Models and Usage pages.

## User Impact

There is no user-visible change. Agents that work in these areas now get short rules from the scoped guide they already read.

## Why This Change Was Made

Each rule records a lesson that came back 2 or more times in merged work. Each rule is one line, in the guide that owns the area:

- **`src/plugins/AGENTS.md` "Model Listing":**
  - The hot path has no network request.
  - `models.list` has p99 under 300 ms. Rows and prices publish as one snapshot, and removals apply at once.
  - The authenticated listing decides which models show.
  - List with the credential and runtime that will execute the turn, with one row per model per provider.
  - Failed and empty listings each have defined semantics.
  - Capabilities come from the listing, not from model-ID rules.
  - One core admission rule.
- **`extensions/AGENTS.md`:**
  - Host policy that every provider shares stays core.
  - Sign-in goes through the Models page and `/login`. Setup saves the connection only.
  - Native CLIs own their login and model menu.
  - Refusals are classified by cause.
  - Attribution headers come from one helper.
- **`src/agents/AGENTS.md` "Run Authority":**
  - One model resolver for every entry path.
  - No silent fallback to another runtime or billing.
  - Native-runtime consent is asked once.
- **`src/gateway/AGENTS.md` "Usage And Cost" (new section):**
  - Measured, unpriced, partial and unknown usage stay distinct.
  - Each route is priced from the provider that bills it.
  - Reports are complete or flagged as partial.
- **`ui/AGENTS.md`:**
  - A route waits only for its first-paint data.
  - New "Layout Stability" section: zero layout shift, how to prove it, and a 200 ms load budget for Models and Usage.
- **Root `AGENTS.md`:** one line in "Read when relevant" that points to these sections.

Examples of the incidents behind the rules: #140139, #158000, #167444, #167658, #168033, #172608, #172773, #173792, #174641, #176404, #180838, #184066.

## Evidence

- `pnpm check:agents-md-size`: all 27 files are within 20000 chars.
- `oxfmt --check` passes on each of the 6 changed files.
- I checked the cited names on current `main`: `buildLiveModelProviderConfig`, `readModelId` and `modelPricing.providers.<id>.priceAs`.

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

## What Problem This Solves

The repo has no written rules for agents that work on model listing, provider plugins or usage/cost. So the same classes of bugs keep coming back across providers and on the Models and Usage pages.

## User Impact

There is no user-visible change. Agents that work in these areas now get short rules from the scoped guide they already read.

## Why This Change Was Made

Each rule records a lesson that came back 2 or more times in merged work. Each rule is one line, in the guide that owns the area:

- **`src/plugins/AGENTS.md` "Model Listing":**
  - The hot path has no network request.
  - `models.list` has p99 under 300 ms. Rows and prices publish as one snapshot, and removals apply at once.
  - The authenticated listing decides which models show.
  - List with the credential and runtime that will execute the turn, with one row per model per provider.
  - Failed and empty listings each have defined semantics.
  - Capabilities come from the listing, not from model-ID rules.
  - One core admission rule.
- **`extensions/AGENTS.md`:**
  - Host policy that every provider shares stays core.
  - Sign-in goes through the Models page and `/login`. Setup saves the connection only.
  - Native CLIs own their login and model menu.
  - Refusals are classified by cause.
  - Attribution headers come from one helper.
- **`src/agents/AGENTS.md` "Run Authority":**
  - One model resolver for every entry path.
  - No silent fallback to another runtime or billing.
  - Native-runtime consent is asked once.
- **`src/gateway/AGENTS.md` "Usage And Cost" (new section):**
  - Measured, unpriced, partial and unknown usage stay distinct.
  - Each route is priced from the provider that bills it.
  - Reports are complete or flagged as partial.
- **`ui/AGENTS.md`:**
  - A route waits only for its first-paint data.
  - New "Layout Stability" section: zero layout shift, how to prove it, and a 200 ms load budget for Models and Usage.
- **Root `AGENTS.md`:** one line in "Read when relevant" that points to these sections.

Examples of the incidents behind the rules: openclaw#140139, openclaw#158000, openclaw#167444, openclaw#167658, openclaw#168033, openclaw#172608, openclaw#172773, openclaw#173792, openclaw#174641, openclaw#176404, openclaw#180838, openclaw#184066.

## Evidence

- `pnpm check:agents-md-size`: all 27 files are within 20000 chars.
- `oxfmt --check` passes on each of the 6 changed files.
- I checked the cited names on current `main`: `buildLiveModelProviderConfig`, `readModelId` and `modelPricing.providers.<id>.priceAs`.

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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant