Skip to content

fix(models): one failed provider discovery hides its models until a manual refresh - #167230

Merged
obviyus merged 3 commits into
mainfrom
fix/failed-discovery-retry
Oct 8, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/failed-discovery-retry

Conversation

@obviyus

@obviyus obviyus commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: when a provider's model discovery fails once (for example an OpenRouter timeout), the Gateway falls back to that provider's few built-in rows (OpenRouter 466 → 3) and keeps them until someone runs an explicit models refresh.

User Impact

A transient provider outage no longer hides most of that provider's models for the life of the Gateway. The failed provider retries discovery in the background and its full model list comes back on its own once the provider is reachable.

Why This Change Was Made

Failed discovery recorded no renewal deadline, and ordinary models.list reads intentionally no longer renew inventory (#167008), so nothing ever retried it. A failed provider now gets a backed-off retry deadline (30 s, doubling to a 30 min cap) on its retained inventory facts. The catalog owner keeps one timer for the earliest deadline, re-armed after each acquisition settles and cancelled when the catalog generation retires. Reads stay passive; a successful retry publishes the full rows and returns the provider to its normal cache deadline. A compatible reload keeps the failure facts and resumes the retry.

Evidence

  • Regression tests in prepared-model-runtime.catalog-owner.test.ts: discovery fails, then recovers with backoff and no read or refresh (fails on main: the worker is never called again); and a new failure episode is measured from its own failure.
  • Live isolated Gateway with real OpenRouter discovery and a DNS-delay preload: OpenRouter discovery failed at startup and showed 3 built-in rows with refreshFailed. Background retries ran at the expected backoff (lookups at 12:17:38, 12:18:13, 12:19:19, 12:21:24, 12:25:29 UTC). After the network recovered at 12:29:40, passive models.list polling (no refresh) showed OpenRouter go from 3 to 466 rows at 12:33:35, on the next scheduled retry. OpenRouter's outcome is now ready.
  • Focused prepared-catalog and models-list suites pass. Two models-auth-*.catalog.integration tests also fail on an unmodified main checkout locally.
  • Test cost: pnpm exec vitest run src/agents/prepared-model-runtime.catalog-owner.test.ts takes 8.2 s wall time locally (19 tests; Vitest duration 4.2 s). The two new cases use fake timers and add about 0.4 s of CI test time.

@clawsweeper

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

@obviyus
obviyus marked this pull request as ready for review October 8, 2026 12:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 8, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 8:57 AM ET / 12:57 UTC (Revision 2).

ClawSweeper review

What this changes

The Gateway automatically retries failed provider model discovery with capped exponential backoff while ordinary model-list reads remain passive.

Example: The user opens the model list after an OpenRouter discovery timeout.

  • Before: OpenRouter remains at 3 built-in models until an explicit refresh or another catalog lifecycle change.
  • After: Background discovery restores 466 models after connectivity recovers, without an explicit refresh.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with convincing real outage recovery evidence and no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The recorded isolated Gateway run exercises the changed catalog owner through real OpenRouter discovery under injected DNS delay, then observes passive models.list recovery from 3 to 466 rows with ready status. Retry facts are process-local and introduce no stored-data contract change.
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 transient provider outage can hide most model choices until the user manually refreshes the catalog.
Reason: Automatic recovery has clear value and stays within the established catalog owner. The author’s prior merged area work supports the direction, and the intentional passive-read contract remains intact.

Merge readiness

✅ Ready for maintainer review

This PR addresses a recovery gap still present on current main, has sufficient real Gateway proof, and has no actionable review findings. The previous review’s test-cost request is satisfied.

Priority: P2
Reviewed head: 0be8d0c79951040c76726fcd22b8b4adc427a4f2

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway’s model catalog supplies model choices to the CLI, chat commands, and app pickers. Its lifecycle owner acquires provider inventory and publishes completed results while retaining compatible choices through failures.

flowchart TD
  A[Provider discovery] --> B{Discovery succeeds?}
  B -->|Yes| C[Publish model inventory]
  B -->|No| D[Retain saved or built-in models]
  D --> E[Owner schedules backed-off retry]
  E --> A
  C --> F[Passive model-list reads]
  D --> F
  G[Generation retires] -->|Cancel timer| E
Loading

Technical review

Best possible solution:

Keep failure recovery in the existing catalog owner, preserving passive reads, compatible inventory retention, and generation-scoped cancellation.

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

Yes: current source leaves failed discovery without a renewal deadline while model-list reads stay passive, and the contributor reports a failing owner regression and real OpenRouter outage recovery. This read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Yes: scoped retries repair acquisition recovery at its existing owner without restoring request-triggered discovery or adding configuration.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point. Added test files: 1.

Security

None.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Source +98, Tests +67, Docs +2. Total +167 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 113 15 +98
Tests 1 67 0 +67
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 183 16 +167

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A transient provider outage can leave most model choices missing indefinitely, while retained choices and explicit refresh limit the immediate blast radius.
  • 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 (1 earlier review cycle)
  • reviewed 2026-10-08T12:46:26.925Z sha 0be8d0c :: needs changes before merge. :: none

@obviyus

obviyus commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit eea11f9 into main Oct 8, 2026
205 of 212 checks passed
@obviyus
obviyus deleted the fix/failed-discovery-retry branch October 8, 2026 13:34
@obviyus

obviyus commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in eea11f9. If a provider's discovery failed once, it used to stay on its built-in rows until someone ran a manual refresh. Now the failed provider retries in the background (30 s, then doubling up to 30 min) without making reads renew anything. Proof: in an isolated live Gateway, OpenRouter went from 3 to 466 rows on its own after the network recovered, with no refresh. A regression test also covers this and fails on the old code.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…anual refresh (openclaw#167230)

## What Problem This Solves

Fixes: when a provider's model discovery fails once (for example an OpenRouter timeout), the Gateway falls back to that provider's few built-in rows (OpenRouter 466 → 3) and keeps them until someone runs an explicit `models refresh`.

## User Impact

A transient provider outage no longer hides most of that provider's models for the life of the Gateway. The failed provider retries discovery in the background and its full model list comes back on its own once the provider is reachable.

## Why This Change Was Made

Failed discovery recorded no renewal deadline, and ordinary `models.list` reads intentionally no longer renew inventory (openclaw#167008), so nothing ever retried it. A failed provider now gets a backed-off retry deadline (30 s, doubling to a 30 min cap) on its retained inventory facts. The catalog owner keeps one timer for the earliest deadline, re-armed after each acquisition settles and cancelled when the catalog generation retires. Reads stay passive; a successful retry publishes the full rows and returns the provider to its normal cache deadline. A compatible reload keeps the failure facts and resumes the retry.

## Evidence

- Regression tests in `prepared-model-runtime.catalog-owner.test.ts`: discovery fails, then recovers with backoff and no read or refresh (fails on `main`: the worker is never called again); and a new failure episode is measured from its own failure.
- Live isolated Gateway with real OpenRouter discovery and a DNS-delay preload: OpenRouter discovery failed at startup and showed 3 built-in rows with `refreshFailed`. Background retries ran at the expected backoff (lookups at 12:17:38, 12:18:13, 12:19:19, 12:21:24, 12:25:29 UTC). After the network recovered at 12:29:40, passive `models.list` polling (no refresh) showed OpenRouter go from 3 to 466 rows at 12:33:35, on the next scheduled retry. OpenRouter's outcome is now `ready`.
- Focused prepared-catalog and models-list suites pass. Two `models-auth-*.catalog.integration` tests also fail on an unmodified `main` checkout locally.
- Test cost: `pnpm exec vitest run src/agents/prepared-model-runtime.catalog-owner.test.ts` takes 8.2 s wall time locally (19 tests; Vitest duration 4.2 s). The two new cases use fake timers and add about 0.4 s of CI test time.

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 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: S 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