fix(stella-tools): keep the head and tail of over-cap bash/custom output instead of dropping the tail (#1889) - #1900
Merged
Conversation
…put instead of dropping the tail One shared elision spelling — exec::truncate_middle_capped, 40% head / 60% tail (L-S3), UTF-8-boundary-safe, marker naming the elided byte count and the cap — replaces the three independent copies in exec.rs, bash.rs, and custom.rs. The bash/custom cap drops from 100 KB (~19% of the 150k compaction budget per result, ~224k input tokens over the 8-step retention horizon) to 64 KB (~12%), the point #1842 ratified for read_file. custom.rs now aliases bash's constant so the two cannot drift. Retention-aging is deliberately left to the engine issues. Closes #1889 Refs #1842 #1819 #1438
Contributor
There was a problem hiding this comment.
Sorry @macanderson, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Reviewer's GuideCentralizes and unifies middle-out output truncation across exec, bash, and custom tools by introducing a shared UTF-8-safe head+tail elision helper with a 64KB cap, wiring bash/custom to it, tightening caps, and adding tests that assert sentinel preservation and marker correctness. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Problem
bash.rsandcustom.rscapped tool output atMAX_OUTPUT_BYTES = 100 KB— ~28k estimated tokens, ~19% of the 150k compaction budget in one result. A single large result does not trigger the compaction that would reclaim it (compact_measuredreturns early when the rest of the transcript is small), and the 8-step retention horizon then keeps it verbatim: onecargo test --workspaceornpm ciprinting 100 KB cost ~224k input tokens, not 28k (#1889, the deliberate residue of #1842).On top of the budget shape, the crate had grown three independent elision spellings:
exec::truncate_middle(50/50 split, one marker format),bash.rs's inline copy (50/50, a second marker format), andcustom.rs::truncate_middle_out(40/60, the second marker format again). Three copies is the shape that lets one drift — and they already had, on both the split and the marker.Decision
Head + tail elision through one shared helper, and a 64 KB cap.
exec::truncate_middle_capped(s, max_bytes)is now the crate's single model-facing elision primitive.exec::truncate_middle,bash, andcustomall cut through it;custom.rs's private copy (and its boundary helpers) are deleted. It sits inexec.rsbecause that module already owns the output-cap policy for every other runner (truncate_middle,CappedStream,truncate_preview), andexec.rsis not a god file.custom.rs;bashmoves from 50/50 to match rather than the reverse, and the shared function makes future divergence structurally impossible. Both cuts land on UTF-8 char boundaries (the existing discipline oftruncate_preview/ the old inline code).[… N bytes truncated: output exceeded the 65536-byte cap; the head and tail are kept …]— the model can account for every byte and knows the bound it is working under, mirroringCappedStream's "say which cap did this" convention.read_file(400 KB → 64 KB, PR fix(stella-tools): cut read_file's payload cap from 76% of the context budget to 12% (#1842) #1888), for the same multiplier argument. It stays the same order of magnitude and preserves P1: budgets: fill in every deferred cap, deadline, and retention window in one sitting #616's ratio argument: still 2.2xexec::MAX_OUTPUT_BYTES(30k), so the shell remains the agent's wide sensory channel whileread_outputpages stay cheap.custom.rsnow aliasesbash's constant (pub(crate) use) instead of carrying a copy, so the two cannot drift.Exemplar for the consolidation shape: the crate's own
shell_quote, which collapsed five drifting copies into oneexec.rsprimitive with a "a new one must be too" contract; this PR does the same for elision.Witness
over_cap_output_keeps_first_and_last_lines_with_a_named_elision, once per surface (bash::tests,custom::tests): a command/script emitting a first sentinel line,MAX_OUTPUT_BYTESof filler, and a last sentinel line yields a result containing both sentinel lines, a marker naming the elided byte count and the cap, bounded by the cap plus the marker. Every size is derived from the constant — nothing hard-codes a human-readable size, the assertion shape #1842 caught going stale.Verified failing on the old code the artisanal way — both tests spliced onto the parent commit:
…and passing on this branch.
exec::testsadditionally pin the helper itself: the marker's elided count is arithmetically exact (derived, not hard-coded), tail budget ≥ head budget (L-S3), both cuts survive landing mid-multibyte-char, and at-or-below-cap input is byte-identical.Verification
cargo test -p stella-tools: 723 passed (lib) + all integration suites green, 0 failed.cargo clippy -p stella-tools --all-targets -- -D warningsclean;cargo fmt -p stella-tools --checkclean.pub(crate)).Closes #1889
Refs #1842 #1819 #1438
Summary by Sourcery
Unify and tighten stdout/stderr truncation across exec, bash, and custom tools to keep both the head and tail of oversized outputs under a smaller shared cap.
Bug Fixes:
Enhancements:
Tests: