Skip to content

v2: first prompt after idle can race Console model catalog refresh #34837

Closed

Description

@opencode-agent

Summary

In OpenCode v2, the first prompt after an idle period can fail with ModelUnavailableError for a valid Console model such as opencode/gpt-5.5. The failure appears to be a local catalog readiness race: Console has the model, but the local v2 catalog is read before the OpenCode provider refresh has finished.

Environment

  • opencode version: Unavailable: reported from a user's local v2 box; exact version not captured in the source report
  • OS: Unavailable: reporter OS not captured
  • Terminal: Unavailable: reporter terminal not captured
  • Shell: Unavailable: reporter shell not captured
  • Install/channel: OpenCode v2 local session, exact channel unavailable
  • Active plugins: Unavailable: reporter plugin/config state not captured

Reproduction

  1. Use OpenCode v2 with the OpenCode Console provider and a valid model that Console returns for the credential, e.g. opencode/gpt-5.5.
  2. Leave the session/location idle long enough for location services to cold boot on the next turn.
  3. Send a prompt immediately after the idle period.
  4. Observe the first turn resolving the model before the async OpenCode provider refresh has populated the local catalog.

Expected Behavior

The first prompt after idle should wait for the provider/catalog refresh needed to validate the configured model, then continue normally when Console says the model is available.

Actual Behavior

The prompt fails with ModelUnavailableError; from the user's perspective, they send a prompt and nothing happens besides an error.

The observed failure mode is not Console saying the model is unavailable. Console returns gpt-5.5 for the anomaly credential, but the local v2 catalog snapshot does not yet include providerID=opencode, modelID=gpt-5.5 when model resolution runs.

Additional Context

Likely race identified from source inspection:

  • packages/core/src/session/runner/model.ts: SessionRunnerModel.resolve checks catalog.model.available() for the provider/model pair and throws ModelUnavailableError when absent.
  • packages/core/src/location-services.ts: location services are cached for 60 minutes; after idle, the next message cold-boots location services.
  • packages/core/src/plugin/internal.ts: internal plugin boot runs in a fork and is not awaited.
  • packages/core/src/plugin/provider/opencode.ts: initial OpenCode Console provider refresh is started in a fork and is not awaited.
  • Result: the session runner can read the catalog before the async OpenCode provider refresh has fetched/reloaded Console models.

Reported from internal Discord discussion: https://discord.com/channels/1391832426048651334/1447692703549755466/1522079701697429645

Activity

  1. added
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Jul 2, 2026
  2. kitlangton commented on Jul 4, 2026

    @kitlangton
    Contributor

    Confirmed this race remains on the current V2 branch. #35267 implements the readiness barrier and regression coverage, but is still open with failing Linux and Windows unit CI. Keeping this issue open until that PR lands successfully.

  3. thdxr commented on Jul 9, 2026

    @thdxr
    Member

    Closing this tracker after the recent V2 server lifecycle, restart continuity, reconnect hydration, and synchronization work. This area has changed substantially, and we want to track any remaining or newly reproducible behavior as a fresh, focused issue against the current implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

2.0bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)gang-grillDesign topics queued for later group grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions