Repository navigation
feat: add per-file byte cap and budget-aware truncation to agentsmd - #1235
Merged
Merged
Conversation
mrh997
force-pushed
the
fix/mrh/agentsmd
branch
from
September 1, 2026 09:54
3bda9e2 to
551fd3d
Compare
mrh997
force-pushed
the
fix/mrh/agentsmd
branch
from
September 1, 2026 09:57
551fd3d to
4bd0269
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1235 +/- ##
==========================================
+ Coverage 83.71% 83.78% +0.06%
==========================================
Files 162 162
Lines 23887 23940 +53
==========================================
+ Hits 19998 20057 +59
+ Misses 2628 2623 -5
+ Partials 1261 1260 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mrh997
force-pushed
the
fix/mrh/agentsmd
branch
from
September 1, 2026 10:13
4bd0269 to
053b1a1
Compare
hi-pender
approved these changes
Sep 1, 2026
mrh997
force-pushed
the
fix/mrh/agentsmd
branch
from
September 1, 2026 12:18
053b1a1 to
76907cd
Compare
Add PerAgentsMDMaxBytes to cap each AGENTS.md file individually, make AllAgentsMDMaxBytes apply to the first file too, and truncate (or drop) the file that crosses the cumulative budget instead of skipping it wholesale. Truncated files carry a notice and dropped files are summarized at the end.
mrh997
force-pushed
the
fix/mrh/agentsmd
branch
from
September 1, 2026 12:29
76907cd to
9cc93f6
Compare
shentongmartin
approved these changes
Sep 1, 2026
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.
Summary
The agentsmd middleware previously always loaded each individual AGENTS.md file in full and only skipped later files once the cumulative budget was exceeded, so a single oversized file could blow past
AllAgentsMDMaxBytesunbounded. This change makes the byte limits authoritative: content is now truncated to fit the budget rather than admitted whole, and the model is told what was cut or omitted.API Changes
Config.PerAgentsMDMaxBytes— caps the byte size of each individual AGENTS.md file (including @imported ones); a larger file is truncated to the limit with a notice appended.0means no per-file limit.Key Changes
AllAgentsMDMaxBytesnow applies to every file, including the first. When loading a file would cross the cumulative budget, it is truncated to the remaining budget if at least 500 bytes remain, otherwise dropped whole; either way no further files load.AllAgentMDDocsMaxBytes→AllAgentsMDMaxBytes) and added validation for the new field.