Skip to content

Long-running server keeps per-directory provider models stale after catalog refresh #36284

Closed as not planned

Description

@JaviOverflow

Description

A long-running opencode serve process keeps provider/model state cached per directory after the models.dev catalog refreshes. Different directories served by the same process can therefore return different model catalogs.

Observed on one server process:

  • Server started July 8.
  • ~/.cache/opencode/models.json updated July 10 and contains openai/gpt-5.6-sol.
  • A directory initialized before the update returns 13 OpenAI models and no GPT-5.6 models.
  • A directory initialized after the update returns 25 OpenAI models, including gpt-5.6-sol-fast.
  • Repeating GET /provider does not refresh the stale directory.
  • Restarting opencode serve fixes it.

Expected: directory-scoped provider catalogs eventually reflect refreshed models.dev data without restarting the server or manually disposing each instance.

Suspected cause: provider state created through InstanceState.make() captures modelsDevSvc.get() during directory initialization. The /provider handler merges current ModelsDev entries with connected providers using Object.assign(...); the stale connected provider entry replaces the fresh catalog entry, including its models map.

Possible fix: invalidate/rebuild initialized provider states on ModelsDev.Event.Refreshed, or merge fresh catalog models into connected provider metadata during provider-list reads.

Related but distinct: #36117 covers incomplete snapshots during cold startup. This report concerns a settled catalog remaining stale indefinitely after startup.

Plugins

None

OpenCode version

1.17.13

Steps to reproduce

No response

Screenshot and/or share link

No screenshot. Reproduced directly against the HTTP API.

Operating System

macOS

Terminal

Not terminal-specific (opencode serve HTTP API)

Activity

  1. github-actions commented on Sep 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions