You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Bound native read_file output by the active context budget #1252
Native read_file output is limited by line count and per-line characters, but not by the active model's available input budget. The default path can return roughly 4 MB (2,000 lines x 2,000 characters), and an explicit limit can request even more. The complete result is then added to API conversation history, where it can exceed the model context window before recovery can run.
This was reproduced from #648 using the real read_file formatter.
Scope
Bound native textual read_file results before they are added to model-facing history.
Derive the available read budget from the active profile's input capacity after accounting for current context, reserved output, and a safety margin.
Apply an absolute ceiling so incorrect model metadata cannot permit an unbounded result.
Clamp or reject explicit limit values that would bypass the model-facing budget.
Preserve useful line-range semantics and include a clear truncation marker with the returned range, original size, and continuation guidance.
Cover ordinary text reads and native text extraction paths such as PDF/DOCX.
Acceptance criteria
A default read of 2,000 long lines cannot add a multi-megabyte result beyond the calculated budget.
An oversized explicit limit cannot bypass the budget.
Truncated output tells the model what was omitted and how to request the next range.
Existing small-file and partial-read behavior remains unchanged.
Focused tests cover long lines, many lines, explicit limits, and extracted text.
Out of scope
MCP output limiting
Condensation-input sanitization
Sliding-window recovery behavior
Full-output spill files or resource references
Aggregate budgeting across parallel tool calls
Estimate
1 story point. Independently mergeable and non-stacked.
Activity