This actually makes a lot of sense. One giant agent always turns into noise after a while.
AI Coding Tip 014 - Use Nested AGENTS.md Files
2 Comments
Well I'm surprised to see a post written today on a topic I'm currently researching.
My concern about using directory-aligned AGENTS.md files is how they are not passed as system instructions. The system instructions appear at the beginning of the context, giving them weight and power. Files injected mid-context will receive lower attention weight — the model will effectively be less influenced by them. This is the "lost in the middle" problem applied to directives.
But as we float about the project, working on this and that within the repo, and attempt to inject instructions willy-nilly into the context, they will suffer from the "lost in the middle" problem, or bloat the context repeatedly.
I ran this take through Github Copilot / Claude Sonnet 4.6, and here is its take:
ME
(the above) plus:
I seem to recall that the system instructions block is set at context initialization, and is not mutable. If it were, the KV cache would freak out.
Github Copilot / Claude Sonnet 4.6
Your analysis is correct on both counts, and the reasoning is tight.
System instructions are fixed at context initialization. The root AGENTS.md occupies the system prompt slot — it's placed before the conversation history and never changes during a session. The KV cache builds its prefix keys over that token sequence. If the system prompt mutated between turns, the cached attention states for every subsequent token position would be invalid and would need full recomputation. That's not just "freak out" — it's a complete cache miss on every turn, which is why the design doesn't permit it.
Nested AGENTS.md files are injected as user-turn context, not system instructions. This is the critical distinction. When IDEA's experimental feature picks up a nested file (say pipelines/AGENTS.md because you're editing a pipeline YAML), it injects that content into the user side of the current turn's message — after the conversation history has already accumulated. This puts them squarely in the window where "lost in the middle" attention degradation applies, and it does bloat the context on every turn where the file is considered relevant.
The practical consequence for your design: [REDACTED].
So the nested AGENTS.md feature, as currently implemented, is useful for scoping craft rules to subdirectories across new context windows (clean start, system prompt picks up the right nested file) rather than within a single long session.
Please log in to add a comment.
Please log in to comment on this post.
More Posts
- © 2026 Coder Legion
- Feedback / Bug
- Privacy
- About Us
- Contacts
- Premium Subscription
- Terms of Service
- Refund
- Early Builders
More From Maxi Contieri
Related Jobs
- User Interface (UI) Software Developer IIIOmega Solutions Inc · Full time · Princeton, NJ
- Museum and Archives TechnicianC&O Canal Trust · Full time · Williamsport, MD
- Backend Engineer (AI coding)Pragmatike · Full time · Italian Republic
Commenters (This Week)
Contribute meaningful comments to climb the leaderboard and earn badges!