You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OPENCODE_CONFIG_DIR overrides global AGENTS.md path instead of adding to it #28658
Setting OPENCODE_CONFIG_DIR prevents the global AGENTS.md from loading because the global instructions path and the config directory scan use different resolution strategies.
ConfigPaths.directories() in packages/opencode/src/config/paths.ts:26 always includes Global.Path.config (the static XDG path, ~/.config/opencode) in the directory list, so agents, commands, and skills from the XDG config dir are always discovered regardless of OPENCODE_CONFIG_DIR.
But instruction.ts:64 builds the global AGENTS.md path from global.config (the Service property), which resolves to OPENCODE_CONFIG_DIR when set. So the global instructions lookup skips ~/.config/opencode/AGENTS.md entirely.
The result: setting OPENCODE_CONFIG_DIR to add a secondary config directory (e.g. a workspace-level .opencode/) correctly picks up agents/commands/skills from both locations, but silently drops the global AGENTS.md unless you duplicate it into the override directory.
Steps to reproduce
Have a global AGENTS.md at ~/.config/opencode/AGENTS.md
Set OPENCODE_CONFIG_DIR to a different directory (e.g. /path/to/workspace/.opencode)
Start opencode
The global AGENTS.md is not loaded; only $OPENCODE_CONFIG_DIR/AGENTS.md is checked
Expected behavior
instruction.ts should use Global.Path.config (the static XDG path) for the global AGENTS.md, consistent with how ConfigPaths.directories() handles config directory scanning. OPENCODE_CONFIG_DIR should add to the search path, not replace the global instructions source.
Opened #47468 for this — instruction.ts and instruction-context.ts both build the global AGENTS.md path from the flag-overridden Global.Service.config instead of Global.Path.config, same root cause you described.
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
@thdxr The issue is still present in v2. There's already another open issue tagged with 2.0, #32825. The intended meaning of OPENCODE_CONFIG_DIR in v2 is still unclear to me (see my comment in the other issue), but I would like to bring the previous behaviour back if that's in any way possible.
Activity
chore: re-include global AGENTS.md displaced by OPENCODE_CONFIG_DIR
eminfedar commentedon Jul 20, 2026
Yeah, can't define global AGENTS.md in opencode, doesn't read the file. Global AGENTS.md should always be added in every chat.
minutechreview commentedon Sep 5, 2026
Opened #47468 for this — instruction.ts and instruction-context.ts both build the global AGENTS.md path from the flag-overridden Global.Service.config instead of Global.Path.config, same root cause you described.
hotzen commentedon Sep 26, 2026
this needs to be resolved asap, please!
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
cbrachem commentedon Oct 13, 2026
@thdxr The issue is still present in v2. There's already another open issue tagged with
2.0, #32825. The intended meaning ofOPENCODE_CONFIG_DIRin v2 is still unclear to me (see my comment in the other issue), but I would like to bring the previous behaviour back if that's in any way possible.