Repository navigation
Description
Client or integration
Other
Area
CLI
Summary
ocx opencode reports that it wired the proxy and injected its provider blocks, but when an
opencode v2 background service is already running, the launched instance never sees those
blocks. The launcher's only output is a success line, so the failure is silent: the models it
just advertised are absent from the running opencode.
--standalone, and a cold start where no service exists yet, both work.
Reproduction
Isolated home so the test cannot touch a real config; opencode v2.3.2:
export XDG_STATE_HOME=/tmp/ocx-bug1/state XDG_DATA_HOME=/tmp/ocx-bug1/data \
XDG_CONFIG_HOME=/tmp/ocx-bug1/config XDG_CACHE_HOME=/tmp/ocx-bug1/cache
mkdir -p "$XDG_STATE_HOME" "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
# 1. Start the background service the way an earlier plain `opencode` run would.
opencode service set port 51177
opencode service start # -> http://127.0.0.1:51177
# 2. Launch through the launcher against that warm service.
ocx opencode debug config > c.json
# stderr: "✅ opencode wired to http://127.0.0.1:10100/v1 — 3 model(s) under provider `opencodex`."
# 3. Look for the injected blocks in what the instance actually loaded.
python3 -c '
import json; d=json.load(open("c.json")); out=[]
for s in d:
info=s.get("info") or {}
for blk in ("provider","providers"):
b=(info.get(blk) or {}).get("opencodex")
if b: out.append((blk,len(b.get("models") or {})))
print("opencodex blocks visible:", out or "NONE")'
# -> opencodex blocks visible: NONEControls, same isolated home:
| Scenario | opencodex blocks loaded |
|---|---|
Warm background service, then ocx opencode |
NONE |
ocx opencode debug config --standalone |
providers, 3 models |
Service stopped, then ocx opencode (cold autostart) |
providers, 3 models |
Expected behavior
The launched opencode should load the generated provider.opencodex / providers.opencodex
blocks in every case, or the launcher should refuse to claim success when it cannot deliver them.
Observed behavior
With a warm service the blocks are dropped entirely, and the launcher still prints the success
line, so the user only finds out when the models are missing from the picker.
Likely cause
src/cli/opencode.ts builds the env and spawns opencode with it
(buildOpencodeEnv -> spawn(inv.file, inv.args, { env }), around line 696-704). That env reaches
the client process only. When an opencode v2 background service is already listening, the
client connects to that daemon and the daemon serves config it loaded when it started — before
any OPENCODE_CONFIG_CONTENT existed in its environment. opencode's own help describes
--standalone as "Run with a private server instead of the background service", which matches
the observed split.
What I ruled out
A restart-with-the-runtime-layer fix does not work, so it is not on the table. I started the
service with OPENCODE_CONFIG_CONTENT already set in its own environment, and the daemon still
loaded no opencodex blocks — the variable is not present in the daemon process at all. A
background service therefore cannot be told about the proxy by injection under any restarted
state, which leaves only genuinely different approaches.
Still open, and a maintainer's call: run a private server (--standalone) whenever a service is
warm, which guarantees the injected layer applies but gives up the shared session the service
provides; or make the launcher fail loudly instead of printing the success line when the blocks
cannot be applied; or write a static block through the managed integration path. Each has a real
cost, so this is a report rather than a proposal.
Workaround
A static exported block on disk is read by the service and does work:
ocx export --client opencode # merge the two blocks into ~/.config/opencode/opencode.jsonThe catch is that export is a snapshot: it does not follow catalog or visibility changes.
Version
opencodex 2.100.8 (npm install). Also reproduced from a local dev checkout at 9e0e298e
(the current dev tip, package.json version 2.100.0, run as bun bin/ocx.mjs).
Operating system
macOS 27.2.0 (Darwin), Bun 1.4.4, opencode v2.3.2
Logs or error output
$ ocx opencode debug config
✅ opencode wired to http://127.0.0.1:10100/v1 — 3 model(s) under provider `opencodex`.
Your existing opencode config files are left untouched; only the runtime provider blocks are injected.
RESULT opencodex blocks visible to the warm daemon: NONE
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
github-actions commentedon Nov 22, 2026
Issue reopened
The report now contains the information required by the automated check. Thanks for updating it.
lidge-jun commentedon Nov 25, 2026
Confirmed from source.
ocx opencodedelivers its provider blocks only throughOPENCODE_CONFIG_CONTENTin the environment of the spawned client (buildOpencodeEnvinsrc/cli/opencode.ts), and it prints the success line unconditionally. A background service that is already running never sees that variable. The three fixes in the report (auto--standalonewhen a service is warm, refusing to claim success, or a managed static block) are product choices, so this waits on a maintainer decision. Until then,--standaloneorocx export --client opencodeare the workarounds.yogesh-aggarwal commentedon Nov 25, 2026
Fair, that is your call.
One correction to my own report: restarting the service with the runtime layer already in its env does not work either. I tried it and the daemon still loads nothing, so
--standaloneis the only thing that gets through today. Might save someone an hour.If it helps:
opencode service statusexits 0 in both states and just printsstoppedor the URL, so detecting a warm service is cheap. Happy to build whichever you pick.