Repository navigation
feat(agent): point the agent at nested AGENTS.md files - #1392
Merged
Merged
Conversation
4 tasks
inference-gateway-maintainer
Bot
marked this pull request as ready for review
September 28, 2026 21:54
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
September 28, 2026 21:54
5 tasks
buildAgentsMDInfo now discovers AGENTS.md files below the working directory (up to 4 levels, hidden and vendored trees skipped) and injects them alongside the root file, each labeled with the directory it applies to. The combined text is budgeted nearest-file-first at agent.agents_md.max_chars so the file closest to the edited code keeps its instructions while shallower files are truncated or dropped. Resolves #1385
… them Injecting every nested brief spent the agent.agents_md.max_chars budget on package files first and truncated the root AGENTS.md in this repository. The root file is now injected whole as before. Nested files get a one-line precedence rule, and their paths are listed only when the project tree is off, since the tree already shows them. The model reads a brief when it works in that directory.
edenreich
force-pushed
the
fix/issue-1385
branch
from
September 28, 2026 22:55
89cff11 to
1b63f10
Compare
Contributor
|
🎉 This PR is included in version 0.218.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1385
Summary
infernow tells the model about nestedAGENTS.mdfiles below the working directory, following the agents.md standard for subprojects (https://agents.md). The rootAGENTS.mdis still injected whole, exactly as before. Nested files are pointed at, not injected, and the model reads a brief with the Read tool when it works in that directory. This keeps package briefs such asinternal/tools/AGENTS.mdandinternal/presentation/AGENTS.mdreachable without growing every turn's system prompt.Changes
buildAgentsMDInfoininternal/agent/utils.goinjects the rootAGENTS.mdas before, then appends a one-line precedence rule when nested files exist: a nestedAGENTS.mdtakes precedence over the root file for its directory, so read it before working there.agent.context.tree_enabled) is in the prompt, it already shows where the nested files are, so only the rule is added. With the tree off, their paths are listed as well, capped at 20 entries.node_modules/vendor. The walk runs in lexical order, so the system prompt stays byte-stable across turns for KV-cache reuse.agent.agents_md.enabled,max_linesandmax_charskeep their meaning and defaults, and still cap only the root file.TestBuildAgentsMDInfocover these cases:agent.agents_mdsection and the nested behavior indocs/configuration-reference.md, and updated the "Package AGENTS files" line in the rootAGENTS.md.Why pointers instead of injection
An earlier revision injected every nested file into a shared
max_charsbudget, nearest file first. In this repository the root file (7047 bytes) plus the two package briefs (1647 bytes) exceed the 8000 default, so the root lost its Security Gotchas tail and Config section. Pointing at the briefs keeps the root rules intact and costs one line.Verification
task precommit:runpasses (fmt, lint with 0 issues, markdownlint).go test ./internal/agent/... -racepasses.infer debug agent system_promptin this repository shows the whole rootAGENTS.mdwith no truncation marker, then the rule line.internal/tools/: AGENTS.mdandinternal/presentation/: AGENTS.mdappear once, in the project tree.Docs follow-up: inference-gateway/docs#853