PARAS MADAN
All writing

Latest in AI

OpenCode 2.4.0: Why the Model List Can Be Empty After Startup

Fix an empty or partial OpenCode model catalog by refreshing on SDK events or waiting for the exact provider and model your script needs.

OpenCode 2.4.0 stops waiting for plugins before answering model and provider catalog requests. If you maintain an OpenCode integration, a successful GET /api/model immediately after startup can now contain an empty or partial list. It tells you the server replied, not that the model your app needs is ready.

This matters most when your integration loads its model menu once, or when a short-lived job picks a default on startup. If the first list misses your model and that makes the app pick another one, a startup delay can change the behavior and cost of every subsequent request.

Why an HTTP 200 can still miss a model

The previous server path could wait up to five seconds for plugins, then return a 503 if they weren't ready. The merged change removes that wait from the affected handlers. The API reference describes the model list as a snapshot that may precede initial plugin setup. It defaults to chat models, and the result is scoped to the requested OpenCode Location, or to the server's default Location if you omit it.

An earlier issue illustrates why the old behavior could be painful: a user with a large skills directory on Windows reported repeated 503s and a missing model picker. That is one reported setup, not a benchmark or evidence that upgrading makes every plugin initialize faster.

Refresh a model picker on the update event

If your app stays open, load the first snapshot so users can see what is available. Subscribe to model.updated, then reload the catalog for the same Location when the event arrives. If your UI also shows provider status, do the equivalent for provider.updated. These are catalog events in the OpenCode API; use them to trigger a fresh read rather than treating each event as a new full catalog.

I would establish the event subscription before the first read, then take a fresh snapshot after a reconnect. An update may be coalesced during startup, and an event does not promise that your particular model has loaded. Keep an existing selection visibly pending instead of clearing it when the first snapshot comes back without it.

Give a one-shot script a bounded wait

For a short-lived script, poll for the exact provider and model it is configured to use. An empty list and a nonempty list that lacks the required entry mean the same thing for that script: it isn't ready to submit the job. Use a deadline that fits your own startup measurements. On timeout, name the missing entry and stop. A successful read of the wrong catalog should never trigger an automatic fallback.

For example, in a disposable workspace, start the service cold and read the catalog without sending an inference request. Record how long it takes for your configured model to appear, then repeat with a warm service and confirm the same model is selected. If it never appears, check the Location, model type and plugin logs before increasing the timeout.

The upgrade removes a server-side wait. Your application still needs a readiness check for the exact model it intends to use.

If your AI tool works once everything is warm but quietly changes behavior on a fresh boot, I can help narrow down the startup conditions and design a small acceptance test. Book a 30-minute call.