Put a floor under what one tool result costs the transcript
Surveying six open-source harnesses turned up one thing every single one of
them does that Beaver did not: cap the size of a tool result at the
transport, and pair the cap with a message telling the model how to fetch
the rest. Codex caps at 10,000 tokens middle-out; pi and opencode at 2,000
lines or 50KB with "Use offset={next} to continue"; goose spills over
200,000 chars to a tempfile; Cline truncates at 400KB and points at search.
Beaver had excellent per-organ caps and no backstop. result() was a bare
JSON.stringify, and an untargeted library_read defaulted to 300,000
characters -- and that is not paid once, because the adapters re-send the
whole transcript every round, so one unbounded read is re-billed for the
rest of the turn.
- result() now enforces 64,000 chars. That sits above every deliberate
read (section reads cap at 60,000, as does PDF lookup), so it bites
untargeted whole-document reads and nothing else. It trims the one
oversized string field rather than the envelope, so what the model
parses stays well-formed JSON, and it keeps head AND tail because a
clause's proviso lives at its end.
- The untargeted library_read default drops from 300,000 to 24,000. The
300,000 ceiling stays for a caller that deliberately asks.
- A truncated result names its own recovery, and Beaver can be more
specific than a byte offset: library_outline for the section map, then
library_read(section=...), or a library_find hit's `at` as `offset`.
scripts/lean-smoke.ts is the modelful smoke this came out of: one real turn
over the real /chat route, reporting the tool sequence the model actually
chose and what the turn cost. Two runs on claude -p sonnet, ~70s each.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bhP89cYSdEEjHNPnxacns
| Repository | eliziff/Beaver |
|---|---|
| Author | Eli Ziff <eliasziff@gmail.com> |
| Authored | |
| Parents | 26e3c03e |
| Stats | 3 files changed , +404 , -4 |
| Part of | Chat backend features and prompt/context-budget management |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-fda59230.md
from inside the repo you want the change in.