[Bug] `ocx opencode` injects nothing when an opencode v2 background service is already running
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- cli
Research direction
Start in src/cli/opencode.ts at buildOpencodeEnv and the spawn(inv.file, inv.args, { env }) call around lines 696-704, then reproduce with the isolated XDG home in the report by starting an opencode background service before running ocx opencode debug config. Read how the launcher detects or connects to an existing service, and compare the --standalone and cold-autostart paths that already work. Done means a warm service either receives the generated provider.opencodex / providers.opencodex blocks or the launcher stops printing the success line and fails loudly; the fix approach still needs a maintainer decision.
Written by the indexing model from the issue text.
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: NONE
Controls, 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.json
The 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.
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.3k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 814
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lidge-jun/opencodex
-
bug gui platform
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
lidge-jun/opencodex#9172 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
[Feature]: Include provider, model and account label in the `upstream failure` service.log linePossibly taken @EnesKartal claimed this 4 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
lidge-jun/opencodex#9057 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
[Provider] antigravity-acp catalog omits gemini-4-hydrogen and gemini-4-neon that agy acp offersPossibly taken @sedoll claimed this 6 days ago. Opencatalog provider provider-compatibility
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
lidge-jun/opencodex#9037 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
bug cli
Difficulty 4/5 3-5 days Newbie friendliness 52/100
lidge-jun/opencodex#9171 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
account-pool enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
All issues in lidge-jun/opencodex
Similar issues
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 64/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
ranxianglei/billion-context#7860 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
agent-oc-find-bugs api complexity → simple payment-methods recurring contributions reviewed stripe
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
opencollective/opencollective#9177 ·