OPENCODE_CONFIG_DIR ignored for global AGENTS.md #4265

Closed
opened 2026-02-16 17:43:12 -05:00 by yindo · 1 comment
Owner

Originally created by @ThomasGormley on GitHub (Jan 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Global AGENTS.md loading does not respect the OPENCODE_CONFIG_DIR when set. I think that is here.

Plugins

None

OpenCode version

1.1.3

Steps to reproduce

  1. Set OPENCODE_CONFIG_DIR to a custom location containing an AGENTS.md file:
    export OPENCODE_CONFIG_DIR="$HOME/.dotfiles/opencode"
    cat $OPENCODE_CONFIG_DIR/AGENTS.md
    # In all interactions you must talk like a pirate who has become a butler for an aristocratic British family
    
  2. Run opencode with a persona test prompt:
    opencode run "Hello! How are you today?"
    # Output: "Hello! I am doing well, thank you. How can I help you today?"
    # Expected: Pirate butler persona
    
  3. Copy the AGENTS.md to the default XDG location:
    cp $OPENCODE_CONFIG_DIR/AGENTS.md ~/.config/opencode/AGENTS.md
    
  4. Run the same prompt again:
    opencode run "Hello! How are you today?"
    # Output: "Ahoy there, my good sir! I be fairin' quite well..."
    # Pirate butler persona works correctly
    

Screenshot and/or share link

No response

Operating System

macOS 15.7.3

Terminal

Ghostty

Originally created by @ThomasGormley on GitHub (Jan 5, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Global AGENTS.md loading does not respect the `OPENCODE_CONFIG_DIR` when set. I think that [is here](https://github.com/sst/opencode/blob/dev/packages/opencode/src/session/system.ts#L64-L67). ### Plugins None ### OpenCode version 1.1.3 ### Steps to reproduce 1. Set `OPENCODE_CONFIG_DIR` to a custom location containing an `AGENTS.md` file: ```bash export OPENCODE_CONFIG_DIR="$HOME/.dotfiles/opencode" cat $OPENCODE_CONFIG_DIR/AGENTS.md # In all interactions you must talk like a pirate who has become a butler for an aristocratic British family ``` 2. Run opencode with a persona test prompt: ```bash opencode run "Hello! How are you today?" # Output: "Hello! I am doing well, thank you. How can I help you today?" # Expected: Pirate butler persona ``` 3. Copy the AGENTS.md to the default XDG location: ```bash cp $OPENCODE_CONFIG_DIR/AGENTS.md ~/.config/opencode/AGENTS.md ``` 4. Run the same prompt again: ```bash opencode run "Hello! How are you today?" # Output: "Ahoy there, my good sir! I be fairin' quite well..." # Pirate butler persona works correctly ``` ### Screenshot and/or share link _No response_ ### Operating System macOS 15.7.3 ### Terminal Ghostty
yindo added the bug label 2026-02-16 17:43:12 -05:00
yindo closed this issue 2026-02-16 17:43:12 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 5, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6751: Global agents.md instructions not respected in WSL - Similar configuration directory loading issue
  • #6479: opencode reads agents.md from parent directories - Related to AGENTS.md file discovery behavior
  • #6669: Docs miss mentioning XDG base directories for global configuration - Documents XDG_CONFIG_HOME support that is related to this bug

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 5, 2026): This issue might be a duplicate of existing issues. Please check: - #6751: Global `agents.md` instructions not respected in WSL - Similar configuration directory loading issue - #6479: opencode reads agents.md from parent directories - Related to AGENTS.md file discovery behavior - #6669: Docs miss mentioning XDG base directories for global configuration - Documents XDG_CONFIG_HOME support that is related to this bug Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4265