Repository navigation
TUI corrupted by auto-fetch of models.dev error log leaks #34730
Description
Description
My network environment cannot reach https://models.dev/api.json.opencode periodically auto-fetches this URL on startup and in thebackground. Each failed attempt logs:
level=ERROR message="Failed to fetch models.dev"
cause="HttpClientError: Transport error (GET https://models.dev/api.json)"
These errors leak into the TUI and corrupt the layout behind the textinput area. Since I only use a manually configured model, the registryfetch is unnecessary for my workflow.
I'd like a config option (e.g. "models.dev.auto_fetch": false or"model_registry.fetch": "manual") in opencode.jsonc to:
- Disable the periodic auto-fetch of models.dev
- Suppress the related ERROR log
- Optionally allow a manual fetch via command when needed
Relevant log excerpts
The error appears 189 times in a single opencode.log, spanningacross days and persisting across TUI sessions:
timestamp=2026-06-11T02:55:21.574Z level=ERROR run=e038de2c
message="Failed to fetch models.dev"
cause="Cause([Fail(HttpClientError: Transport error
(GET https://models.dev/api.json) (cause: Error: The socket connection
was closed unexpectedly. For more information, pass `verbose: true`
in the second argument to fetch()))])"
timestamp=2026-06-11T02:59:01.762Z level=ERROR run=44ab922b
message="Failed to fetch models.dev"
cause="Cause([Fail(HttpClientError: Transport error
(GET https://models.dev/api.json) (cause: Error: The socket connection
was closed unexpectedly. ...))])"
timestamp=2026-06-30T11:05:43.193Z level=ERROR run=483673bb
message="Failed to fetch models.dev"
cause="Cause([Fail(HttpClientError: Decode error
(200 GET https://models.dev/api.json) (cause: Error: The socket
connection was closed unexpectedly. ...))])"
timestamp=2026-07-01T01:06:02.239Z level=ERROR run=e3cd7dcb
message="Failed to fetch models.dev"
cause=Cause([Fail(TimeoutError)])
Different error variants observed:
Transport error— socket reset (ECONNRESET)Decode error— got HTTP 200 but connection died mid-responseTimeoutError— request timed out
The error fires repeatedly within minutes during the same sessionand resumes after restart. This confirms the auto-fetch runsperiodically with no backoff or stop mechanism.
Plugins
@mohak34/opencode-notifier@latest
OpenCode version
1.17.12
Steps to reproduce
- Run opencode in a network that cannot reach https://models.dev/api.json
(e.g. behind corporate proxy, VPN, or air-gapped environment) - Observe the TUI — ERROR messages appear behind the text input area,
causing UI elements to shift and overlap - Check opencode.log — repeated "Failed to fetch models.dev" entries
(189 occurrences in a single session in my case)
Screenshot and/or share link
Operating System
Windows (PowerShell 7)
Terminal
Windows Terminal
Activity
[-]TUI crash caused by auto-fetch of models.dev error log[/-][+]TUI corrupted by auto-fetch of models.dev error log[/+][-]TUI corrupted by auto-fetch of models.dev error log[/-][+]TUI corrupted by auto-fetch of models.dev error log leaks[/+]github-actions commentedon Jul 1, 2026
This issue might be a duplicate of existing issues. Please check:
soetang commentedon Jul 1, 2026
I am experiencing the same. The TUI corruptions does not appear to happen in 1.17.11 for me. So there seems to be a regression between 1.17.11 and 1.17.12
0warning0error commentedon Jul 2, 2026
there is a workarond:
set environment variable:
klx1204 commentedon Jul 2, 2026
Unfortunately, the issue reoccurs while I'm using 1.17.13
leigoshi commentedon Jul 2, 2026
我也遇到了1.17.13
opencode-agent commentedon Jul 3, 2026
Additional investigation: root cause is an eager ModelsDev refresh logging before the OpenCode logger is installed
I reproduced the stdout leak locally and traced the likely cause.
Summary
ModelsDev.nodestarts an eager backgroundrefresh()during layer construction. Whenhttps://models.dev/api.jsonis unavailable, that refresh logsFailed to fetch models.devwithEffect.logError(...).If that log runs before OpenCode's
Observability.layerlogger has been installed, Effect's default logger writes to stdout. In the TUI, stdout is owned by OpenTUI, so the log text is rendered into the terminal frame and corrupts the UI.Providing
Observability.layerbefore buildingModelsDev.nodeprevents the stdout write in the minimal repro.Relevant code paths
packages/core/src/models-dev.tsrefresh()logs the fetch failure:packages/core/src/observability/logging.tsOPENCODE_PRINT_LOGS=1.packages/tui/src/app.tsxMinimal repro evidence
Working tree/tag used for investigation:
v1.17.13/10c894bdeeorigin/devchecked separately at5455fed78e;packages/core/src/models-dev.tsis effectively unchanged for this behavior.First, Effect's default logger writes errors to stdout:
Observed:
Then a minimal
ModelsDev.nodebuild with a failing mock HTTP client reproduces the same stdout leak:Observed when redirecting streams:
Control case: if the same layer is built with
Observability.layerprovided first, the repro produces no stdout/stderr leak:Observed:
Why this matches the user symptom
When
models.devis reachable, the eager refresh succeeds and no log leaks. In networks wheremodels.devis blocked, reset, or times out, the eager refresh hits the log path during startup/background refresh. If that happens before the OpenCode logger is active, the log goes to stdout and OpenTUI renders it into the UI.This also explains why the app can otherwise keep working: the models catalog has disk/bundled fallback behavior, but the best-effort refresh error is still emitted as an ERROR log.
Expected behavior
A best-effort models.dev refresh failure should never write to stdout while the TUI is active. It should either:
Possible fixes
Observability.layeris installed before any eager-forking service layers can log.ModelsDev.refresh()fork out ofModelsDev.nodelayer construction and start it after runtime/logging bootstrap.opencode models --refresh: background failures can be debug/warn/file-only, while explicit manual refresh can surface failure to the user.Related issues
models.devconnection errors breaking the TUI.Failed to fetch models.devERROR on every startup #32986 reportedFailed to fetch models.devat ERROR level every startup.Environment used for investigation
v1.17.13(10c894bdee) andorigin/dev(5455fed78e)6.12.93x86_64TERM=xterm-256color/bin/bashkitlangton commentedon Jul 3, 2026
The root cause here was a layer-ordering regression in the server route composition: the service graph (including the models.dev background refresh) was built before the logging layer, so its forked refresh fiber kept Effect's default stdout logger. The TUI runs that server in a worker thread of the same process, and worker-thread console output bypasses the TUI's console capture, which is why the error text landed on the screen.
#35171 fixes the ordering so the refresh failure is written to the log file instead of stdout, and it will be in the next release. Once you're on that version, the UI corruption should be gone. Note the periodic
Failed to fetch models.deventries will still appear in opencode.log when models.dev is unreachable (the refresh is best-effort and falls back to the cached/bundled catalog), and you can disable the auto-fetch entirely withOPENCODE_DISABLE_MODELS_FETCH=1.If you still see UI corruption after updating, please comment and we'll reopen.
nexxeln commentedon Jul 7, 2026
still see it @kitlangton
AndyLuoJJ commentedon Jul 12, 2026
Still exists in OpenCode version 1.17.18
github-actions commentedon Sep 11, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.