Skip to content

feat: load AGENTS.md from profile directory first, fall back to cwd - #52580

Open
xmhcte wants to merge 1 commit into
NousResearch:mainfrom
xmhcte:pm/pr-feat-agents-md-profile-first
Open

xmhcte wants to merge 1 commit into
NousResearch:mainfrom
xmhcte:pm/pr-feat-agents-md-profile-first

Conversation

@xmhcte

@xmhcte xmhcte commented Jun 25, 2026

Copy link
Copy Markdown

Currently AGENTS.md is only loaded from the workspace/cwd directory. For multi-profile setups (e.g. distinct role rules per profile), each profile needs its own AGENTS.md with role-specific constraints.

This change introduces a profile-first lookup: get_hermes_home()/AGENTS.md takes priority, cwd/AGENTS.md serves as fallback. This mirrors the existing SOUL.md loading pattern.

Currently AGENTS.md is only loaded from the workspace/cwd directory. For multi-profile setups (e.g. distinct role rules per profile), each profile needs its own AGENTS.md with role-specific constraints.

This change introduces a profile-first lookup: get_hermes_home()/AGENTS.md takes priority, cwd/AGENTS.md serves as fallback. This mirrors the existing SOUL.md loading pattern.
@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jun 25, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused profile-context proposal.

Problems

  • agent/prompt_builder.py:1685 returns profile AGENTS.md before checking the workspace. That suppresses a repository's project instructions whenever the profile file exists. Current main documents AGENTS.md as CWD project context (website/docs/user-guide/features/context-files.md:16,28-32) and reserves $HERMES_HOME/SOUL.md for profile-wide identity (website/docs/user-guide/features/personality.md:32-47). Commit 725831171 also deliberately limited AGENTS startup lookup to the working-directory root.
  • The PR changes this resolution contract without tests. Main's existing contract test is tests/agent/test_prompt_builder.py:758-766; no profile-vs-workspace precedence or fallback test is included.

Suggested changes

  • Please have maintainers settle the desired profile-wide instruction surface and its precedence relative to workspace instructions before changing this loader. If profile-level AGENTS is adopted, document the resulting contract and add hermetic tests for profile-only, workspace-only, both-present, and empty-profile cases.

Automated hermes-sweeper review.

Comment thread agent/prompt_builder.py
hermes_home = get_hermes_home()
for name in ["AGENTS.md", "agents.md"]:
# Profile-level AGENTS.md takes priority (mirrors SOUL.md pattern)
profile_candidate = hermes_home / name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This precedence makes a profile AGENTS.md suppress the workspace AGENTS.md rather than fall back to it. Current main treats AGENTS.md as CWD project context and HERMES_HOME/SOUL.md as profile-wide identity; please settle and document the intended source-of-truth/precedence before changing this branch.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users area/profiles Multi-profile isolation, HERMES_HOME scoping labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants