Repository navigation
fix(agent): keep a nested directory's instructions after its read shrinks - #428
Merged
Merged
Conversation
…inks The first `read` into a nested directory appended that directory's `AGENTS.md` (and siblings) to the end of the read's result. A few steps later spill keeps 400 chars of an old result and prune keeps 2 KiB from its head, so the instructions were cut off, and since each directory is attached once per session they never came back: the agent stopped following the package's rules partway through the work. The instructions now go into one agent note right after the step's results. Agent notes are never spilled or pruned, so the rules stay until compaction, and appending after the results keeps the cached prefix stable as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
force-pushed
the
fix/nested-instructions-survive-pruning
branch
from
November 7, 2026 14:41
0b6d099 to
cc4d040
Compare
This was referenced Nov 7, 2026
Merged
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.
Found in the context audit for the token-efficiency series (#418–#427).
Problem
The first
readinto a nested directory (for examplepkg/in a monorepo) appended that directory'sAGENTS.mdand siblings to the end of the read's tool result. A few steps later the per-step passes shrink old results: spill keeps a 400-char head plus a pointer, and prune keeps the first 2 KiB. Either way the instructions at the tail were cut off. Each directory is attached only once per session (instruction_dirs), so they never came back, and the agent stopped following the package's rules partway through the work.Change
The instructions now go into one agent note right after the step's results (
nested_instructions_for). Agent notes are never spilled, pruned or shaken, so the rules stay until compaction. Appending after the results keeps the cached prefix byte-stable, as before. The size cap (MAX_NESTED_BYTES) and the once-per-directory rule are unchanged.Checks
a_read_below_the_project_attaches_that_directory_s_agents_md_oncenow asserts:r1, and none followsr2;whycodes-agent --lib764 passed; clippy is ok. Local llvm-cov: every changed line is covered.docs/internals/turn-loop.md§11 and theprompt-cache.mdbreak table are updated.Note: #418 also touches
turn.rs(the recovery note just below this hunk). Whichever merges second needs a trivial rebase.🤖 Generated with Claude Code