Skip to content

cli: debug config returns stale config after edits and cannot run standalone #48695

Open

Description

@sainzs

Summary

opencode2 debug config reports the shared service's cached configuration, not
what is on disk, so immediately after editing a config file the command returns
the previous value for roughly 1–3 seconds. There is no way to force a fresh
read: debug subcommands reject --standalone, which the troubleshooting
guidance otherwise recommends for isolating shared-service state. Callers that
edit config and then verify it (scripts, agents) can read a stale result.

Environment

  • opencode version: 0.0.0-beta-19271
  • OS: Darwin 25.5.0 (darwin arm64)
  • Terminal: TERM=xterm-256color, COLORTERM=truecolor (running inside a Herdr 0.8.2 pane)
  • Shell: /bin/zsh
  • Install/channel: beta (bun add -g @opencode-ai/[email protected])
  • Active plugins: none (opencode2 plugin list → "No plugins found")

Reproduction

  1. Create a scratch project with .opencode/opencode.json containing {"model":"probe/A"} and let the service load it.
  2. Run opencode2 debug config → reports probe/A.
  3. Rewrite the file to {"model":"probe/B"}.
  4. Immediately run opencode2 debug config → still reports probe/A.
  5. Wait ~1–3 s and run it again → reports probe/B.

Measured (disk value read directly; service value from debug config):

20.83s  disk=probe/A  svc=probe/A
# write probe/B
20.94s  disk=probe/B  svc=probe/A   <- stale
21.80s  disk=probe/B  svc=probe/B
# write probe/C
23.61s  disk=probe/C  svc=probe/B   <- stale
26.82s  disk=probe/C  svc=probe/C

The --standalone escape hatch does not work:

$ opencode2 --standalone debug config
ERROR  Unrecognized flag: --standalone in command opencode2 debug

$ opencode2 debug config --standalone
ERROR  Unrecognized flag: --standalone in command opencode2 debug config

Expected Behavior

debug config should report the configuration effective at the moment it runs,
or clearly label the snapshot it is reporting so callers know it may lag. If the
shared service caches config by design, there should be a way to request a fresh
read (--standalone, --server, or a --reload flag).

Actual Behavior

debug config returns the shared service's cached config for ~1–3 s after a
change, and no flag bypasses or refreshes that cache. An automation that edits
opencode.json and immediately verifies it reads a stale result.

Additional Context

Workaround used: sleep a few seconds between the edit and the verification, or
restart the service (opencode2 service restart) to force a reload.

Proposed Solution

  1. Prefer a fresh on-disk read for debug config, or invalidate the cached
    config when the source file mtime/etag changes.
  2. Accept --standalone/--server on debug (and its subcommands) so callers
    can query a freshly started private server instead of the shared service.
  3. Optionally add opencode2 debug config --reload and/or include the snapshot
    generation or loaded-at timestamp in the output.

Activity

  1. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and the timings!

    Your report has two parts:

    I've marked the rest as a feature request: a way for debug config to always reflect what is on disk, either by doing a fresh read or adding a --reload flag, or by including a loaded-at timestamp or snapshot number in its output so callers can tell whether it is out of date. 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