hermes - ✅(Solved) Fix SubdirectoryHintTracker only loads the first matching hint file in a directory [2 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#14537Fetched 2026-04-24 06:16:38
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×2

Fix Action

Fixed

PR fix notes

PR #14561: fix(agent): load all subdirectory hint files

Description (problem / solution / changelog)

Summary

  • load every supported hint file found in a newly visited subdirectory instead of stopping at the first match
  • preserve existing formatting and truncation behavior for each discovered hint file
  • add a regression test covering a directory that contains both AGENTS.md and .cursorrules

Testing

  • python3 -m pytest -o addopts='' tests/agent/test_subdirectory_hints.py -q

Issue

  • closes #14537

Changed files

  • agent/subdirectory_hints.py (modified, +0/-2)
  • tests/agent/test_subdirectory_hints.py (modified, +18/-0)

PR #14593: fix(hints): load all hint files per directory, not just the first

Description (problem / solution / changelog)

Problem

Closes #14537

SubdirectoryHintTracker._load_hints_for_directory() contains an unconditional break at the end of the per-filename try block. This stops the loop after the first matching file, silently dropping any other hint files in the same directory (e.g. AGENTS.md + .cursorrules).

The module docstring and issue description both state that all matching hint files should be loaded.

Root Cause

# agent/subdirectory_hints.py  (before)
found_hints.append((rel_path, content))
# First match wins per directory (like startup loading)
break  # ← stops after first file

Fix

Remove the break. The found_hints list and the sections-building code below the loop already handle multiple entries correctly — only the early exit was wrong.

# after
found_hints.append((rel_path, content))
# (no break — continue to next filename)

Minimal Reproduction (from issue)

import tempfile
from pathlib import Path
from agent.subdirectory_hints import SubdirectoryHintTracker

with tempfile.TemporaryDirectory() as td:
    wd = Path(td)
    sub = wd / 'pkg'
    sub.mkdir()
    (sub / 'AGENTS.md').write_text('agents rules')
    (sub / '.cursorrules').write_text('cursor rules')

    tracker = SubdirectoryHintTracker(str(wd))
    result = tracker._load_hints_for_directory(sub)
    print(result)

Before: only agents rules (cursor rules silently dropped) After: both agents rules and cursor rules

Tests Added

  • test_loads_all_hint_files_in_directory — AGENTS.md + .cursorrules both appear in result
  • test_first_hit_does_not_suppress_subsequent_files — two distinct hint files both loaded
  • test_single_hint_file_still_works — regression guard for single-file directories

Changed files

  • agent/subdirectory_hints.py (modified, +0/-2)
  • tests/agent/test_subdirectory_hints.py (modified, +52/-0)

Code Example

source venv/bin/activate
python - <<'PY'
import tempfile
from pathlib import Path
from agent.subdirectory_hints import SubdirectoryHintTracker

with tempfile.TemporaryDirectory() as td:
    wd = Path(td)
    sub = wd / 'pkg'
    sub.mkdir()
    (sub / 'AGENTS.md').write_text('agents rules')
    (sub / '.cursorrules').write_text('cursor rules')

    tracker = SubdirectoryHintTracker(str(wd))
    print(tracker._load_hints_for_directory(sub))
PY
RAW_BUFFERClick to expand / collapse

Bug Description

SubdirectoryHintTracker says it loads all supported hint files found in a visited directory, but _load_hints_for_directory() stops after the first match. When a directory contains more than one supported context file (for example AGENTS.md plus .cursorrules), the later files are silently dropped.

Affected files / lines

  • agent/subdirectory_hints.py:26-28 — module comment says “we load ALL found (not first-wins)”
  • agent/subdirectory_hints.py:175-206 — loop appends one file then breaks on the first match

Why this is a bug

This is not just a stale comment: the current implementation drops real context that the module says it should surface. A project can legitimately keep both AGENTS.md and .cursorrules in the same directory, but only the first filename in _HINT_FILENAMES is injected.

Minimal reproduction

source venv/bin/activate
python - <<'PY'
import tempfile
from pathlib import Path
from agent.subdirectory_hints import SubdirectoryHintTracker

with tempfile.TemporaryDirectory() as td:
    wd = Path(td)
    sub = wd / 'pkg'
    sub.mkdir()
    (sub / 'AGENTS.md').write_text('agents rules')
    (sub / '.cursorrules').write_text('cursor rules')

    tracker = SubdirectoryHintTracker(str(wd))
    print(tracker._load_hints_for_directory(sub))
PY

Current output contains only AGENTS.md content and omits .cursorrules.

Expected Behavior

If multiple supported hint files exist in the same visited directory, all of them should be loaded (or the docs/comments should be corrected and callers should explicitly know only one file is used).

Actual Behavior

The first matching filename wins within a directory, and the rest are skipped.

Suggested investigation direction

  • Remove the per-directory break so all matching files are collected, and
  • add a regression test covering a directory that contains both AGENTS.md and .cursorrules.

extent analysis

TL;DR

Remove the break statement in the _load_hints_for_directory() method to allow loading of all supported hint files in a directory.

Guidance

  • Review the _load_hints_for_directory() method in agent/subdirectory_hints.py and remove the break statement after the first match to enable loading of all supported hint files.
  • Add a regression test to cover the scenario where a directory contains both AGENTS.md and .cursorrules to ensure the fix works as expected.
  • Verify that the SubdirectoryHintTracker loads all supported hint files by running the provided minimal reproduction script after applying the fix.
  • Consider updating the module comment to reflect the corrected behavior.

Example

# agent/subdirectory_hints.py:175-206
for filename in _HINT_FILENAMES:
    filepath = directory / filename
    if filepath.exists():
        # Load the hint file and append to the list
        hints.append(load_hint_file(filepath))
        # Remove the break statement to allow loading of all supported hint files
        # break

Notes

The provided minimal reproduction script can be used to verify the fix. After applying the fix, the script should output the contents of both AGENTS.md and .cursorrules.

Recommendation

Apply the workaround by removing the break statement in the _load_hints_for_directory() method, as this will allow the SubdirectoryHintTracker to load all supported hint files in a directory.

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