Skip to content

Config update writes config.json, which config discovery never reads #43613

Description

@EthanZhao0710

Description

Config.update — the code path behind PATCH /config — writes <project>/config.json, but project config discovery only reads opencode.json / opencode.jsonc (ConfigPaths.files("opencode", ...)). The update lands in a file that is never loaded again, so it has no effect and leaves a stray config.json in the project.

This was reported in #4194 and fixed in #4205; that PR was closed as stale and the issue was auto-closed for inactivity, with the note to open a new one if it is still relevant. It still reproduces on dev.

I have a fix + tests ready and can open a PR.

Steps to reproduce

  1. Project with opencode.json containing "model": "anthropic/claude-sonnet-4-5"
  2. opencode serve --port 4199
  3. curl -X PATCH http://127.0.0.1:4199/config \
      -H 'content-type: application/json' \
      -H "x-opencode-directory: $PROJECT" \
      -d '{"model":"anthropic/claude-opus-4-5"}'
    

Response is 200 {"model":"anthropic/claude-opus-4-5"}, but on disk:

$ ls $PROJECT
config.json      opencode.json

$ cat $PROJECT/opencode.json      # still the old model
{ "$schema": "https://opencode.ai/config.json", "model": "anthropic/claude-sonnet-4-5" }

$ cat $PROJECT/config.json        # written, but never read back
{ "model": "anthropic/claude-opus-4-5" }

Restarting keeps the old model.

OpenCode version

dev @ b155b15 (v1.18.19)

Operating System

macOS (Darwin 25.5)

Metadata

Metadata

Assignees

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