Skip to content

fix: prioritize OPENCODE_CONFIG_DIR for AGENTS.md#11536

Merged
rekram1-node merged 2 commits intoanomalyco:devfrom
lgladysz:fix/opencode-config-dir-agents-priority
Feb 4, 2026
Merged

fix: prioritize OPENCODE_CONFIG_DIR for AGENTS.md#11536
rekram1-node merged 2 commits intoanomalyco:devfrom
lgladysz:fix/opencode-config-dir-agents-priority

Conversation

@lgladysz
Copy link
Contributor

@lgladysz lgladysz commented Jan 31, 2026

Summary

When OPENCODE_CONFIG_DIR is set, the AGENTS.md from that directory should be loaded instead of the global one. Currently, global ~/.config/opencode/AGENTS.md is always checked first and the loop breaks, so profile-specific AGENTS.md is never reached.

Changes

  • Check OPENCODE_CONFIG_DIR first in globalFiles() and return early if set
  • This makes profiles isolated environments with their own configuration

Test Plan

  1. Create global AGENTS.md: echo "# Global" > ~/.config/opencode/AGENTS.md
  2. Create profile AGENTS.md: mkdir -p ~/.config/opencode/profiles/work && echo "# Work" > ~/.config/opencode/profiles/work/AGENTS.md
  3. Set OPENCODE_CONFIG_DIR=~/.config/opencode/profiles/work
  4. Verify only the profile AGENTS.md is loaded

How I verified it is working:

  1. I prepared the AGENTS.md structure (global and profile).
  2. Ran OPENCODE_CONFIG_DIR=~/.config/opencode/profiles/work bun dev.
  3. Written hi in opencode.
  4. Result as below:
image

Fixes #11534

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR found:

The other results (PR #952 and #9657) appear to be about AGENTS.md recursive loading and subdirectory rule loading, which are different features rather than duplicates of the prioritization fix.

@lgladysz lgladysz changed the title fix: prioritize OPENCODE_CONFIG_DIR for AGENTS.md loading fix: prioritize OPENCODE_CONFIG_DIR for AGENTS.md Jan 31, 2026
@lgladysz lgladysz marked this pull request as ready for review January 31, 2026 23:24
@lgladysz lgladysz marked this pull request as draft February 3, 2026 18:56
@lgladysz lgladysz marked this pull request as ready for review February 3, 2026 20:46
@lgladysz lgladysz force-pushed the fix/opencode-config-dir-agents-priority branch from 6fe834f to d971c42 Compare February 3, 2026 22:32
@lgladysz lgladysz force-pushed the fix/opencode-config-dir-agents-priority branch from d971c42 to b6cea0f Compare February 3, 2026 23:25
@rekram1-node rekram1-node merged commit 299f411 into anomalyco:dev Feb 4, 2026
4 checks passed
mvclaudianobj pushed a commit to mvclaudianobj/markscode that referenced this pull request Feb 4, 2026
@lgladysz lgladysz deleted the fix/opencode-config-dir-agents-priority branch February 4, 2026 13:22
ishaksebsib pushed a commit to ishaksebsib/opencode that referenced this pull request Feb 4, 2026
ishaksebsib pushed a commit to ishaksebsib/opencode that referenced this pull request Feb 4, 2026
dmae97 pushed a commit to dmae97/opencode that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: AGENTS.md in OPENCODE_CONFIG_DIR is ignored when global AGENTS.md exists

2 participants