Preserve shell output head and tail - #16
Merged
Merged
Conversation
Shell stdout/stderr truncation was head-biased: output over max_tool_output_bytes kept the first N bytes and dropped the tail, discarding the trailing compiler/test failure that is usually the most useful part. Add middle_truncate_utf8_to_bytes, which keeps both the head and the tail joined by a "[... truncated N bytes ...]" marker, stays within the byte budget, and never splits a UTF-8 codepoint. Apply it to the host shell result envelope (build_shell_target_result) only; read_file and the shared docker run_container primitive keep head truncation. Output under budget and max_bytes == 0 are unchanged (parity with the head-truncation helper). stdout_truncated / stderr_truncated semantics are preserved. Tests: short output unchanged; long ASCII preserves head+tail within budget; marker reports the omitted byte count exactly; long 3-byte-codepoint UTF-8 stays valid and within budget; shell envelope middle-truncates stdout; small timeout partial output passes through unchanged.
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.
Summary
Improves shell/tool output truncation so long output preserves both the beginning and the end.
Why
Head-only truncation can discard the most useful part of build/test output, especially final compiler errors, test failures, or panic summaries.
This makes LocalAgent more useful during real coding tasks by keeping the command context and the actionable failure details.
What changed
Validation
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test --lib target::cargo test --lib tools::cargo test --test tool_call_accuracy_cicargo test --test artifact_goldenpython scripts/ci_release_readiness.pyFollow-ups