Bounded tool I/O and a smaller default tool surface - #173
Merged
chauncygu merged 5 commits intoJul 20, 2026
Conversation
Four defects found by independent review of the bounded-I/O work: - files.py (SummarizeLargeFile): the PDF branch of _read_file_for_summary returned an Error whenever the bounded extractor appended its truncation marker, so summarizing any large PDF (papers/books — the tool's main use case) hard-failed and dead-ended ReadPDF's own redirect to it. Strip only the trailing marker and summarize the extracted text; genuine Error returns still propagate. - fs.py (_read_logical_line): a complete CRLF whose LF landed on the read-chunk boundary re-entered the bare-CR probe and swallowed a following blank line, shifting every later line number (Read line numbers drive Edit targeting). Probe only when the last selected byte is a bare CR. - files.py (_summarize_large_file reduce): a failed (None) chunk hit break and dropped all later chunk summaries; the reduce cap silently truncated the tail while the header still claimed all N chunks. Skip None chunks, report the chunks actually merged, and warn on incomplete coverage — including when the cap clips the last included chunk. - web.py (_DuckDuckGoResultParser): HTML void elements (<img>, <br>) inside a result title/snippet left the depth counters permanently offset, bleeding text between fields. Skip void tags in both start/end handlers. Adds no new deps. Verified with targeted repros and the bounded-I/O, summarize, tool-registry and prompt-assembly test suites.
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.
Motivation
High-volume tools could do substantial work before their output hit the truncation layer — a large file, PDF, or slow HTTP response wasted memory, latency, and context budget. Every turn also exposed the full tool catalog, inflating schema/prompt size for ordinary coding tasks. This moves limits and tool-selection to the source of the data.
What changed
Bounded input
Readstreams files incrementally under byte limits, preserving logical line boundaries and CRLF.WebFetch/WebSearchenforce a response byte limit, a bounded redirect chain, identity-only encoding, and one cancellable deadline spanning connect + redirects + body streaming.Tool profiles
standardprofile = common coding tools only;research/orchestration/fullare explicit opt-ins./configvalidation, and cache keys. Configs withouttool_profiledefault tostandard;fullrestores the complete surface.Prompt & cache correctness
EnterPlanMode/ExitPlanModeare active; tmux guidance only when its tool is active.Correctness fixes
files.py· SummarizeLargeFilefs.py·_read_logical_line\r.files.py· summarize reduceNone) chunk instead of aborting the merge; report chunks actually merged and warn on incomplete coverage (incl. a clipped last chunk).web.py· DuckDuckGo parser<img>,<br>) in both tag handlers so title/snippet depth counters stay balanced.Validation
compileallandgit diff --checkpass.