Skip to content

feat(backend): add idempotent LLM catalog importer and bundled catalog - #13607

Closed
ntindle wants to merge 1 commit into
feat/llm-registry-v2-corefrom
feat/llm-registry-v2-importer
Closed

feat(backend): add idempotent LLM catalog importer and bundled catalog#13607
ntindle wants to merge 1 commit into
feat/llm-registry-v2-corefrom
feat/llm-registry-v2-importer

Conversation

@ntindle

@ntindle ntindle commented Jul 18, 2026

Copy link
Copy Markdown
Member

Why

Part 3 of 9 of the LLM registry restack (#13605#13606 → this). The original stack seeded the registry with a one-shot SQL migration — frozen at install time, no way to update self-hosted installs, and no protection for admin edits. This PR replaces seeding with an idempotent importer that runs on every startup, which is the foundation the remote-sync mechanism (part 5) builds on.

What

  • catalog_model.pyCatalogPayload schema v1: the single source of truth for the bundled file, the public endpoint (part 4), and sync validation (part 5). Facts only: no costs, no credentials, no routing cells, no non-GA models. Slug patterns, bounds, and a 2000-model cap.
  • importer.py — merge rules: upsert-by-slug; source=LOCAL (admin-owned) rows never updated or disabled, enforced inside every UPDATE's WHERE clause so a concurrent admin claim wins the race; absent models are disabled + catalogRemovedAt-stamped, never deleted; LlmModelCost never touched; sha256 content-hash fast-path (steady-state boot = one SELECT); one transaction, then cache refresh + cross-pod fan-out.
  • export.py — regenerates catalog.json from a populated DB (python -m backend.data.llm_registry.export); GA-visibility models only.
  • catalog.json — 85 models / 8 providers / 17 creators, generated from today's MODEL_METADATA (deliberately not the March-era seed data); gpt-5.2 recommended, mirroring DEFAULT_LLM_MODEL.
  • Lifespan — bundled import before registry refresh, fail-soft (empty registry degrades to hardcoded behavior).

Verification

  • 51/51 tests pass locally — real-DB integration tests for each merge rule (create, hash fast-path, LOCAL survival under both update and removal, disable-not-delete, reappearance re-enable, forward-referenced fallback pointers, schema_version rejection, full bundled import), catalog schema validation edges, and a forever-guard that catalog.json parses with unique slugs and sound references
  • poetry run format + poetry run lint clean

Checklist

  • data/*.py changes: registry tables are global config, no user-scoped rows — no user ID checks applicable
  • Out-of-scope changes: none

Part 3 of 9 of the LLM registry restack. Replaces the original stack's
one-shot 287-line seed SQL migration with an importer that runs on every
startup:

- catalog_model.py: CatalogPayload schema (v1) — model facts only; costs,
  credentials, routing cells, and non-GA models are never in a catalog
- importer.py: upsert-by-slug with source tracking. LOCAL (admin-owned)
  rows are never updated or disabled, enforced via `source != LOCAL`
  inside every UPDATE WHERE clause (row-atomic against concurrent admin
  writes). Removals disable + stamp catalogRemovedAt, never delete.
  sha256 content-hash fast-path makes steady-state boots one SELECT.
  All writes in one transaction, then refresh_runtime_caches()
- registry.refresh_runtime_caches(): the single write-path choke point
  (clear Redis L2 -> rebuild L1 -> pub/sub fan-out)
- export.py: regenerate catalog.json from a populated DB
  (poetry run python -m backend.data.llm_registry.export)
- catalog.json: 85 models / 8 providers / 17 creators generated from the
  current MODEL_METADATA (not the stale March seed data); gpt-5.2 marked
  recommended to mirror DEFAULT_LLM_MODEL
- lifespan: import_bundled_catalog() before the registry refresh,
  fail-soft

Tests: real-DB integration tests for every merge rule + catalog schema
validation + a forever-guard that catalog.json parses with unique slugs.

Co-authored-by: Bentlybro <Github@bentlybro.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7df1d5c6-9b41-4fa8-87a6-2c3d44283b81

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/llm-registry-v2-importer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added platform/backend AutoGPT Platform - Back end size/xl labels Jul 18, 2026
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.01%. Comparing base (2a3a7f0) to head (47f709d).

Additional details and impacted files
@@                    Coverage Diff                     @@
##           feat/llm-registry-v2-core   #13607   +/-   ##
==========================================================
  Coverage                      76.01%   76.01%           
==========================================================
  Files                           2688     2688           
  Lines                         204280   204280           
  Branches                       19654    19654           
==========================================================
+ Hits                          155278   155281    +3     
+ Misses                         44662    44657    -5     
- Partials                        4340     4342    +2     
Flag Coverage Δ
platform-frontend-e2e 31.05% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 82.83% <ø> (ø)
Platform Frontend 49.98% <ø> (+<0.01%) ⬆️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ntindle

ntindle commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

After a post-build design review we pivoted from the DB-registry to catalog-as-code: one canonical, schema-validated catalog file is the source of truth (models + costs + copilot routing), updated by PR (catalog-only diffs may ride hotfix→master; the /review bot covers the lane), propagated by CD, with LaunchDarkly demoted to optional cohort experiments and git history as the audit log. Rationale: the admin machinery mostly bought instant-mutation and non-engineer authoring we don't need, and LD is too unreliable to be the load-bearing control layer.

Replaced by #13622 — catalog.py is promoted from seed data to the database itself; the importer/merge semantics have no second writer to exist for.

@ntindle ntindle closed this Jul 20, 2026
@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to ✅ Done in AutoGPT development kanban Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end size/xl

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant