server: custom providers from global config not registered on service boot
Summary
Custom providers defined in the global config (~/.config/opencode/opencode.json) are not registered when the background service boots, and subsequent file-watcher reload cycles never register them either. Sessions referencing their models fail with ModelUnavailableError. Only an explicit POST /api/location/reload registers them, after which everything works.
Environment
- opencode version: 2.3.0
- OS: Linux 7.2.15-1-omarchy (linux x64)
- Terminal: ghostty (TERM=xterm-ghostty, COLORTERM=truecolor)
- Shell: /usr/bin/bash
- Install/channel: latest
- Active plugins: none configured
Reproduction
- Define a custom provider in the global config
~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"main": {
"name": "llama.cpp main",
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "http://100.x.x.x:8080/v1"
},
"models": {
"qwen": {
"modelID": "qwen-main",
"name": "Qwen3.6-35B-A3B",
"capabilities": {
"tools": true,
"input": ["text"],
"output": ["text"]
},
"limit": {
"context": 65536,
"output": 8192
}
}
}
}
}
}
- Confirm it works:
opencode run --model main/qwen "..."succeeds. - Restart the background service (
serve --service). opencode api get /api/provider→ the custom provider is absent (only catalog providersopencodeandfireworks-aiare listed).- Any session using the model fails:
SessionRunnerModel.ModelUnavailableError: Model unavailable: main/qwen. opencode api post /api/location/reload→ the provider immediately appears withactivation=enabled, and inference works again.
Expected Behavior
Custom providers from the global config are registered when the service boots (and when config file changes are picked up by the watcher), without requiring a manual location reload.
Actual Behavior
After a service restart, the custom providers are never registered. The watcher fires provider.updated events on location boot and on later reload cycles, but the providers remain absent for as long as the service keeps running (observed >25 hours across multiple watcher cycles). GET /api/config during the broken state shows the parsed global config document with the providers key missing entirely ({"$schema": "...", "update": "disable", "instructions": [...]}); after the manual reload, the same endpoint includes providers and the providers work.
Additional Context
Timeline from ~/.local/share/opencode/log/opencode.log (UTC):
- 2026-11-19 18:49:45 —
POST /api/location/reload→provider.updated,model.updated; subsequentopencode run --model main/qwen/small/qwensucceeded. - 2026-11-23 11:33:48 — service started (
serve --service, v2.3.0);location services booted;provider.updatedfired. - 2026-11-23 12:33 / 12:35 / 13:35 and 2026-11-24 19:24 — further location boots / watcher reload cycles with
provider.updatedevents; providers still absent. - 2026-11-24 19:24:08 — session drain failed:
SessionRunnerModel.ModelUnavailableError: Model unavailable: main/qwen
at <anonymous> (/$bunfs/root/chunk-1wt015yk.js:13:21186)
at SessionRunnerModel.select (/$bunfs/root/chunk-1wt015yk.js:13:21523)
at SessionRunnerModel.resolve (/$bunfs/root/chunk-zngf6fdt.js:100:8858)
at SessionContext.load (/$bunfs/root/chunk-7559ejtv.js:493:2814)
at SessionRunner.advanceToStep (/$bunfs/root/chunk-7559ejtv.js:493:2869)
at SessionRunner.drain (/$bunfs/root/chunk-7559ejtv.js:493:6652)
- 2026-11-24 ~19:38 —
POST /api/location/reload→ both providers registered and verified working.
Both llama.cpp endpoints were reachable throughout (verified via GET /v1/models directly), so this is not an endpoint outage. The config validates against the published schema. Reproducible: yes, across every service boot observed since 2026-11-23. Workaround: opencode api post /api/location/reload after each service start.
Thanks for the detailed report. I couldn't reproduce this on 2.3.0 yet.
What I tried, on Linux with an isolated home directory and no plugins:
- Put your
providers.mainblock in~/.config/opencode/opencode.json, pointed at a local mock OpenAI-compatible server. In a second run I also added"update": "disable"and aninstructionsentry, to match the keys your/api/configoutput showed. - Ran
opencode service start, then checkedopencode api get /api/providerand/api/config, and ranopencode run --model main/qwen. - Stopped and started the service again (the process ID changed) and repeated the checks, then ran
opencode api post /api/location/reload.
Every time, including right after the restart, main was listed in /api/provider, providers was in the config document, and main/qwen was selected without a ModelUnavailableError.
One detail stands out: in your broken state, /api/config showed the global document with the providers key missing. That suggests the service read a different version of the file, or a different file. These would help narrow it down:
- Is
~/.config/opencodeoropencode.jsona symlink, e.g. into a dotfiles repo? #55119 is a related report where config changes weren't picked up from a symlinked~/.config/opencode. - How is the service started after a reboot or restart:
opencode service start, a systemd unit, the desktop app, or auto-start from anotheropencodecommand? Does that environment set a differentHOME,XDG_CONFIG_HOMEorOPENCODE_CONFIG*variable? - Was
providersadded to the file, or the file rewritten, after the service started? Is there also anopencode.jsoncin that folder? - In the broken state, the full output of
opencode api get /api/config(thepathof each document), and the log lines aroundlocation services bootedthat mention config or providers.
You can reply here with the details, or edit the issue and leave a short comment saying you've updated it.
- Yes, this is a symlinked config
- systemd service
- no, and no
- will provide if broken state returns
Thanks :)
On Tue, Nov 24, 2026 at 2:50 PM opencodejr[bot] @.***> wrote:
opencodejr[bot] left a comment (anomalyco/opencode#66166) https://github.com/anomalyco/opencode/issues/66166#issuecomment-7142648847
Thanks for the detailed report. I couldn't reproduce this on 2.3.0 yet.
What I tried, on Linux with an isolated home directory and no plugins:
- Put your providers.main block in ~/.config/opencode/opencode.json, pointed at a local mock OpenAI-compatible server. In a second run I also added "update": "disable" and an instructions entry, to match the keys your /api/config output showed.
- Ran opencode service start, then checked opencode api get /api/provider and /api/config, and ran opencode run --model main/qwen.
- Stopped and started the service again (the process ID changed) and repeated the checks, then ran opencode api post /api/location/reload.
Every time, including right after the restart, main was listed in /api/provider, providers was in the config document, and main/qwen was selected without a ModelUnavailableError.
One detail stands out: in your broken state, /api/config showed the global document with the providers key missing. That suggests the service read a different version of the file, or a different file. These would help narrow it down:
- Is ~/.config/opencode or opencode.json a symlink, e.g. into a dotfiles repo? #55119 https://github.com/anomalyco/opencode/issues/55119 is a related report where config changes weren't picked up from a symlinked ~/.config/opencode.
- How is the service started after a reboot or restart: opencode service start, a systemd unit, the desktop app, or auto-start from another opencode command? Does that environment set a different HOME, XDG_CONFIG_HOME or OPENCODE_CONFIG* variable?
- Was providers added to the file, or the file rewritten, after the service started? Is there also an opencode.jsonc in that folder?
- In the broken state, the full output of opencode api get /api/config (the path of each document), and the log lines around location services booted that mention config or providers.
You can reply here with the details, or edit the issue and leave a short comment saying you've updated it.
— Reply to this email directly, view it on GitHub https://github.com/anomalyco/opencode/issues/66166?email_source=notifications&email_token=AAAB5BSX323XYSJRUYUYT6T52XQ7JA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMJUGI3DIOBYGQ32M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-7142648847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAB5BSYCIMRXZRRSODUKW352XQ7JAVCNFSNUABFKJSXA33TNF2G64TZHM4TONJXGM2DGMJZHNEXG43VMU5TMNJYHE4TGNZTG422C5QC . You are receiving this because you authored the thread.Message ID: <anomalyco/opencode/issues/66166/7142648847 @.***>
Thanks for the details. I tried again with them, but it still doesn't reproduce on 2.3.0.
What I did, with your providers.main block plus "update": "disable" kept in a separate dotfiles folder:
- Symlinked it two ways:
~/.config/opencodepointing at the dotfiles folder, and onlyopencode.jsonas a symlink. - Started
opencode serve --servicethe way systemd would (onlyHOMEandPATHset, working directory/). - Checked
/api/providerand/api/config, restarted the service, checked again, then ranPOST /api/location/reloadand checked once more.
In every check main was listed and providers was in the config document.
The symlinked folder does show the known watcher problem from #55119. The log has failed to subscribe ... inotify_add_watch on '.../.config/opencode' failed: Not a directory, so the service doesn't watch that folder for edits. Even so, the file was read in full at each boot, so this alone doesn't explain the missing providers you saw.
When the broken state comes back, these would help:
- The full output of
opencode api get /api/config - The log lines from that boot around
location services booted, and anyfailed to subscribeor config errors - Your systemd unit file (leave out any secrets), especially
Environment=,WorkingDirectory=,ExecStart=and anyAfter=/Requires=lines - Where the symlink points: is the target on another mount or drive, or inside a git repo that might be on another branch or checkout when the service starts?
A reply here with those is enough.
Taking this. The shape I'm chasing: the config plugin reads config.entries() once at construction and re-applies on config.updated; if the global document lands after the Location's plugins were built and that arrival doesn't publish config.updated, the provider transforms never see it — and POST /api/location/reload rebuilding the Location is exactly what would fix it, which matches the report. I'll confirm against packages/core/src/config.ts and the boot path before touching anything.
Withdrawing my offer too — same reason as #66146, and I'd rather not open a guess.
The race I described in my last comment is already closed in the code:
packages/core/src/config/plugin/entry-observer.ts:14-19reads the entries, then subscribes, then re-reads with the comment "Close the race between the first read and establishing the subscription.":20-23re-reads and calls the plugin'sreloadon everyconfig.updated, and the provider plugin's reload isctx.integration.reload().pipe(Effect.andThen(ctx.provider.reload()))(config/plugin/provider.ts:21-25).- The provider transform itself derives from
loaded.entries, which that observer keeps current (:57-95).
So a global document that arrives late does land, provided config.updated is published and config.entries() contains it. The remaining hole I can name is the one the bot already probed: a symlinked config directory, where the file watcher may not observe the real path — which would explain "only an explicit POST /api/location/reload registers them", because that rebuilds the Location and re-reads config without needing a watch event.
That is testable, but not by me from here: it needs your dotfiles layout (which path is the symlink, and whether the real path is inside the watched config directory). If you can paste, for the broken state:
readlink -f ~/.config/opencodeandreadlink -f ~/.config/opencode/opencode.json- the log lines around service start that mention
configorwatch - whether touching the real file (not the symlink) makes the provider appear without a reload
…then this becomes a real bug with a real seam, and I'll take it. Without that, a patch here would be a change to code that already handles the case it is being blamed for.
Thanks @s0nspark, and thanks @Guembri01 for looking into the code.
I'm closing this for now because we couldn't reproduce it. On 2.3.0, I set up your provider config with a symlinked ~/.config/opencode (and separately a symlinked opencode.json) and started serve --service the way systemd would. The custom provider was registered at every boot, after a restart, and after a reload. The symlink does trigger the known watcher error from #55119 (inotify_add_watch ... Not a directory), but the config was still read in full at boot.
We were waiting for details from the broken state:
- the output of
opencode api get /api/config - the log lines from that boot
- your systemd unit
- where the symlink points (
readlink -f ~/.config/opencode) - whether editing the real file makes the provider appear without a manual reload
If the problem comes back, reply here with those details and the issue will reopen.