Skip to content

fix(models): read provider model kinds at one owner; unknown is not chat:false - #199998

Merged
obviyus merged 8 commits into
mainfrom
openclaw/chat-capability-step1
Nov 16, 2026
Merged

obviyus merged 8 commits into
mainfrom
openclaw/chat-capability-step1

Conversation

@obviyus

@obviyus obviyus commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Since #198288, a listed model with no capability metadata is stored as inference.chat: false, so it is hidden and refused before any request. But the shared translator (readLiveModelChatCapability) did not read most providers' capability fields:

Change

  • Kind vocabulary, in provider-catalog-live-normalize.internal.ts. The translator reads type, task, model_type, pipeline_tag, LiteLLM mode, DeepInfra metadata.tags and Ollama capabilities.
    • chat, text, llm, vlm, text-generation and *-text-to-text are affirmative.
    • Explicit non-chat kinds decide on their own and beat text output: embedding, rerank, image, video, audio, speech, tts/stt/asr, transcription, music, inpaint, upscale, realtime, moderation, decision, evaluation, ocr, search, and LiteLLM completion.
    • Together language is neither (the review point on fix: allow listed models with missing chat metadata #199544).
  • Unknown is not false. A row with no evidence stays unknown, which downstream treats as chat. Interim rule: an unknown ID matching NON_TEXT_MODEL_ID_PATTERN still gets chat: false.
  • Closed-world pass, unfamiliar values only. Within one listing, a row with a different value in a field that other rows use for a chat kind is not chat (Together language next to chat). Rows missing the field stay unknown.
  • Removes the LiteLLM mode patch from fix(litellm): LiteLLM proxy chat models are hidden from model lists and refused as not chat #198582; the shared translator yields the same rows.
  • No wire, schema, config or cache-scope change. src/plugins/AGENTS.md (with the incident citation) and model-catalogs.md each state the rule once.
  • Related PRs:

Proof

Replay of saved real listings (merge base 4ff607aa61f3 vs head; unchanged on this head)

provider listed rows with proof main shown branch shown main wrongly shown / hidden branch wrongly shown / hidden
OpenAI picker (counts only) 125 31 14 37 0 / 8 1 / 3
HF router / OpenRouter 600 600 600 600 0 / 0 0 / 0
Vercel AI Gateway 508 508 353 323 30 / 0 0 / 0
DeepInfra 178 178 0 92 0 / 92 0 / 0
Venice 414 414 0 142 0 / 142 0 / 0
NVIDIA (no proof) 39 0 1 29 – –
models.dev 9,878 9,545 9,420 9,414 6 / 0 0 / 0

Tests

  • Kind fixtures: real listing shapes with synthetic IDs. They fail on the merge base; the completion-only case failed on 3edf4c06.
  • model-catalog.test.ts: the audio-only pin case is unchanged. It had failed only because the test shared a cached listing between cases; the test now clears the cache. The bare-row case asserts the new unknown contract.
  • Revert of the cache-scope bump: the catalog scope, backup sanitizer, logout and credential tests and perf scripts are byte-identical to the merge base again. On this head, ocx test passes for plugin-model-catalog (read, write, auth), models-config write serialization, auth-logout, doctor catalog and credentials, snapshot/backup, prepared-model-runtime and model-catalog.test.ts. The Postgres lanes are skipped without a server.
  • Earlier heads also passed the plugin-sdk and normalizer-consumer extension suites. extensions/meta/muse-login.test.ts also times out on the merge base.
  • Gates: tsgo:core, check:test-types, oxlint and oxfmt are clean. The test-lines ratchet passes (+97).

Upgrade proof (built dist, real OpenAI key)

  • Setup: every child ran under env -i (PATH, temp HOME, TMPDIR, OPENCLAW_STATE_DIR; the key was passed only through stdin into the environment), on loopback with its own port and token, refusing to start if any channel was configured.
  • State: one state dir across all phases. Config pins openai/gpt-5-mini (primary plus agents.defaults.models); a session pin is set with /model openai/gpt-5-mini.
  • Releases are unaffected: no release stored the old-rule value. 2026.11.4 and every beta through 2026.11.5-beta.4 predate fix: hide non-chat models from chat selection #198288, and 2026.11.4 saves gpt-5-mini without chat:false. Only main and nightly installs that ran fix: hide non-chat models from chat selection #198288 have it.

These phases were run on cec46be8, which has the same code as this head:

phase models list --all --provider openai session pin / config pin
main 4ff607aa (old rule) gpt-5-mini absent; saved catalog holds gpt-5-mini with chat:false refused: model_chat_unsupported
this branch, first start on that state after discovery gpt-5-mini listed still refused: the startup catalog comes from the saved rows (the #184996 typed-only veto)
this branch, after one restart gpt-5-mini listed immediately reply ok from gpt-5-mini
  • Accepted edge: a main or nightly install that ran fix: hide non-chat models from chat selection #198288 may see an affected pin refused until the first restart after upgrading. It is visible and self-healing, and there is no code for it, only a comment at the pre-run fallback in embedded-agent-runner/model.ts.
  • Earlier rejected attempt: a cache-scope bump avoided this edge. It was reverted because logout cleanup searched only the new scope, and it would make every release user cold-start.
  • Other results from the same harness:
    • With embedding and tts allowed in config, they stay hidden and are refused by the chat check (model_chat_unsupported).
    • Downgrading to main loads cleanly. 2026.11.4 on main-written state refuses to start with a clear schema message (schema 40 from main; this diff has no schema change), with no crash.
    • Sessions and config were preserved in every phase.
  • Cleanup: 0 key hits in all saved output, every Gateway and port gone, and the live Gateway's pid unchanged.

Known gap (pre-existing, follow-up)

A turn within about 10 s of Gateway start can get "Unknown model" for a live-only model, because the run-time registry lags the prepared catalog. This will be fixed separately.

obviyus and others added 2 commits November 16, 2026 11:28
…hat:false

The shared live-listing translator now reads each provider's capability
vocabulary: LiteLLM `mode`, DeepInfra `metadata.tags`, Venice/Together/
Vercel/models.dev `type`, oMLX/NVIDIA `model_type`, Hugging Face
`pipeline_tag` and the Ollama `capabilities` list. `chat` and `text` kinds
are affirmative; a declared non-chat kind beats text output, so embedding
and reranking rows that list `text` output are no longer shown.

A row with no evidence is unknown and treated as chat instead of being
recorded as `inference.chat: false`; as an interim rule, an unknown ID that
names a non-text family still gets `chat: false`. Within one listing, rows
that carry a kind field holding another value than a chat kind used by other
rows are not chat (Together `language`). The LiteLLM `mode` patch from
#198582 is removed; the shared translator yields the same rows.

Co-authored-by: obviyus <[email protected]>
…hat:false

OpenClaw-Publication: b583c461-57f1-4932-a8d9-1ab3794de058
@clawsweeper

clawsweeper Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR centralizes provider model-kind parsing and stops recording missing capability metadata as an explicit chat denial.

Example: OpenAI lists gpt-5-mini without chat-capability metadata.

  • Before: Discovery marks it chat:false, hiding it and refusing saved selections.
  • After: Discovery leaves support unknown, allowing selection and execution; affected main/nightly saved catalogs may require one restart.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful shared repair with applicable production behavior evidence, preserved compatibility boundaries and one redundant test.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied built-Gateway results exercise metadata-free OpenAI discovery, saved selections, a real gpt-5-mini reply and explicit non-chat controls; the exercised implementation matches this head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Supported models listed by a provider disappear from chat choices or are refused before a request because capability metadata is missing or unrecognized.
Reason: The repair restores useful listed models through the existing owner, and collaborator authorship supplies the direction decision for relaxing the previous default.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: current main still has the discovery regression, and the shared repair has no blocking correctness or security findings.

Priority: P1
Reviewed head: 4f781b9d896a07224ad05937cf8189b704b4ece8

Before merge

None.

Findings

None.

Tests

  • Low-value test src/agents/model-catalog.test.ts: Remove the new standalone metadata-free publication test: it calls the same catalog builder already covered by the runtime suite's unclassified-row case and never exercises the agent catalog or resolver; retain the cache reset and excluded-pin integration coverage.
Agent review details

How this fits together

The shared catalog normalizer converts provider listings and upstream metadata into model rows consumed by pickers and agent admission.

flowchart LR
 A[Provider listings] --> C[Shared capability translator]
 B[Upstream metadata] --> C
 C --> D[Prepared model catalog]
 D --> E[Model picker]
 D --> F[Agent admission]
 F --> G[Provider transport]
Loading

Technical review

Best possible solution:

Land the shared translator repair after required CI passes, preserving explicit denials and the documented restart tradeoff.

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

Current-main source deterministically assigns chat:false to unfamiliar metadata-free rows, and the supplied Gateway replay records the resulting refusal; this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete repair extends the existing capability owner, distinguishes unknown from denial in both projections, and removes the replaced LiteLLM adapter without adding state or configuration.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared capability classification, unknown defaults and catalog documentation changes intended behavior with a stated reason (2110db5: Require affirmative chat/text declarations to prevent non-chat selections while retaining negative facts for saved pins.)
  • LiteLLM mode adapter keeps the original intent (48cdab3: Restore proxy models declaring mode:chat because the shared parser did not recognize that field.)
  • Provider request-shaping admission gates keeps the original intent (8028a3a: Prevent discovered models from being offered when the provider cannot construct a supported request.)
  • Shared model-listing ownership instruction keeps the original intent (0aced8c: Record one core admission owner and authenticated-listing ownership to prevent repeated provider-specific drift.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2110db5 adds src/plugin-sdk/provider-catalog-live-normalize.internal.ts:129 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2110db5a1d1c; files: src/plugin-sdk/provider-catalog-live-normalize.internal.ts)
  • Ayaan Zaidi: Raw commit 6b3a4ec adds src/plugin-sdk/provider-catalog-live-normalize.internal.ts:135 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6b3a4ec511e6; files: src/plugin-sdk/provider-catalog-live-normalize.internal.ts)
  • Jason (Json): Raw commit 55cf952 adds src/plugin-sdk/provider-catalog-live-normalize.internal.ts:91 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 55cf9523e015; files: src/plugin-sdk/provider-catalog-live-normalize.internal.ts)
  • Hannes Rudolph: Raw commit 28bad33 adds src/agents/embedded-agent-runner/model.ts:155 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 28bad336c002; files: src/agents/embedded-agent-runner/model.ts)

PR surface

Source +28, Tests +97, Docs -3. Total +122 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 83 55 +28
Tests 6 122 25 +97
Docs 3 14 17 -3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 219 97 +122

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The existing regression hides supported provider-listed models and refuses real agent turns before inference.
  • merge-risk: 🚨 compatibility: The public discovery default changes for metadata-free rows; maintainer authorship accepts that direction and explicitly records the main/nightly restart tradeoff.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-16T06:19:20.632Z sha 3edf4c0 :: needs changes before merge. :: [P2] Classify completion modes without requiring a chat sibling | [P2] Cite the incident behind the expanded admission instruction
  • reviewed 2026-11-16T06:45:49.307Z sha cec46be :: blocked before merge. :: none
  • reviewed 2026-11-16T07:58:01.799Z sha 6b64349 :: blocked before merge. :: [P1] [P1] Scrub retained v1 catalog credentials during logout
  • reviewed 2026-11-16T08:35:03.416Z sha 4f781b9 :: needs maintainer review before merge. :: none

Reviewed November 16, 2026, 3:45 AM ET / 08:45 UTC (Revision 5).

obviyus and others added 2 commits November 16, 2026 12:08
LiteLLM `mode: "completion"` is now a declared non-chat kind, so a proxy
listing only completion models no longer admits them as chat; the
closed-world pass stays for unfamiliar values in a field the listing uses
for chat. The model-catalog pin test cleared no live-row cache, so its
audio-only case was served the previous case's bare listing; it now
clears the cache, and the bare-row case asserts the new unknown contract.
Cite the incident beside the Model Listing rule.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: adde80a3-c327-43b4-86a9-35026a695cf9
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Nov 16, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Nov 16, 2026
obviyus and others added 2 commits November 16, 2026 13:09
… rule

A Gateway built before this change saved listed models without capability
metadata as `inference.chat: false` in the persisted plugin model catalog.
After an upgrade, the startup catalog loaded those rows and the pre-run guard
kept refusing session and config pins to them for the whole first run, even
after discovery republished them without the veto; they recovered only on the
next restart. Saved catalogs now use the `plugin-model-catalog-v2` cache
scope, so this build starts from discovery instead of the stale rows. v1 rows
stay for older builds after a downgrade, and backups keep sanitizing them.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 9690d624-6407-4e9e-aa3e-746a0a90a9c5
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts commands Command implementations labels Nov 16, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 Nov 16, 2026
obviyus and others added 2 commits November 16, 2026 13:58
Reverts the plugin-model-catalog-v2 cache scope. Logout credential cleanup
searched only the new scope, so retained v1 rows kept plaintext credentials,
and every release user would cold-start after upgrading. No release saved the
old unknown-is-false value; a main or nightly install that ran #198288 can
see an affected pin refused until its first restart after upgrading, which
self-heals. Name that accepted edge beside the pre-run fallback.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 3f0e5160-67d1-4c56-bc7a-5f51e798bcdb
@openclaw-barnacle openclaw-barnacle Bot removed scripts Repository scripts commands Command implementations labels Nov 16, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 16, 2026
@obviyus
obviyus merged commit 84a378c into main Nov 16, 2026
207 of 209 checks passed
@obviyus
obviyus deleted the openclaw/chat-capability-step1 branch November 16, 2026 09:28
obviyus added a commit that referenced this pull request Nov 16, 2026
)

## Problem

#199998 made models that a provider lists without capability metadata visible and runnable. A listed model that is not a chat model, or is not enabled for the account, now fails at its first request instead of being hidden.

Live probes on OpenAI and Google AI Studio show these failures return a 4xx in 0.3–1.0 s. About half of the bodies say the model "does not exist" (404), so OpenClaw reported "This model was not found". That is misleading for a model that the provider itself lists. Others ("not supported with the Responses API", "response modalities", "bidiGenerateContent", "not allowed to sample") ended as a raw request rejection or a sign-in error.

## Solution

Both conditions below must hold:

- The provider answers with a deterministic **400, 403 or 404** that contains one of these phrases: "model … does not exist", "not supported with the Responses API", "not supported for generateContent", "response modalities", "bidiGenerateContent" or "not allowed to sample".
- The **successful listing made with the same credential** (same provider and auth profile) returned that model ID. The check reads the outcome's `listedModelIds` or `modelIdCatalog`.

When both hold, the turn says:

> The provider lists this model but rejected a chat request. It may not be a chat model, or it isn't enabled for this account. Choose another model.

Code changes:

- `live-model-errors.ts`: `isListedModelChatRejection(status, message)`. It sits next to the model-not-found matcher, so the classifier owner stays the same.
- `failover/error.ts` + `user-copy.ts`: code `model_chat_rejected` and its copy. The code is rendered through the existing `renderFailoverCodeUserCopy` path, which every reply surface already uses for `model_chat_unsupported`.
- `provider-catalog-outcome.ts`: `isModelInCredentialListing`, which uses the same credential rule as the account-entitlement check.
- `assistant-failure.ts` + `failover-policy.ts`: the run produces a stateless `format` failure. This failure skips auth refresh, profile rotation, profile cooldown and session-model revert. It also skips the deterministic-format fallback stop, so a configured fallback runs next. Like the deterministic-400 handling from #198288, there is no retry and no compaction.
- Catalog owners publish their listing: the OpenAI API-key catalog's ready outcome carries `modelIdCatalog`, as the shared OpenAI-compatible live catalog already does. The Google AI Studio catalog's ready outcome carries `listedModelIds`: every ID `models.list` returned, including the non-chat rows its projection hides. Before this, the Google catalog published no listing, so the Google rules could never apply.

These cases stay on their current paths: 5xx, 429, 401/402, timeouts, any 200 (including empty output), and 404s for models that are not in the current listing (the real model-not-found case).

## Impact

- Users see an honest reason and the next configured model runs. Nothing is persisted.
- Side effect: OpenAI API-key users with configured OpenAI model IDs that their listing does not return now get the existing "unlisted configured model" advisory. Other live-listing providers already show it.
- Accepted edge: a turn that is admitted before the first listing of the Gateway's life completes cannot prove listing membership. It keeps the current model-not-found copy. The next turn after discovery uses the new copy.
- Not covered: failures produced inside a plugin-owned harness transport (prompt stage, for example Codex app-server requests). In the real run below, the listed model went through OpenClaw's own transport.

## Evidence

**Regression tests (red on the merge base `84a378cfe2df`, green here).** `assistant-failure.listed-model.test.ts` replays sanitized live bodies through `projectProviderError` → `handleEmbeddedAssistantFailure` → `runWithModelFallback` → reply copy. Model IDs are synthetic, and request IDs and headers are removed. The positive bodies are an OpenAI Responses 404 and 400, an OpenAI Chat 403, and Google generateContent 404, modalities 400 and bidi 400. Each case uses its owner's listing shape: OpenAI `modelIdCatalog`, Google `listedModelIds`.

- On base, all 6 copy cases fail: they show "This model was not found", "Couldn't sign in…" or "LLM request rejected: …".
- On base, the two Google 400 cases also stop the fallback chain.
- Negative fixtures pass on both: 500, 429, 401, an empty 200, and a 404 for a model missing from the listing.
- A unit test checks that only 400/403/404 qualify, and never 200, 401, 402, 408, 429, 500 or 503.
- `extensions/google/provider-registration.test.ts` runs the registered Google catalog against a `models.list` body with a chat row and an `embedContent`-only row. The picker gets only the chat row; the ready outcome lists both IDs under the selected auth profile.

**Real Gateway turn.** I built both sides with `ocx build --dist`. Each Gateway ran isolated under `env -i` with only `PATH`, a temporary `HOME`, `TMPDIR`, `OPENCLAW_STATE_DIR` and `OPENAI_API_KEY`. Each used loopback only, its own port and token, and no channels. The harness refreshed the OpenAI listing through the Gateway, then ran one `openclaw agent` turn on a model that this key's `/v1/models` lists but cannot use. Public listed non-chat IDs such as `text-embedding-3-small` are still refused before the run. Google has no real-Gateway turn; its proof is the two tests above.

| | Reply | Provider requests (`[model-fetch] start POST /v1/responses`) | Decision |
|---|---|---|---|
| merge base `84a378cfe2df` | `This model was not found. Choose another model in the OpenClaw app. \| model_not_found` | 1 (404) | `surface_error reason=model_not_found` |
| this branch | `The provider lists this model but rejected a chat request. It may not be a chat model, or it isn't enabled for this account. \| model_chat_rejected` | 1 (404) | `surface_error reason=format`, no compaction |

The real run used the copy before review added the trailing "Choose another model."; the regression test asserts the final copy.

An exact-key scan of every Gateway log and state directory found 0 hits. All Gateways and ports were confirmed gone afterwards.

**Checks.** Focused tests pass (agents failover, OpenAI catalog, Google registration and catalog). `pnpm tsgo:core`, `pnpm tsgo:extensions`, `pnpm check:test-types`, oxfmt, oxlint, the line-cap ratchet, the mock-exports ratchet and the test-lines ratchet pass. I left broad suites to CI.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 16, 2026
… of being refused (#200102)

## What Problem This Solves

Fixes: listed models are refused before any request when OpenClaw only *guesses* they are not chat models. Examples are an ID that names a non-text family, an OpenAI live/cyber/exp/alpha ID, or an unfamiliar kind value. Other guesses show a model that fails for the listing key, such as `gpt-5.6-cyber`.

## User Impact

- Rows that **declare** non-chat support (native kind, output modality, catalog) are unchanged: hidden and refused before any request.
- Rows that are only **unlikely** chat leave the default picker and setup choices but appear in "all" views. Typed and configured refs to them still run.
- OpenAI default picker on a real listing: wrongly shown 1 → 0, wrongly hidden 3 → 3. Typed `openai/o3` replies while it is absent from the default list.
- Tencent TokenHub: an uncatalogued, unlabeled listed ID (the #198288 TTS case) stays out of the default picker without hiding new chat models from typed refs.

## Why This Change Was Made

#199998 made "no evidence" unknown, but kept an interim rule: an ID that names a non-text family got `chat: false`. This PR separates guesses from declarations:

| state | encoding | default picker / setup | "all", typed, configured | pre-run guard |
|---|---|---|---|---|
| yes / unknown | no `inference`, or `chat: true` | shown | shown, runs | passes |
| unlikely | `inference: { chat: true, chatEvidence: "unlikely" }` | hidden | shown, runs | passes |
| declared no | `inference: { chat: false }` | hidden | hidden | refused (#184996) |

- **Marker:** an optional `chatEvidence` key inside `inference`; `chat` is not widened. Old readers drop it and see plain chat:
  - the 2026.11.5 beta inference schema is a non-strict `z.object`;
  - released stable readers have no `inference` at all (v1/v2 bundles only);
  - the v3 hosted reader drops unknown `inference` keys.
  - The registry runtime model and the v3 row schema accept the key.
  - No wire, protocol, config or cache-scope change. `ModelChoice` is a closed protocol object, so there is no "unverified" badge.
- **Weak evidence** applies only to uncatalogued rows without capability fields:
  - the ID-family pattern;
  - an unfamiliar value in a kind field the same listing uses for chat;
  - a provider prior, set with the new discovery option `unknownModelChatEvidence: "unlikely"`.
- **Surfaces:**
  - The visibility owner (default picker, `models.list`, `/models`) treats unlikely like `deprecated`: listed only in `all`, configured and retained views.
  - The setup picker, oMLX and Bifrost offer likely chat only.
  - The guard still refuses only `chat === false`.
- **OpenAI:**
  - `live|cyber|exp|alpha` IDs are demoted instead of dropped, and the `gpt-5.6-cyber` exception is removed.
  - `search` IDs stay dropped: Responses rejects them with a 400, dated snapshots too.
  - The pre-GPT-5 rule stays (#167462).
- **Tencent:** opts into the prior. Its list has IDs and status only and includes speech models (#198288).
- **Docs:** `model-catalogs.md` and `src/plugins/AGENTS.md` each state the rule once, citing #198288 and #199998. The OpenAI and Tencent provider pages are updated to match.
- **Supersedes #199545:** the name-matched OpenAI IDs are demoted, not revealed, so their 404/500 IDs stay out of the default picker.

## Evidence

**Replay of saved real listings, main `84a378cf` vs this head.** Same truth labels as #199998.

| provider | listed | proven | default picker main / branch | wrongly shown / hidden, main | wrongly shown / hidden, branch |
|---|---|---|---|---|---|
| OpenAI (after account projection) | 125 | 31 | 37 / 36 | 1 / 3 | **0 / 3** |
| HF router + OpenRouter | 600 | 600 | 600 / 600 | 0 / 0 | 0 / 0 |
| Vercel AI Gateway | 508 | 508 | 323 / 323 | 0 / 0 | 0 / 0 |
| DeepInfra | 178 | 178 | 92 / 92 | 0 / 0 | 0 / 0 |
| Venice | 414 | 414 | 142 / 142 | 0 / 0 | 0 / 0 |
| NVIDIA (no proof) | 39 | 0 | 29 / 29 | – | – |
| Ollama library | 24 | 24 | 23 / 23 | 0 / 0 | 0 / 0 |
| models.dev | 9,878 | 9,545 | 9,414 / 9,414 | 0 / 0 | 0 / 0 |

- **OpenAI wrongly hidden (3):** `gpt-4o-mini` and `o3` fall under the pre-GPT-5 rule and run by typed ref. `gpt-5-search-api` is Chat-Completions-only.
- **OpenAI rows refused pre-run:** 46 on main, 0 on this branch. 38 of the 46 are now unlikely; 8 hit the pre-GPT-5 drop.
- **TokenHub:** its authenticated listing is uncaptured, so a fixture of that shape is tested instead.

**Real Gateway (built dist, real OpenAI key).**
- **Setup:** each side ran under `env -i` with only PATH, a temp HOME, TMPDIR, `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH`. The key came through stdin only.
- **Isolation:** loopback, its own port and token, no channels (the harness refuses one). Reads waited for a `ready` live listing.

| | main | branch |
|---|---|---|
| OpenAI rows: default `models list` / `--all --provider openai` | 39 / 39 | 36 / 102 |
| `gpt-5.6-cyber` default / all | shown / shown | absent / shown |
| `gpt-image-2` default / all | absent / absent | absent / shown |
| typed `openai/o3` turn (absent from default on both) | reply `ok` | reply `ok` |
| typed `openai/gpt-image-2` turn | refused pre-run `model_chat_unsupported` | sent; provider 404 |

- **Cleanup:** 0 key hits in outputs and state, both Gateways exited and ports closed. The host Gateway was untouched.
- `models list --provider X` already uses the `all` view (#142063).

**Tests and gates.**
- **New cases** are red on `84a378cf` and green here:
  - the gate table (shown / unlikely / declared no) and the provider prior;
  - visibility: default, `all` and configured views;
  - discovery → prepared snapshot → visibility → `resolveModelAsync`: the bare ID-pattern row passes the pre-run check, and the declared-no pin test still rejects;
  - the setup picker;
  - the OpenAI API-key catalog;
  - a Tencent ID-only listing;
  - an old-reader schema fixture;
  - the v3 reader keeping the marker.
- **Consumer suites updated and green:** live-runtime, OpenCode Zen/Go, oMLX, Bifrost, LiteLLM, Anthropic discovery, Codex cyber-failover, utility model.
- **Typecheck and lint:** `tsgo:core`, `tsgo:extensions`, `check:test-types`, oxlint and oxfmt are clean.
- **Prefix stability:** `agent-tools.prefix-stability.test.ts` passes (14/14).
- **Ratchets:** test lines +178 (allowance 400); line-cap passes.
- **Builds:** `ocx build --dts` and `build:plugin-sdk:strict-smoke` pass on this head.
- **`plugin-sdk:api:diff`:** one changed signature, `ModelInferenceCapabilitiesSchema` (optional `chatEvidence`), digest `47bba3f8`.
- **Size:** production +96 / −40 in 10 files; no new module, state, cache or config.

**Accepted edges (no code)**
- The existing route-change overlay replaces a route-moved row's `inference` with `chat: false`, as it already does for any such row.
- A future `chatEvidence` value would fail this build's schema, so a later state should use a new key.
- Main or nightly state saved under #199998 keeps an ID-pattern row as `chat: false` until rediscovery.

## Merge danger

- **Two-way door:** a revert restores #199998's behavior, and older builds read the marker as plain chat. No migration, config or protocol change.
- **Blast radius if wrong:** listed non-chat models appear in `all` views. A typed ref to one gets the provider error instead of the pre-run refusal.

<!-- openclaw-publication:8af8ed4a-ce4e-471b-9465-c401900ac501 -->

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

## Problem

openclaw#199998 made models that a provider lists without capability metadata visible and runnable. A listed model that is not a chat model, or is not enabled for the account, now fails at its first request instead of being hidden.

Live probes on OpenAI and Google AI Studio show these failures return a 4xx in 0.3–1.0 s. About half of the bodies say the model "does not exist" (404), so OpenClaw reported "This model was not found". That is misleading for a model that the provider itself lists. Others ("not supported with the Responses API", "response modalities", "bidiGenerateContent", "not allowed to sample") ended as a raw request rejection or a sign-in error.

## Solution

Both conditions below must hold:

- The provider answers with a deterministic **400, 403 or 404** that contains one of these phrases: "model … does not exist", "not supported with the Responses API", "not supported for generateContent", "response modalities", "bidiGenerateContent" or "not allowed to sample".
- The **successful listing made with the same credential** (same provider and auth profile) returned that model ID. The check reads the outcome's `listedModelIds` or `modelIdCatalog`.

When both hold, the turn says:

> The provider lists this model but rejected a chat request. It may not be a chat model, or it isn't enabled for this account. Choose another model.

Code changes:

- `live-model-errors.ts`: `isListedModelChatRejection(status, message)`. It sits next to the model-not-found matcher, so the classifier owner stays the same.
- `failover/error.ts` + `user-copy.ts`: code `model_chat_rejected` and its copy. The code is rendered through the existing `renderFailoverCodeUserCopy` path, which every reply surface already uses for `model_chat_unsupported`.
- `provider-catalog-outcome.ts`: `isModelInCredentialListing`, which uses the same credential rule as the account-entitlement check.
- `assistant-failure.ts` + `failover-policy.ts`: the run produces a stateless `format` failure. This failure skips auth refresh, profile rotation, profile cooldown and session-model revert. It also skips the deterministic-format fallback stop, so a configured fallback runs next. Like the deterministic-400 handling from openclaw#198288, there is no retry and no compaction.
- Catalog owners publish their listing: the OpenAI API-key catalog's ready outcome carries `modelIdCatalog`, as the shared OpenAI-compatible live catalog already does. The Google AI Studio catalog's ready outcome carries `listedModelIds`: every ID `models.list` returned, including the non-chat rows its projection hides. Before this, the Google catalog published no listing, so the Google rules could never apply.

These cases stay on their current paths: 5xx, 429, 401/402, timeouts, any 200 (including empty output), and 404s for models that are not in the current listing (the real model-not-found case).

## Impact

- Users see an honest reason and the next configured model runs. Nothing is persisted.
- Side effect: OpenAI API-key users with configured OpenAI model IDs that their listing does not return now get the existing "unlisted configured model" advisory. Other live-listing providers already show it.
- Accepted edge: a turn that is admitted before the first listing of the Gateway's life completes cannot prove listing membership. It keeps the current model-not-found copy. The next turn after discovery uses the new copy.
- Not covered: failures produced inside a plugin-owned harness transport (prompt stage, for example Codex app-server requests). In the real run below, the listed model went through OpenClaw's own transport.

## Evidence

**Regression tests (red on the merge base `6851ad055e6e`, green here).** `assistant-failure.listed-model.test.ts` replays sanitized live bodies through `projectProviderError` → `handleEmbeddedAssistantFailure` → `runWithModelFallback` → reply copy. Model IDs are synthetic, and request IDs and headers are removed. The positive bodies are an OpenAI Responses 404 and 400, an OpenAI Chat 403, and Google generateContent 404, modalities 400 and bidi 400. Each case uses its owner's listing shape: OpenAI `modelIdCatalog`, Google `listedModelIds`.

- On base, all 6 copy cases fail: they show "This model was not found", "Couldn't sign in…" or "LLM request rejected: …".
- On base, the two Google 400 cases also stop the fallback chain.
- Negative fixtures pass on both: 500, 429, 401, an empty 200, and a 404 for a model missing from the listing.
- A unit test checks that only 400/403/404 qualify, and never 200, 401, 402, 408, 429, 500 or 503.
- `extensions/google/provider-registration.test.ts` runs the registered Google catalog against a `models.list` body with a chat row and an `embedContent`-only row. The picker gets only the chat row; the ready outcome lists both IDs under the selected auth profile.

**Real Gateway turn.** I built both sides with `ocx build --dist`. Each Gateway ran isolated under `env -i` with only `PATH`, a temporary `HOME`, `TMPDIR`, `OPENCLAW_STATE_DIR` and `OPENAI_API_KEY`. Each used loopback only, its own port and token, and no channels. The harness refreshed the OpenAI listing through the Gateway, then ran one `openclaw agent` turn on a model that this key's `/v1/models` lists but cannot use. Public listed non-chat IDs such as `text-embedding-3-small` are still refused before the run. Google has no real-Gateway turn; its proof is the two tests above.

| | Reply | Provider requests (`[model-fetch] start POST /v1/responses`) | Decision |
|---|---|---|---|
| merge base `6851ad055e6e` | `This model was not found. Choose another model in the OpenClaw app. \| model_not_found` | 1 (404) | `surface_error reason=model_not_found` |
| this branch | `The provider lists this model but rejected a chat request. It may not be a chat model, or it isn't enabled for this account. \| model_chat_rejected` | 1 (404) | `surface_error reason=format`, no compaction |

The real run used the copy before review added the trailing "Choose another model."; the regression test asserts the final copy.

An exact-key scan of every Gateway log and state directory found 0 hits. All Gateways and ports were confirmed gone afterwards.

**Checks.** Focused tests pass (agents failover, OpenAI catalog, Google registration and catalog). `pnpm tsgo:core`, `pnpm tsgo:extensions`, `pnpm check:test-types`, oxfmt, oxlint, the line-cap ratchet, the mock-exports ratchet and the test-lines ratchet pass. I left broad suites to CI.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
… of being refused (openclaw#200102)

## What Problem This Solves

Fixes: listed models are refused before any request when OpenClaw only *guesses* they are not chat models. Examples are an ID that names a non-text family, an OpenAI live/cyber/exp/alpha ID, or an unfamiliar kind value. Other guesses show a model that fails for the listing key, such as `gpt-5.6-cyber`.

## User Impact

- Rows that **declare** non-chat support (native kind, output modality, catalog) are unchanged: hidden and refused before any request.
- Rows that are only **unlikely** chat leave the default picker and setup choices but appear in "all" views. Typed and configured refs to them still run.
- OpenAI default picker on a real listing: wrongly shown 1 → 0, wrongly hidden 3 → 3. Typed `openai/o3` replies while it is absent from the default list.
- Tencent TokenHub: an uncatalogued, unlabeled listed ID (the openclaw#198288 TTS case) stays out of the default picker without hiding new chat models from typed refs.

## Why This Change Was Made

openclaw#199998 made "no evidence" unknown, but kept an interim rule: an ID that names a non-text family got `chat: false`. This PR separates guesses from declarations:

| state | encoding | default picker / setup | "all", typed, configured | pre-run guard |
|---|---|---|---|---|
| yes / unknown | no `inference`, or `chat: true` | shown | shown, runs | passes |
| unlikely | `inference: { chat: true, chatEvidence: "unlikely" }` | hidden | shown, runs | passes |
| declared no | `inference: { chat: false }` | hidden | hidden | refused (openclaw#184996) |

- **Marker:** an optional `chatEvidence` key inside `inference`; `chat` is not widened. Old readers drop it and see plain chat:
  - the 2026.11.5 beta inference schema is a non-strict `z.object`;
  - released stable readers have no `inference` at all (v1/v2 bundles only);
  - the v3 hosted reader drops unknown `inference` keys.
  - The registry runtime model and the v3 row schema accept the key.
  - No wire, protocol, config or cache-scope change. `ModelChoice` is a closed protocol object, so there is no "unverified" badge.
- **Weak evidence** applies only to uncatalogued rows without capability fields:
  - the ID-family pattern;
  - an unfamiliar value in a kind field the same listing uses for chat;
  - a provider prior, set with the new discovery option `unknownModelChatEvidence: "unlikely"`.
- **Surfaces:**
  - The visibility owner (default picker, `models.list`, `/models`) treats unlikely like `deprecated`: listed only in `all`, configured and retained views.
  - The setup picker, oMLX and Bifrost offer likely chat only.
  - The guard still refuses only `chat === false`.
- **OpenAI:**
  - `live|cyber|exp|alpha` IDs are demoted instead of dropped, and the `gpt-5.6-cyber` exception is removed.
  - `search` IDs stay dropped: Responses rejects them with a 400, dated snapshots too.
  - The pre-GPT-5 rule stays (openclaw#167462).
- **Tencent:** opts into the prior. Its list has IDs and status only and includes speech models (openclaw#198288).
- **Docs:** `model-catalogs.md` and `src/plugins/AGENTS.md` each state the rule once, citing openclaw#198288 and openclaw#199998. The OpenAI and Tencent provider pages are updated to match.
- **Supersedes openclaw#199545:** the name-matched OpenAI IDs are demoted, not revealed, so their 404/500 IDs stay out of the default picker.

## Evidence

**Replay of saved real listings, main `6851ad05` vs this head.** Same truth labels as openclaw#199998.

| provider | listed | proven | default picker main / branch | wrongly shown / hidden, main | wrongly shown / hidden, branch |
|---|---|---|---|---|---|
| OpenAI (after account projection) | 125 | 31 | 37 / 36 | 1 / 3 | **0 / 3** |
| HF router + OpenRouter | 600 | 600 | 600 / 600 | 0 / 0 | 0 / 0 |
| Vercel AI Gateway | 508 | 508 | 323 / 323 | 0 / 0 | 0 / 0 |
| DeepInfra | 178 | 178 | 92 / 92 | 0 / 0 | 0 / 0 |
| Venice | 414 | 414 | 142 / 142 | 0 / 0 | 0 / 0 |
| NVIDIA (no proof) | 39 | 0 | 29 / 29 | – | – |
| Ollama library | 24 | 24 | 23 / 23 | 0 / 0 | 0 / 0 |
| models.dev | 9,878 | 9,545 | 9,414 / 9,414 | 0 / 0 | 0 / 0 |

- **OpenAI wrongly hidden (3):** `gpt-4o-mini` and `o3` fall under the pre-GPT-5 rule and run by typed ref. `gpt-5-search-api` is Chat-Completions-only.
- **OpenAI rows refused pre-run:** 46 on main, 0 on this branch. 38 of the 46 are now unlikely; 8 hit the pre-GPT-5 drop.
- **TokenHub:** its authenticated listing is uncaptured, so a fixture of that shape is tested instead.

**Real Gateway (built dist, real OpenAI key).**
- **Setup:** each side ran under `env -i` with only PATH, a temp HOME, TMPDIR, `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH`. The key came through stdin only.
- **Isolation:** loopback, its own port and token, no channels (the harness refuses one). Reads waited for a `ready` live listing.

| | main | branch |
|---|---|---|
| OpenAI rows: default `models list` / `--all --provider openai` | 39 / 39 | 36 / 102 |
| `gpt-5.6-cyber` default / all | shown / shown | absent / shown |
| `gpt-image-2` default / all | absent / absent | absent / shown |
| typed `openai/o3` turn (absent from default on both) | reply `ok` | reply `ok` |
| typed `openai/gpt-image-2` turn | refused pre-run `model_chat_unsupported` | sent; provider 404 |

- **Cleanup:** 0 key hits in outputs and state, both Gateways exited and ports closed. The host Gateway was untouched.
- `models list --provider X` already uses the `all` view (openclaw#142063).

**Tests and gates.**
- **New cases** are red on `6851ad05` and green here:
  - the gate table (shown / unlikely / declared no) and the provider prior;
  - visibility: default, `all` and configured views;
  - discovery → prepared snapshot → visibility → `resolveModelAsync`: the bare ID-pattern row passes the pre-run check, and the declared-no pin test still rejects;
  - the setup picker;
  - the OpenAI API-key catalog;
  - a Tencent ID-only listing;
  - an old-reader schema fixture;
  - the v3 reader keeping the marker.
- **Consumer suites updated and green:** live-runtime, OpenCode Zen/Go, oMLX, Bifrost, LiteLLM, Anthropic discovery, Codex cyber-failover, utility model.
- **Typecheck and lint:** `tsgo:core`, `tsgo:extensions`, `check:test-types`, oxlint and oxfmt are clean.
- **Prefix stability:** `agent-tools.prefix-stability.test.ts` passes (14/14).
- **Ratchets:** test lines +178 (allowance 400); line-cap passes.
- **Builds:** `ocx build --dts` and `build:plugin-sdk:strict-smoke` pass on this head.
- **`plugin-sdk:api:diff`:** one changed signature, `ModelInferenceCapabilitiesSchema` (optional `chatEvidence`), digest `47bba3f8`.
- **Size:** production +96 / −40 in 10 files; no new module, state, cache or config.

**Accepted edges (no code)**
- The existing route-change overlay replaces a route-moved row's `inference` with `chat: false`, as it already does for any such row.
- A future `chatEvidence` value would fail this build's schema, so a later state should use a new key.
- Main or nightly state saved under openclaw#199998 keeps an ID-pattern row as `chat: false` until rediscovery.

## Merge danger

- **Two-way door:** a revert restores openclaw#199998's behavior, and older builds read the marker as plain chat. No migration, config or protocol change.
- **Blast radius if wrong:** listed non-chat models appear in `all` views. A typed ref to one gets the provider error instead of the pre-run refusal.

<!-- openclaw-publication:8af8ed4a-ce4e-471b-9465-c401900ac501 -->

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

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: litellm extensions: omlx extensions: opencode extensions: opencode-go merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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