Skip to content

core: "Failed to fetch models.dev" reports no cause and no next step #56742

Open

Description

@mgajda

Title: core: "Failed to fetch models.dev" reports no cause and no next step

Template: Bug report


Description

When the periodic models.dev refresh fails, packages/core/src/models-dev.ts:429 logs the symptom
and nothing else:

timestamp=2026-09-21T13:45:53.227Z level=ERROR run=<redacted> message="Failed to fetch models.dev" cause="Cause([Fail(HttpClientError: Transport error (GET https://models.opencode.ai/api.json) (cause: Error: Unable to connect. Is the computer able to access the url?))])"

Two unrelated causes land under this one message: a transport failure, and an EACCES when the
refresh cannot create ~/.local/state/opencode/locks. Neither says what to do, and neither says
whether the running session is affected — it isn't, because the bundled snapshot is the boot floor.

On my machine this is 56 of 790 ERROR lines (7.1%), making it the most frequent non-provider
failure I hit. It clusters hard — 15 occurrences on one day — because refresh() repeats on a 5
minute TTL and every retry re-logs the identical opaque line.

Suggested: classify the cause and log the host plus a next action, e.g.

Cannot reach models.opencode.ai (connection refused). Using the bundled model catalog; retrying
in 5 minutes. Check HTTP_PROXY/HTTPS_PROXY if you expect a proxy.

networkFailure() in packages/core/src/aisdk.ts:977 already classifies these shapes
(ECONNREFUSED, ETIMEDOUT, "fetch failed", UND_ERR*), but it is private to that module and
used only for LLM errors. Extracting it into a shared module would let both call sites use it.

This is one instance of the wider problem in #35325 and #36582 — I'm filing it narrowly rather than
duplicating those.

Plugins

None.

OpenCode version

v2, built from v2-patched (reports 1.18.31; the version string is stale on this fork).

Steps to reproduce

  1. Break outbound network, or point the machine at a host that refuses connections.
  2. Start opencode and leave it running.
  3. Read ~/.local/share/opencode/log/opencode.log, grep for Failed to fetch models.dev.
  4. Observe the same line repeated every 5 minutes with no cause or remedy.

Screenshot and/or share link

N/A — log excerpt above.

Operating System

Ubuntu.

Terminal

N/A.

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the numbers from your logs. To restate the request: when the periodic models.dev refresh fails, the log should say which failure it was (network/transport vs. a filesystem error such as EACCES on ~/.local/state/opencode/locks), name the host and point to a next step (proxy settings, permissions). It should also say that the bundled catalog is still in use and when the next retry is, instead of repeating the same raw Cause(...) line every 5 minutes. Reusing the networkFailure() classifier from packages/core/src/aisdk.ts for this makes sense.

    I checked dev, and packages/core/src/models-dev.ts still logs only Failed to fetch models.dev with the raw cause, so this applies to current v2. Maintainers will consider it.

    Related issues:

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

Metadata

Metadata

Assignees

No one assigned

    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