feat(backend): remote LLM catalog sync for self-hosted installs - #13609
feat(backend): remote LLM catalog sync for self-hosted installs#13609ntindle wants to merge 2 commits into
Conversation
Part 5 of 9 of the LLM registry restack. Self-hosted installs poll the cloud catalog endpoint (part 4) on startup + daily and import through the same idempotent importer the bundled catalog uses (part 3) — new models and remote disables now reach local installs without a code update. - Gate: llm_catalog_sync_enabled AND behave_as=LOCAL. Cloud deployments (behave_as=CLOUD) never fetch — cloud DBs are admin-managed truth - Fetch via util.request.Requests (SSRF-guarded; catalog URL host in trusted_origins so internal mirrors work), 15s timeout, 2MiB cap - Full pydantic validation BEFORE any DB write; bad payloads are rejected wholesale and last-known-good stays - In-process asyncio loop in the rest_api lifespan (the scheduler process is Prisma-less); loop never dies; single-key Redis NX lock dedups multi-pod fetches; attempts recorded on LlmCatalogState - Config: LLM_CATALOG_SYNC_ENABLED / LLM_CATALOG_URL / LLM_CATALOG_SYNC_INTERVAL_HOURS, mirrored in .env.default Co-authored-by: Bentlybro <Github@bentlybro.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/llm-registry-v2-public-api #13609 +/- ##
================================================================
Coverage 76.02% 76.02%
================================================================
Files 2688 2688
Lines 204279 204281 +2
Branches 19654 19655 +1
================================================================
+ Hits 155303 155312 +9
+ Misses 44693 44630 -63
- Partials 4283 4339 +56
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
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. No replacement by design — CD propagates the catalog at deploy; self-hosted installs get it on upgrade. A raw-GitHub fetch remains an easy add if between-release freshness is ever wanted. |
Why
Part 5 of 9 of the LLM registry restack (#13605 → #13606 → #13607 → #13608 → this). This is the piece that makes the registry strictly better than the enum for self-hosted users: new models and remote disables arrive within a day, no
git pullrequired.What
backend/data/llm_registry/sync.py— a lifespan background loop that fetches the cloud catalog on startup and every 24h, validates it, and feeds it to the part-3 importer withsource=REMOTE:behave_as == LOCAL(notapp_env— self-hosted installs also runapp_env=local;behave_asis what encodes "our cloud")util.request.Requests(SSRF guard, retries), catalog host intrusted_originsso pointingLLM_CATALOG_URLat an internal mirror works, 15s timeoutLlmCatalogState.lastRemoteSyncAt/lastRemoteSuccessAt); single-key Redis NX lock dedups multi-pod installs; startup never blocks on the network (background task)Config (mirrored in
.env.default):LLM_CATALOG_SYNC_ENABLED=true,LLM_CATALOG_URL=https://backend.agpt.co/api/llm/catalog,LLM_CATALOG_SYNC_INTERVAL_HOURS=24.Verification
poetry run format+poetry run lintcleanChecklist