Repository navigation
fix(models): retry a cold catalogue and never cache it empty - #4
Merged
Merged
Conversation
A freshly spawned `opencode serve` answers `/api/model` with an empty list for a moment after it reports readiness. The gateway cached that answer for OPENCODE_MODEL_CACHE_TTL_MS, so for the next five minutes every request failed with `404 model_not_found` for models that do exist; only `GET /v1/models?refresh=true` recovered (observed against opencode 2.4.3). Retry an empty model list the way an empty agent list was already retried, and leave the catalogue uncached while it holds no models, so the next request picks them up as soon as the provider registers them.
Record that the catalogue is retried and never cached empty, that opencode 2.4.3 was re-verified (spawn output, /api/model, /api/provider, /api/agent and the model ids are unchanged), and add the matching troubleshooting row for a 404 model_not_found right after startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
curl ... "model":"opencode/deepseek-v4.1-flash-free"answered404 model_not_found, but the model exists. A freshly spawnedopencode servereports readiness before its providers are registered, so thegateway's first
GET /api/modelreturneddata: [](observed againstopencode 2.4.3, agents already came back).
ModelRegistrycached that emptycatalogue for
OPENCODE_MODEL_CACHE_TTL_MS, so every request failed for thenext five minutes;
GET /v1/models?refresh=truereturned all 10 models.Fix
retried (both lists are now retried together, at most ~1 s).
as soon as the provider registers them.
Verification
and "does not cache an empty catalogue" both fail without the fix.
pnpm typecheck,pnpm build,pnpm test— 217 passed (15 files).node dist/index.js, opencode 2.4.3): the firstGET /v1/modelswithout?refreshreturns 10 models, includingopencode/deepseek-v4.1-flash-free; the reported chat request now reaches theupstream and answers the expected
429 provider.free-limit(quota, not agateway defect).
Also documents the behaviour and adds a troubleshooting row, and records that
opencode 2.4.3 was re-verified.
Closes the reported
model_not_foundfailure.