Skip to content

Add middle truncation for tool outputs#20

Merged
jbreite merged 2 commits intomainfrom
joshbreite/jzb-150-add-middle-truncation-for-tool-outputs
Mar 1, 2026
Merged

Add middle truncation for tool outputs#20
jbreite merged 2 commits intomainfrom
joshbreite/jzb-150-add-middle-truncation-for-tool-outputs

Conversation

@jbreite
Copy link
Copy Markdown
Owner

@jbreite jbreite commented Mar 1, 2026

Summary

  • Replace head-only truncation with middle truncation (50/50 head/tail split) for Bash tool output, preserving both beginning context and actionable tail content (error summaries, test failures)
  • Extract middleTruncate utility into src/utils/helpers.ts and export it for reuse
  • Add comprehensive unit tests for the new truncation behavior

jbreite and others added 2 commits March 1, 2026 11:03
Replace front-only truncation in the Bash tool with middleTruncate, which
preserves both the beginning and end of long output. This ensures the agent
sees actionable content like test failure summaries and install errors that
appear at the tail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ounting

Replace text.split("\n").length with a charCodeAt loop for O(1) space
line counting, and guard against invalid maxLength values (negative, NaN,
Infinity).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jbreite jbreite marked this pull request as ready for review March 1, 2026 16:15
@jbreite jbreite merged commit 6dd7751 into main Mar 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant