feat: refresh Prime Inference models from live API - #1928
Conversation
|
@snimu The PR has been fully redesigned around the live Prime Inference |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e7e810c. Configure here.
| this.authorizedPrivatePrimeInferenceModelIds = new Set(authorizedModels.map((model) => model.id)); | ||
| this.authorizedPrivatePrimeInferenceTeamId = teamId; | ||
| this.writePrivatePrimeAuthorizationCache({ fingerprint, modelIds: authorizedIds, refreshedAt: Date.now() }); | ||
| this.reloadModelsAfterCatalogChange(); |
There was a problem hiding this comment.
🟡 Medium core/model-registry.ts:884
Dynamically authorized private deployments are rebuilt without the models.json provider or per-model overrides, so settings such as providers["prime-inference"].modelOverrides["vendor/model:deployment"] and baseUrl are silently ignored. reloadModelsAfterCatalogChange() calls loadModels(), which applies overrides in loadBuiltInModels() before appending authorizedPrivatePrimeInferenceModels; apply the same override pipeline to authorized models before adding them to this.models.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/coding-agent/src/core/model-registry.ts around line 884:
Dynamically authorized private deployments are rebuilt without the `models.json` provider or per-model overrides, so settings such as `providers["prime-inference"].modelOverrides["vendor/model:deployment"]` and `baseUrl` are silently ignored. `reloadModelsAfterCatalogChange()` calls `loadModels()`, which applies overrides in `loadBuiltInModels()` before appending `authorizedPrivatePrimeInferenceModels`; apply the same override pipeline to authorized models before adding them to `this.models`.
Evidence trail:
Commit 24d3413. `packages/coding-agent/src/core/model-registry.ts:511-514,537-576,578-600,654-669,884-885,1366-1425`. Git commands: `git show REVIEWED_COMMIT -- packages/coding-agent/src/core/model-registry.ts`; `git grep -n "authorizedPrivatePrimeInferenceModels\|loadBuiltInModels\|modelOverrides" REVIEWED_COMMIT -- packages/coding-agent/src/core/model-registry.ts`
…2068) * feat(coding-agent): show the model label on every agents-view row Resident summaries carry model info for all session kinds; only the renderer restricted the label to subagent rows. Drop the special case so any row whose summary has a model renders provider/id[:thinkingLevel] in the suffix region, still suppressed while pending delete/kill. * fix(coding-agent): open visible sessions without waiting for selection anchors Consolidates #2079 at d5b4926. * feat(tui): open local file links Consolidates #2073 at b6e83f0. * feat(coding-agent): highlight file references and command options Consolidates #1145 at 285ccf4. * feat: refresh Prime Inference models from the live catalog Consolidates #1928 at 24d3413. * feat(coding-agent): let root agents create sibling sessions Consolidates #1996 at 0c9c883. * feat(coding-agent): wake agents when asynchronous bash finishes Consolidates #2053 at 1bb4d43. * feat(coding-agent): simplify the agents view while retaining model details Consolidates #2087 at dc67428. Retains #2068 model visibility and #2079 immediate opening and query ownership. * fix(coding-agent): preserve background work and sibling-session credentials Keep managed shell commands active until completion delivery is accepted. Forward only effective same-provider transient auth when creating root sessions. Integration fixes for #2053 and #1996. * fix(coding-agent): address session lifecycle and rendering regressions Preserve sibling PATH and reject root creation after disposal. Treat background completions as new runs without duplicate as_completed wakes. Keep table delimiters visible and sanitize live catalog display metadata. Scope the stale-auth regression fixture to its cached Prime team. * fix(coding-agent): forward the selected provider environment credentials Preserve alias priority and runtime credential identity when creating sibling sessions. Pin that a create timeout never dispatches the task prompt. * fix(runtime): recheck creating-cell waits when shell commands settle Preserve late as_completed consumers without suppressing detached completion notices. Document the cached-wrapper result limitation. * fix(runtime): preserve background bash completion lifecycle Wait for process-group cleanup before releasing residency. Defer paused admission within the original request and report terminal rejection. Preserve notices after cancelled non-owning waits and clean up interrupted task construction. * fix(runtime): use a portable signal for construction cleanup Keep immediate POSIX cleanup and use the existing Windows job cleanup path without referencing SIGKILL. * fix(coding-agent): steer shell messages and stop losing supervisor launches Deliver labeled shell completion messages at the next safe turn boundary. Stop only an owned replacement child that loses to a current authenticated supervisor. --------- Co-authored-by: Seth <seth@primeintellect.ai>

Part of RES-1239. Supersedes #1633.
What changed
https://api.pinference.ai/api/v1/modelsendpoint.internal/*,dev/*, and deployment routes.models.jsondefinitions, provider/model overrides, extension providers, and bundled client compatibility metadata.Safety and fallback behavior
specs; entries without them are skipped rather than assigned guessed limits or capabilities.specsretain bundled capabilities and limits while accepting live names and prices.internal/*,dev/*, and deployment IDs containing:. Authenticated-only routes use a separate mode-0600cache keyed by a credential/team fingerprint; they never enter the public cache.PI_OFFLINE=1skips network refreshes.Current backend follow-up
The endpoint currently returns 120 public routes. It provides complete
specsfor 113. Five new Qwen routes and the currently authorized private routes cannot be added dynamically yet becausespecsisnull. To remove the remaining client fallbacks and route-name heuristics, the endpoint should provide:specsfor every public and private route;featuredfield if realtime promotion is desired.Validation
npm run checkNote
Medium Risk
Runtime model pickers and context limits now follow live API data with merge/fallback rules; mistakes could hide models, leak private routes, or mis-state limits, though guards and tests target those cases.
Overview
Prime Inference model lists now update from the live
/modelsendpoint instead of relying only on release bundles and ad hoc generator logic.@earendil-works/pi-aiadds a sharedparsePrimeInferenceModelCatalogparser (pricing, cache costs, specs, private-route detection) and moves generated catalog output throughrenderModelsFileso remote strings are JSON-escaped. Thegenerate-modelsscript hits the public endpoint without Prime CLI credentials, applies truncation/coverage guards, and still merges OpenRouter gaps where needed.Prime Agent loads a validated
prime-inference-models-cache.json(or bundled models) immediately, background-refreshes the public catalog, and merges live entries viabuildPrimeInferenceModels/mergePrimeInferenceModelswhile keeping bundledcompatand thinking maps. Authorizedinternal/*,dev/*, and deployment routes are built from authenticated catalog responses and persisted as full model records, not ID sets.PI_OFFLINE=1skips network refresh; docs describe the new behavior.Reviewed by Cursor Bugbot for commit 24d3413. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Refresh Prime Inference models from live API with validated cache fallback
/modelsendpoint without Prime CLI credentials, with a severe-truncation guard preserving the existing snapshot if live results are too sparsePI_OFFLINE=1supportloadModelsin model-registry.ts replaces bundled Prime Inference entries with live entries when supplied; existing tests for fixed maxTokens and context assertions are relaxed to allow clamped live metadataChanges since #1928 opened
ModelRegistryprivate Prime authorization flow to cache and restore full model metadata instead of model IDs, enabling immediate availability of authorized private deployments at startup without network access [24d3413]parsePrimeInferenceModelCatalogutility to require both input and output modalities to be arrays of strings, treating modalities as undefined when validation fails and only attaching full specs when all required fields are valid [24d3413]buildPrimeInferenceModelsutility to measure coverage of bundled models rather than total model count [24d3413]Macroscope summarized e7e810c.