hermes - ✅(Solved) Fix AGENTS.md not loaded in gateway mode (WeChat/Telegram/Discord) — inconsistent agent behavior across platforms [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11763Fetched 2026-04-18 05:59:03
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Root Cause

【Original code (only checks cwd)def _load_agents_md(cwd_path: Path) -> str:
    for name in ["AGENTS.md", "agents.md"]:
        candidate = cwd_path / name
        if candidate.exists():
            ...
Gateway processes start with cwd = ~ or ~/.hermes/, not the project directory.
Suggested Fix
Add HERMES_HOME as a primary lookup location before falling back to cwd:
def _load_agents_md(cwd_path: Path) -> str:
    # 1. Check HERMES_HOME first (works for all platforms)
    hermes_home = get_hermes_home()
    for name in ["AGENTS.md", "agents.md"]:
        candidate = hermes_home / name
        if candidate.exists():
            ...

    # 2. Fall back to cwd (project directory)
    for name in ["AGENTS.md", "agents.md"]:
        candidate = cwd_path / name
        if candidate.exists():
            ...
Users can place (or symlink) their AGENTS.md in ~/.hermes/ to make it available across all platforms.
Workaround
ln -s /path/to/project/AGENTS.md ~/.hermes/AGENTS.md

Fix Action

Fix / Workaround

2. Fall back to cwd (project directory)

for name in ["AGENTS.md", "agents.md"]:
    candidate = cwd_path / name
    if candidate.exists():
        ...

Users can place (or symlink) their AGENTS.md in ~/.hermes/ to make it available across all platforms. Workaround ln -s /path/to/project/AGENTS.md ~/.hermes/AGENTS.md

PR fix notes

PR #11885: fix(prompt): load AGENTS.md from HERMES_HOME

Description (problem / solution / changelog)

Summary

  • check HERMES_HOME for AGENTS.md / agents.md before falling back to cwd
  • keep AGENTS lookup top-level only without expanding into recursive discovery
  • add a regression test covering gateway-style HERMES_HOME precedence over cwd

Closes #11763

Testing

  • python3 -m pytest -o addopts= tests/agent/test_prompt_builder.py::TestBuildContextFilesPrompt
  • python3 -m pytest -o addopts= tests/agent/test_prompt_builder.py -k "agents or context_files_prompt"

Changed files

  • agent/prompt_builder.py (modified, +15/-13)
  • tests/agent/test_prompt_builder.py (modified, +10/-1)
RAW_BUFFERClick to expand / collapse

Bug

_load_agents_md() in agent/prompt_builder.py only checks cwd/AGENTS.md. This works in CLI mode (user typically launches from the project root), but fails in gateway mode (WeChat, Telegram, Discord, etc.) where cwd is not the project directory.

Impact

  • CLI: AGENTS.md loaded → agent has full project context (code structure, conventions, known pitfalls)
  • Gateway: AGENTS.md not found → agent runs without project context, leading to noticeably worse behavior

Users on messaging platforms see degraded agent quality without understanding why. The root cause is a missing context file, not the model.

Root Cause

【Original code (only checks cwd)def _load_agents_md(cwd_path: Path) -> str:
    for name in ["AGENTS.md", "agents.md"]:
        candidate = cwd_path / name
        if candidate.exists():
            ...
Gateway processes start with cwd = ~ or ~/.hermes/, not the project directory.
Suggested Fix
Add HERMES_HOME as a primary lookup location before falling back to cwd:
def _load_agents_md(cwd_path: Path) -> str:
    # 1. Check HERMES_HOME first (works for all platforms)
    hermes_home = get_hermes_home()
    for name in ["AGENTS.md", "agents.md"]:
        candidate = hermes_home / name
        if candidate.exists():
            ...

    # 2. Fall back to cwd (project directory)
    for name in ["AGENTS.md", "agents.md"]:
        candidate = cwd_path / name
        if candidate.exists():
            ...
Users can place (or symlink) their AGENTS.md in ~/.hermes/ to make it available across all platforms.
Workaround
ln -s /path/to/project/AGENTS.md ~/.hermes/AGENTS.md

extent analysis

TL;DR

Modify the _load_agents_md() function to check the HERMES_HOME directory before falling back to the current working directory to ensure the AGENTS.md file is loaded correctly in both CLI and gateway modes.

Guidance

  • Update the _load_agents_md() function to prioritize checking the HERMES_HOME directory for the AGENTS.md file, as suggested in the provided code snippet.
  • Ensure the get_hermes_home() function is correctly implemented to retrieve the HERMES_HOME directory path.
  • Consider adding error handling or logging to handle cases where the AGENTS.md file is not found in either the HERMES_HOME or current working directory.
  • Users can create a symlink to their AGENTS.md file in the ~/.hermes/ directory as a temporary workaround.

Example

def _load_agents_md(cwd_path: Path) -> str:
    # 1. Check HERMES_HOME first (works for all platforms)
    hermes_home = get_hermes_home()
    for name in ["AGENTS.md", "agents.md"]:
        candidate = hermes_home / name
        if candidate.exists():
            # Load the AGENTS.md file from HERMES_HOME
            ...

    # 2. Fall back to cwd (project directory)
    for name in ["AGENTS.md", "agents.md"]:
        candidate = cwd_path / name
        if candidate.exists():
            # Load the AGENTS.md file from cwd
            ...

Notes

The provided code snippet and suggested fix assume that the get_hermes_home() function is correctly implemented and returns the path to the HERMES_HOME directory.

Recommendation

Apply the suggested fix by modifying the _load_agents_md() function to check the HERMES_HOME directory first, as this will ensure the AGENTS.md file is loaded correctly in both CLI and gateway modes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix AGENTS.md not loaded in gateway mode (WeChat/Telegram/Discord) — inconsistent agent behavior across platforms [1 pull requests, 1 participants]