Skip to content

2026.6.1: agent_model_catalogs / model_capability_cache tables defined but never written; models list takes 25–53s #90368

Closed

Description

@xdemocle

Summary

In 2026.6.1, two new SQLite tables (agent_model_catalogs, model_capability_cache) are created by the state-db migration but no producer code in the shipped dist/ build ever writes to them. As a result openclaw models list falls back to live per-provider fetches on every call.

Measured on Linux, 2026.6.1 (2e08f0f), warm gateway:

command time
openclaw models status 2.9 s (baseline: CLI + config load)
openclaw models list (configured providers only) 25.7 s
openclaw models list --all 53.0 s

Repeated calls don't speed up — there's no persisted catalog cache.

Evidence

Schema is present:

$ grep -nE "agent_model_catalogs|model_capability_cache" dist/openclaw-state-db-*.js
536:CREATE TABLE IF NOT EXISTS model_capability_cache (
554:CREATE INDEX IF NOT EXISTS idx_model_capability_cache_provider_updated ON model_capability_cache(...)
557:CREATE TABLE IF NOT EXISTS agent_model_catalogs (
564:CREATE INDEX IF NOT EXISTS idx_agent_model_catalogs_agent_dir ON agent_model_catalogs(...)

No producer anywhere in dist/:

$ grep -rnE 'INSERT INTO (agent_model_catalogs|model_capability_cache)' dist/
(no matches)
$ grep -rnE '"agent_model_catalogs"|'\''agent_model_catalogs'\''|`agent_model_catalogs`' dist/
(no matches)
$ grep -rnE '"model_capability_cache"|'\''model_capability_cache'\''|`model_capability_cache`' dist/
(no matches)

Both tables stay at 0 rows across restarts, after openclaw plugins registry --refresh, and after invoking models list --all.

(The OpenRouter capability cache under plugin_state_entries / core:openrouter-model-capabilities namespace models.v3 is wired correctly via createCorePluginStateSyncKeyedStore in provider-stream-*.js. That's a different, working path. The two new tables look like a separate planned cache whose writer didn't ship.)

Repro

  1. Fresh-start gateway on 2026.6.1.
  2. sqlite3 ~/.openclaw/state/openclaw.sqlite "SELECT COUNT(*) FROM agent_model_catalogs; SELECT COUNT(*) FROM model_capability_cache;" → both 0.
  3. time openclaw models list --all → ~50 s on first call.
  4. Re-run step 2 → still both 0.
  5. Re-run step 3 → still ~50 s; no caching benefit.

Expected

After the first models list --all, subsequent calls should hit the new SQLite tables and complete in well under 1 s.

Environment

  • OpenClaw 2026.6.1 (2e08f0f)
  • Linux (kernel 5.15)
  • Node 24.15.0
  • Providers configured: minimax, anthropic, mistral (no OpenRouter)

Notes

Also noticed (likely separate, happy to file separately if useful):

  • [state-migrations] Legacy state migration warnings: Left plugin install index in place because shared SQLite state has conflicting plugin install metadata for: acpx, brave, diffs, memory-lancedb
    Triggered by version drift between ~/.openclaw/plugins/installs.json (legacy) and installed_plugin_index in ~/.openclaw/state/openclaw.sqlite. openclaw plugins registry --refresh only rebuilds SQLite, leaving the legacy file out of sync — so the warning fires on every restart until the legacy file is removed.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 4, 2026, 10:44 AM ET / 14:44 UTC.

    Summary
    Keep open: current main still has the two SQLite tables only in schema/types/docs, while the models list path still reads generated models.json/static metadata and can call provider catalog loaders instead of a persisted SQL catalog cache.

    Reproducibility: no. high-confidence live reproduction was run in this read-only review. The source path is reproducible enough for triage because current main defines the tables but has no runtime table references outside schema/docs/types, and models list still reaches provider catalog loaders.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.
    • Include redacted logs or terminal output.

    Next step
    The report is valid and source-backed, but the fix spans model catalog generation, SQL state helpers, and list-path tests, so it is a medium-confidence repair lane rather than an automatic strict bug lane.

    Review details

    Best possible solution:

    Wire model catalog generation and provider capability data through the existing shared SQLite tables, with a clear invalidation/fingerprint path and regression coverage for warm models list, models list --all, and provider-filtered catalog reads.

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

    No high-confidence live reproduction was run in this read-only review. The source path is reproducible enough for triage because current main defines the tables but has no runtime table references outside schema/docs/types, and models list still reaches provider catalog loaders.

    Is this the best way to solve the issue?

    Yes, the reported direction matches the existing schema and database-first policy. The implementation should reuse the existing SQLite tables rather than adding new config, sidecar files, or another cache layer.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • I did not run the CLI timing repro because this review is read-only and those commands would touch local OpenClaw state; the source path still strongly supports that the SQL cache producer is missing.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 15f3903b6f84.

    Label changes

    Label changes:

    • add P2: The report describes a current user-facing CLI performance bug with a clear source-level cause, but it does not make the runtime unusable.
    • add impact:auth-provider: The affected path is provider model catalog/model-choice discovery across configured providers.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.

    Label justifications:

    • P2: The report describes a current user-facing CLI performance bug with a clear source-level cause, but it does not make the runtime unusable.
    • impact:auth-provider: The affected path is provider model catalog/model-choice discovery across configured providers.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/agents/model-catalog.test.ts src/commands/models.list.e2e.test.ts src/commands/models/list.list-command.forward-compat.test.ts
    • node scripts/run-vitest.mjs src/state/openclaw-state-db.test.ts src/agents/embedded-agent-runner/openrouter-model-capabilities.test.ts
    • git diff --check

    What I checked:

    • Current issue state: Live GitHub API shows this issue is open, authored by an external reporter, has no protected labels, and only has the initial ClawSweeper placeholder comment.
    • Schema exists on current main: Current main defines both model_capability_cache and agent_model_catalogs in the shared state schema. (src/state/openclaw-state-schema.sql:257, 15f3903b6f84)
    • No runtime producer found: Repository-wide search found the table names only in state schema/generated typings and database-first docs, not in runtime writers or model-list code. (15f3903b6f84)
    • Current model list still uses provider catalog loaders: appendProviderCatalogRows calls loadProviderCatalogModelsForList, which runs static provider catalogs when available and otherwise invokes live provider catalog hooks. (src/commands/models/list.provider-catalog.ts:275, 15f3903b6f84)
    • Generated model catalog path still writes models.json: ensureOpenClawModelsJson builds and writes models.json and plugin catalog sidecars; it does not persist into agent_model_catalogs. (src/agents/models-config.ts:292, 15f3903b6f84)
    • Database-first docs expect SQL-backed model catalog state: The refactor docs say generated model catalog state should be database-backed and runtime callers should use agent_model_catalogs, not models.json, and also name model_capability_cache as the typed capability table. Public docs: docs/refactor/database-first.md. (docs/refactor/database-first.md:216, 15f3903b6f84)

    Likely related people:

    • steipete: Git blame in this checkout attributes the current state schema and model-list/model-catalog surfaces involved in the report to Peter Steinberger, and the related database-first PR surfaced by GitHub search is authored by steipete. (role: recent area contributor; confidence: medium; commits: 087fcf40858b, 15f3903b6f84; files: src/state/openclaw-state-schema.sql, src/commands/models/list.list-command.ts, src/commands/models/list.provider-catalog.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 4, 2026
  3. steipete commented on Jun 13, 2026

    @steipete
    Contributor

    Fixed by the combined landed changes in #90457 and #92247.

    The generic model_capability_cache table is not required to make this listing path fast; the durable catalog owner for this report is now agent_model_catalogs, plus bounded default discovery. Closing the reported 25-53s listing regression. Please reopen with timings from current main or a release containing 44f45d8729f5 if the same provider set still reproduces it.

  4. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions