Skip to content

fix(models): isolate every per-provider catalog failure - #189059

Merged
obviyus merged 4 commits into
mainfrom
fix/models-list-provider-isolation
Oct 31, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/models-list-provider-isolation

Conversation

@obviyus

@obviyus obviyus commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Model catalog preparation calls plugin hooks one provider at a time. In three of those steps, any throw from one provider failed the whole models.list request, so no models came back for any provider:

  • ambient credential discovery (synthetic auth hooks)
  • the static provider catalog
  • catalog augment hooks

#189014 fixed one error shape (a missing plugin-owned credential) in the first step only. Any other error from any provider still emptied the model list, for example when someone adds a new provider.

Live provider discovery already followed the right rule: catch per provider, report it unavailable and continue. That rule lived only in that one catch block.

Fix

  • New src/agents/provider-failure-isolation.ts owns the rule. A per-provider failure marks only that provider unavailable, logs a warning naming the step and provider, and continues. Only request-wide failures propagate: a cancelled request signal, plugin lifecycle retirement (isPreparedModelRuntimePluginLifecycleFailure, which the prepared runtime owner retries as a superseded publication) and an unresolved config secret.
  • A failed static catalog stays distinguishable from an empty one: the prepared static entry is marked failed, and implicit discovery reports unavailable for every selected identity of that hook (for example family-plan of a shared family hook) instead of publishing empty configs. Publication then keeps those providers' previous models as a refresh failure (already covered by "retains only same-account inventory after failure"). Implicit discovery's own static fallback run uses the same isolation and identities.
  • All four per-provider steps use it: both ambient discovery loops (replacing fix(models): keep the model list when one plugin-owned provider lacks a credential #189014's narrow matcher), the static catalog loop, catalog augment and live implicit discovery (its catch now calls the shared rule and keeps the profile-scoped secret outcome).
  • Catalog augment moved with its hook-provider resolver from provider-runtime.ts to provider-catalog-augment.ts, so that file drops under its line cap; the stale max-lines baseline entry is pruned. provider-runtime.ts re-exports the function, so the SDK surface is unchanged.
  • The plugin lifecycle errors and their check moved into the leaf prepared-model-runtime-admission-errors.ts (which already holds their base class) to avoid an import cycle; prepared-model-runtime.errors.ts re-exports them, so callers are unchanged.

Behavior notes:

  • Live discovery now propagates plugin lifecycle retirement instead of reporting the provider unavailable. The owner already turns that into a superseded publication and retries.
  • A provider skipped in ambient discovery still shows its models as missing-auth through catalog availability. Each skip logs one warning per catalog build.

User impact

One broken, misconfigured or brand-new provider can no longer empty the model picker and Models page. Its own models show as unavailable and every other provider still lists.

Proof

  • New regressions, each failing on main with the provider's error and passing here:
    • ambient discovery (sync and async): a throwing hook for one provider keeps the sibling's credential; a cancelled signal still rejects.
    • static catalog: a throwing catalog keeps the healthy provider's config; a cancelled signal still rejects.
    • implicit discovery, with and without a prepared static catalog: a throwing static catalog reports { provider, status: "unavailable" } and the healthy provider still lists; a shared hook refreshed for only family-plan reports family-plan, not family (fails on the prior head with family).
    • catalog augment: a throwing hook keeps the other provider's rows.
  • 13 related suites pass, including plugin-scope auth, implicit discovery outcomes and scope, model catalog, models.list provider outcomes, prepared runtime sources and the catalog worker pool.
  • pnpm check:changed passes (typecheck, lint, import cycles, line-cap and max-lines ratchets); pnpm check:madge-import-cycles reports 0 cycles.

No overlap with Pash/Sarah changes.

Merge danger

Two-way door: a revert fully undoes it. No state, config or public contract change. Blast radius: model catalog preparation and models.list for every install.

@clawsweeper

clawsweeper Bot commented Oct 31, 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.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: c41e94f05a53c44113b5e876a1b43e43b45ae6b8
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/agent-auth-discovery.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR isolates provider hook failures so healthy providers remain visible in the model catalog.

Example: The static catalog hook serving family-plan throws while healthy supplies healthy-model.

  • Before: Catalog preparation rejects and healthy-model is absent from the returned list.
  • After: healthy-model remains available, and family-plan receives an unavailable outcome.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch resolves prior defects and passes current-head CI, while behavior evidence remains at the in-process test boundary.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises production functions with injected hooks and green CI, without a shipped-entry-point demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: One failing provider can hide healthy providers from the model picker and Models page.
Reason: Provider isolation matches the existing catalog contract, and the maintainer-authored PR establishes direction without adding settings or changing stored formats.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current catalog failure path and resolves both earlier review findings; no new actionable defect was found.

Priority: P2
Reviewed head: c41e94f05a53c44113b5e876a1b43e43b45ae6b8

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied Gateway or CLI models.list trace demonstrates healthy-provider survival through the changed hook failures; red/green regression results are author-reported.
Agent review details

How this fits together

The prepared model runtime combines provider credentials, static catalogs, live discovery, and supplemental rows into snapshots consumed by models.list and model pickers.

flowchart TD
  A[Provider plugins] --> B[Credential preparation]
  A --> C[Static and live catalogs]
  A --> D[Catalog augmentation]
  B --> E[Provider failure isolation]
  C --> E
  D --> E
  E --> F[Prepared catalog publication]
  F --> G[Models list and pickers]
Loading

Technical review

Best possible solution:

Use one provider-failure policy while preserving selected identities, existing inventory retention, and request-wide failure propagation.

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

Current main allows generic synthetic-auth, static-catalog, and augmentation hook exceptions to escape catalog preparation; source inspection establishes the path without executing target code.

Is this the best way to solve the issue?

The shared classifier is a proportionate fix, and the extracted augmentation code preserves its existing SDK export and selection behavior.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Ambient credential failures changes intended behavior with a stated reason (1b15408: The previous repair skipped only missing plugin-owned credentials while allowing other errors to propagate.)
  • Static catalog preparation keeps the original intent (a67ad03: Lifecycle preparation captures sterile catalogs once for reuse instead of repeating discovery on request paths.)
  • Live discovery outcomes keeps the original intent (f45297b: Unavailable outcomes preserve compatible inventory after refresh failures; unresolved secrets remain request-wide failures.)
  • Catalog augmentation changes intended behavior with a stated reason (b54e37c: Provider augmentation collected supplemental rows while consolidating vendor behavior behind plugin hooks; this PR explains adding per-hook containment.)
  • Lifecycle error identity keeps the original intent (f2d7a0d: Typed lifecycle failures allow publication recovery to distinguish superseded plugin generations; moving the definitions preserves their identity through re-exports.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 030003c adds src/plugins/provider-discovery.ts:204 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 030003c127f8; files: src/plugins/provider-discovery.ts)
  • Peter Steinberger: Raw commit 2640154 adds src/agents/agent-auth-discovery.ts:109 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2640154bcf80; files: src/agents/agent-auth-discovery.ts)
  • Jason (Json): Raw commit a67ad03 adds src/plugins/provider-discovery.ts:194 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: a67ad03eea4b; files: src/plugins/provider-discovery.ts)

PR surface

Source +102, Tests +194, Other -1. Total +295 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 230 128 +102
Tests 4 196 2 +194
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 13 426 131 +295

Review metrics

Metric Value Why it matters
Production versus tests Production +230/−128 lines; tests +196/−2 lines Growth supplies shared containment and failure-state propagation, with focused coverage of sibling survival, cancellation, and scoped identities.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Provider hook failures can suppress healthy model choices; the repair is focused and no urgent release-wide incident is established.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • A redacted Gateway models.list trace showing one throwing provider, a healthy sibling, and retained family-plan inventory would strengthen confidence.

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 (2 earlier review cycles)
  • reviewed 2026-10-31T05:46:21.428Z sha e7cd643 :: needs changes before merge. :: [P2] Carry static-catalog failures into publication outcomes
  • reviewed 2026-10-31T06:27:19.190Z sha 928a3d3 :: needs changes before merge. :: [P2] Report static failures for the selected family identities

Reviewed October 31, 2026, 3:06 AM ET / 07:06 UTC (Revision 3).

@obviyus

obviyus commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@obviyus

obviyus commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@obviyus
obviyus merged commit 0588f51 into main Oct 31, 2026
170 of 171 checks passed
@obviyus
obviyus deleted the fix/models-list-provider-isolation branch October 31, 2026 07:08
@obviyus

obviyus commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 0588f51. Every per-provider catalog step (synthetic auth discovery, static catalog, catalog augment, live discovery) now uses one isolation rule: a failing provider becomes unavailable and the rest of the list loads; only request cancellation, plugin lifecycle retirement and unresolved config secrets fail the request. Failed static catalogs report every selected identity so publication keeps prior models. Thanks ClawSweeper for the two static-outcome catches.

obviyus added a commit that referenced this pull request Oct 31, 2026
…189184)

## Problem

A plugin-owned provider (`authScope: "plugin"`, for example TypeSafe) was missing from the model list on a live install, and its catalog refresh logged `Plugin-owned auth for provider "typesafe" is unavailable: live credential or no-auth evidence is missing` after nearly every Gateway start since Oct 28.

Ambient credential discovery asked every synthetic-auth provider for a credential, including plugin-owned ones. A plugin-owned credential is instance-bound: `getPreparedPluginSecretInput` returns it only inside the owning plugin's Gateway request scope with live instance authority. The prepared model catalog worker builds ambient credentials in a worker thread (`prepared-model-catalog.worker.ts`), where that scope never exists, so the lookup always failed there. Where it did succeed on the main thread, the plugin's key went into the ambient credential map, which is a transferable discovery fact. `provider-runtime.ts` already forbids this for external synthetic auth: "Instance-owned credentials cannot become transferable worker bearer facts."

Before #189059 this failure emptied the whole `models.list`. Since #189059 the provider is skipped, with a warning on every catalog build.

## Fix

Ambient discovery skips providers whose auth scope is `plugin`, so it never calls their auth hook and never stores their key. The scope check runs inside the existing per-provider isolation (#189059), so an ownership lookup error (for example conflicting static credential owners) skips only that provider. Catalog availability already resolves plugin-owned credentials per model inside the owner's scope (`model-catalog-decisions.ts`), so these providers' models still show as available when their credential is live.

## User impact

Plugin-owned providers no longer fail catalog refreshes or produce warnings at Gateway start. Their keys stay inside the plugin's scope.

## Authority chain

Dispatch does not read ambient discovery credentials: runtime auth (`runtime-plan/prepare-auth.ts`) resolves plugin-owned credentials through the owning instance at run time. The existing `src/agents/model-auth.plugin-scope.test.ts` contracts, all passing on this head, cover each link:

- authorized dispatch: "plans plugin-owned auth before agent stores, configured bindings and cooldowns"
- foreign owner: "rejects hook/secret authority replacement during auth", "refuses static/runtime scope mismatch"
- revocation after preparation, before provider I/O: "invalidates catalog readiness on revocation", "refuses revoked protected secret input rather than reusing a prior bearer", "retains credential authority through an awaited exchange (revoked during exchange: true)", "does not read a live credential after preparation is cancelled"

The new regression also checks that, with ambient discovery skipping the provider, the owner path still resolves the live credential inside the plugin's scope.

## Production-path trace

Run on head `42977e4a1d2` and repeated with `main`'s `agent-auth-discovery.ts`; behavior is identical, which is the point: ambient discovery never fed dispatch.

Path: the real `extensions/typesafe` plugin loaded from `plugins.load.paths` (`loadAndActivateRootPluginRegistry`), catalog preparation through `acquireAgentRunPreparedModelRuntime` with runtime plugins (the path where ambient discovery runs), then a consumer plugin calling `api.runtime.decisions.evaluateV2`, which uses TypeSafe's plugin-owned auth and transport to send real HTTP to a loopback fake TypeSafe server. TypeSafe is decision-only (`chat: false`), so an agent chat turn cannot reach its provider I/O; this is the narrowest real path that does. Synthetic keys only.

1. Owner dispatch: catalog has `typesafe/kev-latest`; outcome `ok`; provider requests `[{"path":"/v1/systemone","authorization":"Bearer <synthetic-typesafe-key>"}]`.
2. Foreign owner: a second plugin registering `typesafe` is rejected at load (`provider already registered: typesafe`); registered owners stay `["typesafe"]`; zero requests carry the impostor's key.
3. Revocation after preparation, without re-preparing: after a key rotation republish, zero requests use the old prepared key and the next request uses the rotated key; with `plugins.entries.typesafe.enabled=false` the outcome is `unavailable (disabled)` and zero new provider requests are made.

Not covered by this trace: a replaced live instance during an awaited exchange (covered by "retains credential authority through an awaited exchange" above), and the hosted `plugins.entries.typesafe.config.apiKey` route, which targets the public hosted endpoint and cannot point at a loopback server.

## Proof

- `src/agents/model-auth.plugin-scope.test.ts` regression, with and without a live prepared credential: ambient discovery (sync and async) does not include the plugin-owned provider and never calls its auth hook. On `main` both cases fail: the hook runs, and with a live credential the plugin's key ends up in the ambient map.
- Regression: a provider with conflicting static auth-scope owners next to a healthy sibling. Both ambient APIs keep the sibling's credential. Fails on the previous head with `conflicting static credential owners`.
- Related suites pass: plugin-scope auth (36), discovery auth, external CLI discovery, synthetic auth discovery, prepared runtime sources, catalog worker pool, implicit discovery outcomes, `models.list` provider outcomes.
- `pnpm check:changed` passes. `pnpm check:madge-import-cycles` reports 0 cycles.
- Live evidence: Team server Gateway logs show this refresh failure after starts on Oct 28, 29, 30 and 31, with no config change to the TypeSafe plugin entry or secrets between a working and a failing start.

No overlap with Pash/Sarah changes.

## Merge danger

Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: model catalog discovery for installs with plugin-owned providers.

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

## Problem

Model catalog preparation calls plugin hooks one provider at a time. In three of those steps, any throw from one provider failed the whole `models.list` request, so no models came back for any provider:

- ambient credential discovery (synthetic auth hooks)
- the static provider catalog
- catalog augment hooks

openclaw#189014 fixed one error shape (a missing plugin-owned credential) in the first step only. Any other error from any provider still emptied the model list, for example when someone adds a new provider.

Live provider discovery already followed the right rule: catch per provider, report it `unavailable` and continue. That rule lived only in that one catch block.

## Fix

- New `src/agents/provider-failure-isolation.ts` owns the rule. A per-provider failure marks only that provider unavailable, logs a warning naming the step and provider, and continues. Only request-wide failures propagate: a cancelled request signal, plugin lifecycle retirement (`isPreparedModelRuntimePluginLifecycleFailure`, which the prepared runtime owner retries as a superseded publication) and an unresolved config secret.
- A failed static catalog stays distinguishable from an empty one: the prepared static entry is marked `failed`, and implicit discovery reports `unavailable` for every selected identity of that hook (for example `family-plan` of a shared `family` hook) instead of publishing empty configs. Publication then keeps those providers' previous models as a refresh failure (already covered by "retains only same-account inventory after failure"). Implicit discovery's own static fallback run uses the same isolation and identities.
- All four per-provider steps use it: both ambient discovery loops (replacing openclaw#189014's narrow matcher), the static catalog loop, catalog augment and live implicit discovery (its catch now calls the shared rule and keeps the profile-scoped secret outcome).
- Catalog augment moved with its hook-provider resolver from `provider-runtime.ts` to `provider-catalog-augment.ts`, so that file drops under its line cap; the stale max-lines baseline entry is pruned. `provider-runtime.ts` re-exports the function, so the SDK surface is unchanged.
- The plugin lifecycle errors and their check moved into the leaf `prepared-model-runtime-admission-errors.ts` (which already holds their base class) to avoid an import cycle; `prepared-model-runtime.errors.ts` re-exports them, so callers are unchanged.

Behavior notes:

- Live discovery now propagates plugin lifecycle retirement instead of reporting the provider unavailable. The owner already turns that into a superseded publication and retries.
- A provider skipped in ambient discovery still shows its models as `missing-auth` through catalog availability. Each skip logs one warning per catalog build.

## User impact

One broken, misconfigured or brand-new provider can no longer empty the model picker and Models page. Its own models show as unavailable and every other provider still lists.

## Proof

- New regressions, each failing on `main` with the provider's error and passing here:
  - ambient discovery (sync and async): a throwing hook for one provider keeps the sibling's credential; a cancelled signal still rejects.
  - static catalog: a throwing catalog keeps the healthy provider's config; a cancelled signal still rejects.
  - implicit discovery, with and without a prepared static catalog: a throwing static catalog reports `{ provider, status: "unavailable" }` and the healthy provider still lists; a shared hook refreshed for only `family-plan` reports `family-plan`, not `family` (fails on the prior head with `family`).
  - catalog augment: a throwing hook keeps the other provider's rows.
- 13 related suites pass, including plugin-scope auth, implicit discovery outcomes and scope, model catalog, `models.list` provider outcomes, prepared runtime sources and the catalog worker pool.
- `pnpm check:changed` passes (typecheck, lint, import cycles, line-cap and max-lines ratchets); `pnpm check:madge-import-cycles` reports 0 cycles.

No overlap with Pash/Sarah changes.

## Merge danger

Two-way door: a revert fully undoes it. No state, config or public contract change. Blast radius: model catalog preparation and `models.list` for every install.

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

## Problem

A plugin-owned provider (`authScope: "plugin"`, for example TypeSafe) was missing from the model list on a live install, and its catalog refresh logged `Plugin-owned auth for provider "typesafe" is unavailable: live credential or no-auth evidence is missing` after nearly every Gateway start since Oct 28.

Ambient credential discovery asked every synthetic-auth provider for a credential, including plugin-owned ones. A plugin-owned credential is instance-bound: `getPreparedPluginSecretInput` returns it only inside the owning plugin's Gateway request scope with live instance authority. The prepared model catalog worker builds ambient credentials in a worker thread (`prepared-model-catalog.worker.ts`), where that scope never exists, so the lookup always failed there. Where it did succeed on the main thread, the plugin's key went into the ambient credential map, which is a transferable discovery fact. `provider-runtime.ts` already forbids this for external synthetic auth: "Instance-owned credentials cannot become transferable worker bearer facts."

Before openclaw#189059 this failure emptied the whole `models.list`. Since openclaw#189059 the provider is skipped, with a warning on every catalog build.

## Fix

Ambient discovery skips providers whose auth scope is `plugin`, so it never calls their auth hook and never stores their key. The scope check runs inside the existing per-provider isolation (openclaw#189059), so an ownership lookup error (for example conflicting static credential owners) skips only that provider. Catalog availability already resolves plugin-owned credentials per model inside the owner's scope (`model-catalog-decisions.ts`), so these providers' models still show as available when their credential is live.

## User impact

Plugin-owned providers no longer fail catalog refreshes or produce warnings at Gateway start. Their keys stay inside the plugin's scope.

## Authority chain

Dispatch does not read ambient discovery credentials: runtime auth (`runtime-plan/prepare-auth.ts`) resolves plugin-owned credentials through the owning instance at run time. The existing `src/agents/model-auth.plugin-scope.test.ts` contracts, all passing on this head, cover each link:

- authorized dispatch: "plans plugin-owned auth before agent stores, configured bindings and cooldowns"
- foreign owner: "rejects hook/secret authority replacement during auth", "refuses static/runtime scope mismatch"
- revocation after preparation, before provider I/O: "invalidates catalog readiness on revocation", "refuses revoked protected secret input rather than reusing a prior bearer", "retains credential authority through an awaited exchange (revoked during exchange: true)", "does not read a live credential after preparation is cancelled"

The new regression also checks that, with ambient discovery skipping the provider, the owner path still resolves the live credential inside the plugin's scope.

## Production-path trace

Run on head `42977e4a1d2` and repeated with `main`'s `agent-auth-discovery.ts`; behavior is identical, which is the point: ambient discovery never fed dispatch.

Path: the real `extensions/typesafe` plugin loaded from `plugins.load.paths` (`loadAndActivateRootPluginRegistry`), catalog preparation through `acquireAgentRunPreparedModelRuntime` with runtime plugins (the path where ambient discovery runs), then a consumer plugin calling `api.runtime.decisions.evaluateV2`, which uses TypeSafe's plugin-owned auth and transport to send real HTTP to a loopback fake TypeSafe server. TypeSafe is decision-only (`chat: false`), so an agent chat turn cannot reach its provider I/O; this is the narrowest real path that does. Synthetic keys only.

1. Owner dispatch: catalog has `typesafe/kev-latest`; outcome `ok`; provider requests `[{"path":"/v1/systemone","authorization":"Bearer <synthetic-typesafe-key>"}]`.
2. Foreign owner: a second plugin registering `typesafe` is rejected at load (`provider already registered: typesafe`); registered owners stay `["typesafe"]`; zero requests carry the impostor's key.
3. Revocation after preparation, without re-preparing: after a key rotation republish, zero requests use the old prepared key and the next request uses the rotated key; with `plugins.entries.typesafe.enabled=false` the outcome is `unavailable (disabled)` and zero new provider requests are made.

Not covered by this trace: a replaced live instance during an awaited exchange (covered by "retains credential authority through an awaited exchange" above), and the hosted `plugins.entries.typesafe.config.apiKey` route, which targets the public hosted endpoint and cannot point at a loopback server.

## Proof

- `src/agents/model-auth.plugin-scope.test.ts` regression, with and without a live prepared credential: ambient discovery (sync and async) does not include the plugin-owned provider and never calls its auth hook. On `main` both cases fail: the hook runs, and with a live credential the plugin's key ends up in the ambient map.
- Regression: a provider with conflicting static auth-scope owners next to a healthy sibling. Both ambient APIs keep the sibling's credential. Fails on the previous head with `conflicting static credential owners`.
- Related suites pass: plugin-scope auth (36), discovery auth, external CLI discovery, synthetic auth discovery, prepared runtime sources, catalog worker pool, implicit discovery outcomes, `models.list` provider outcomes.
- `pnpm check:changed` passes. `pnpm check:madge-import-cycles` reports 0 cycles.
- Live evidence: Team server Gateway logs show this refresh failure after starts on Oct 28, 29, 30 and 31, with no config change to the TypeSafe plugin entry or secrets between a working and a failing start.

No overlap with Pash/Sarah changes.

## Merge danger

Two-way door: a revert fully undoes it. No state, config or contract change. Blast radius: model catalog discovery for installs with plugin-owned providers.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot added a commit that referenced this pull request Nov 5, 2026
Backport accepted fixes onto 2026.11.5-beta.2.

Base: bc061f9
Canonical source tree before commit: e6c0c39

These are adapted/squashed backports; do not claim each is an exact Git cherry-pick.
Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests):

runtime-B:
b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468)
c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713)
6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495)
8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436)
00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827)
c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865)
e72b356 fix(anthropic): avoid token profile collisions (#187875)
807075d fix(anthropic): set API workspace at login (#186976)
bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729)
9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919)
6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909)
4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979)
de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432)
e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271)

provider-compaction:
1b43c2e fix(compaction): preserve active request provenance (#180214)
7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561)
9039ceb fix(ci): keep compaction attribution helpers internal
d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395)
fe0f8d1 fix(google): Gemini models ignore configured topP (#190695)

history:
c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690)
3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450)
b195f61 fix(sessions): page oversized transcript history in both directions (#188483)
b65482e fix(gateway): preserve older history across hidden message gaps (#188557)
3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284)
33e7baf fix(sessions): bound active accounting without blocking writers (#190182)
682ade7 fix: preserve chat history continuation metadata (#188612)

runtime-C:
7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734)
15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664)
b53a06b perf(update): read candidate state inventory without copying the shared database (#187921)
970fc4e fix: restore CLI message sends with agent tool policies (#188058)
73ad731 fix: stop model fallback when session capability metadata changes (#179312)
32305db fix: subagent turns fail after session metadata changes (#183501)
d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005)
e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982)
9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434)

direct-auth-state:
1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014)
7d8dc60 fix: recover startup migration with retained worker index (#189023)

capacity:
41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727)

command-once-189369:
8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369)

pg-board-189564:
7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564)

queued-edit-189869:
92b32ca fix: hold queued messages through inline edits (#189869)

Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line.
Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json.
No held136/native82 content adopted by this work. No release or full-candidate qualification claim.

Additional original-source identities (exact adapted hunk scope is in frozen artifacts):
release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258)
UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372)
obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203)
webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778)
schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391)
backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976)
canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846)
matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272)
provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059)
unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868)
replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672)

Co-authored-by: RomneyDa <[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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: L 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