Repository navigation
fix(context): one line budget per tool result, shared by its text blocks - #359
Conversation
`tool_output_max_lines` was applied to each text block on its own, so since #347 (every block sent) an N-block result reached the model as up to N x the budget. Blocks now share it: short blocks stay whole, long ones split the rest, each cut with its own marker and stash key; a cut block keeps at least 5 lines so it is never cut without a marker. Idempotent. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
…wording Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
|
Review (code-reviewer, with a brute-force idempotence check over max_lines 0–12/20/25/MAX, 1–6 blocks, \r\n / trailing-newline / blank-line text, images between): no code issues; keyed and unkeyed passes mark the same blocks. Fixed in 133a8f1: the CHANGELOG now says multi-block results stored by earlier versions are re-cut once at their first level-1 compaction (one prefix-cache rewrite); floor wording limited to budgets of 5 or more; |
…t overshoot wording - Tests: three long blocks share 200 as [67, 67, 66]; a block over the first even share that fits once a shorter one is placed stays whole; an override exempts a many-block result; sixty 4-line blocks stay whole; the loop's append path cuts MultimodalTool's two blocks to [10, 10]. - Docs: overshoot happens when the even share is under 5 lines (short blocks included), and below a budget of 5 nothing is shared; stale "truncated independently" wording updated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
|
Test and comment reviews addressed in 75b8e6b: tests for the remainder rule ([67, 67, 66]), freed slack ([10, 60, 80]), an override on a many-block result, short blocks past the floor, and line counts on the loop's append path ([10, 10]); docs now state the overshoot exactly (even share under 5 lines, short blocks included; no sharing below a budget of 5) and stale per-block wording is updated. |
Follow-up to #347's review (finding 5): since 0.25.9 sends every text block of a tool result,
tool_output_max_lines— applied per block — let an N-block result (an MCP server's) reach the model as N × the budget.Change (
context::block_budgets, used bytruncate_tool_output_keyed):-b{i}) and the loop's stash code are unchanged.Tests (
src/context.rs): 20 × 200-line blocks fit 200 lines with a marker each; blocks that fit together are untouched; a short block stays whole between long ones, an image keeps its place and the keyed marker namesk-b3; ten long blocks under a 20-line budget each keep 5 lines and a marker; every case truncated twice is unchanged.Docs:
docs/concepts/context-management.md, CHANGELOG## Unreleased.🤖 Generated with Claude Code
https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG