Repository navigation
Description
What occurs
OpenCode 2.1.4 reads agent files through a directory symlink at startup, but it misses subsequent edits to the external target.
A new session then sends the previous agent body to the model.
The same test works when the agent directory is a non-symlink directory in the configuration directory.
The test used Linux, isolated HOME and XDG directories, and a local OpenAI-compatible HTTP server.
The HTTP server recorded each request and sent the same streamed response.
The configuration had no third-party extensions.
Steps with the clean reproduction
- Make isolated configuration, data, state, cache, home, and external directories.
- Set
HOME,XDG_CONFIG_HOME,XDG_DATA_HOME,XDG_STATE_HOME, andXDG_CACHE_HOMEto these isolated directories. - Make an
agentsdirectory in the external directory. - Make this agent file at
external/agents/probe.md:
---
mode: primary
description: Reload probe
---
AGENT_BASELINE_814.- Make
config/opencode/agentsa symlink toexternal/agents. - Configure a local OpenAI-compatible provider in
config/opencode/opencode.json. - Use
aisdk:@ai-sdk/openai-compatibleas its package and the local HTTP server URL assettings.baseURL. - Start one
opencode serve --serviceprocess. - Run
opencode run --agent probewith a short message in a new session. - Make sure the primary provider request contains
AGENT_BASELINE_814. - Append
LINKED_AGENT_EDIT_814to the external agent file without a rename. - Wait 15 seconds.
- Run
opencode run --agent probewith a different message in a new session. - Examine the primary provider request, not the different request for the session title.
Correct result
The new primary request contains the updated agent body with LINKED_AGENT_EDIT_814.
Actual
The primary request keeps AGENT_BASELINE_814 but does not contain LINKED_AGENT_EDIT_814.
The model itself does not control this result. The recorded request body shows it.
Controls in the same clean environment:
| Source | Result after an in-place edit |
|---|---|
| Agent file in a non-symlink configuration subdirectory | The new session receives the edit. |
| Agent file through an external directory symlink | The new session keeps the previous body. |
| Explicit instruction file through an external directory symlink | The new session receives the edit. |
| Skill description through an external directory symlink | The new session receives the edit. |
The instruction and skill controls used dedicated watcher subscriptions on their resolved targets.
The log showed no watcher subscription on the external agent target.
Source locations on dev
Source snapshot: 17b79f4e0c16dcff200b0417567ed22aeb2d7166.
The runtime test used 2.1.4. This dev snapshot contains the same agent and watch-plan code.
These files have no changes from that snapshot to dev at 32b57015e5b491a789fba1534ecb472e676c9d8e.
config/plugin/agent.ts:41-83caches agent documents and reloads them from configuration events.config/plugin/agent.ts:132-174follows symlinks during discovery but adds no target watcher subscription.config/watch.ts:8-39monitors configuration roots, not external targets of nested agent-directory symlinks.config.ts:301-329forwards watcher events to configuration consumers.config/plugin/instruction.ts:130-143resolves and monitors instruction files directly.config/plugin/skill.ts:56-64monitors resolved skill-directory targets directly.
Related reports: #51936, #53920, and #54933 (different symlink positions).
PR #54093 monitors symlinked watcher roots, not a symlinked child directory in a non-symlink configuration root.
Activity
opencode-agent commentedon Oct 25, 2026
Thanks for the detailed report. I reproduced this on 2.1.4, and it still happens on the latest
dev(32b57015e).I used an isolated HOME and XDG directories and a mock OpenAI-compatible server that records each request:
agents/:$XDG_CONFIG_HOME/opencode/agentspointed to an external directory containingprobe.md. The firstopencode run --agent probesentAGENT_BASELINE_814. I then appendedLINKED_AGENT_EDIT_814to the target file in place, waited 15s and ran a new session. Its request still had only the old body.agents/as a normal directory, the same edit showed up in the next session.The script below reproduces both cases (
MODE=symlinkorMODE=plain). It startsopencode serve --portand passes--servertoopencode run, instead of usingserve --service.The code agrees with your analysis. Agent discovery follows the symlink when it first loads the files, but nothing watches the symlink's target. Skills and instructions do watch their resolved targets. Related: #53920 / #53932 (symlinked config files), #54933 and #55119 (symlinked config root), #54093 (symlinked watcher roots).
Reproduction script (repro.sh)
Run it:
bash repro.shfix(config): watch single-file symlinks and test via Watcher.Test (an…
fix(config): avoid redundant file watches and use objectContaining in…
ngbrown commentedon Nov 12, 2026
Potentially related reproduction on Windows, OpenCode v2.2.6, affecting commands rather than agents.
My project’s
.opencode/commandsis a directory symlink to..\.agents\commands.While OpenCode already had an active session in a repository, I created
.agents/commands/make-it-so.md. The new command did not appear in slash-command autocomplete.Running
/reloadmade/make-it-soappear without changing the file. This suggests manual discovery follows the symlink, but automatic watching misses newly added files in its target.Is this covered by this issue, or would you prefer a separate report for commands on Windows?
georgernstgraf commentedon Nov 28, 2026
Confirmed still present on v2.4.2 (Linux, inotify backend) — and this hits a very practical real-world pattern: the dotfiles-style setup where
~/.config/opencode/{skills,agents,commands}are symlinks into a shared git repo that several hosts pull. Discovery follows the links fine at startup; hot-reload does not.Reproduction results (service running, changes made inside the symlinked targets; identical actions with non-symlinked config subdirectories all pass):
agents/probe.md)commands/probe.md)Two additions to the report:
New files, not only edits. Newly added agent/command
.mdfiles inside symlinked global config subdirs never appear while the service runs (matches ngbrown's Windows commands observation above, now confirmed on Linux and for the global config dirs, not only project.opencode).The asymmetry is the bug. In the very same symlinked setup, skills hot-reload correctly — including brand-new skill directories — because the skill plugin watches the resolved target recursively plus the link itself as a file (
config/plugin/skill.ts:62-66):No equivalent subscription is ever created for the
agents/commandstargets — their reload path isconfig.changes()filtered byisDirectorySource(config/plugin/agent.ts,config/plugin/command.ts), which misses events arriving under the resolved path. Applying the skill plugin's dual-watch pattern (resolved directory watch + link-as-file watch) to agent/command sources would cover this class.Isolated repro (temp XDG dirs,
symlinkvsrealcontrol, tested on v2.4.2):Side note: in repeated runs, in-place edits to an existing agent file through the link loaded only intermittently, depending on how the file is modified (append vs atomic replace) — consistent with events silently being dropped rather than a hard failure. Related but distinct positions are already tracked separately (#54933 = config root itself symlinked, watch subscription fails outright; PR #54093 resolves watch roots but explicitly does not cover symlinked child directories).
Duplicate check (2026-11-28): reused this issue instead of filing a new one. Checked: #54933, #52701, #52240, #53763, #53920, #53811 and searches for "symlink", "watch reload config", "skills reload" — all cover different symlink positions or platforms.