[PR #11536] fix: prioritize OPENCODE_CONFIG_DIR for AGENTS.md #13828

Closed
opened 2026-02-16 18:18:39 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11536

State: closed
Merged: Yes


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11536 **State:** closed **Merged:** Yes --- ## 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: <img width="1260" height="1401" alt="image" src="https://github.com/user-attachments/assets/126c23b6-8b55-4cc5-beb9-06b3efc6136c" /> Fixes #11534
yindo added the pull-request label 2026-02-16 18:18:39 -05:00
yindo closed this issue 2026-02-16 18:18:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13828