Expand description
Output truncation helpers. Output truncation utilities for tool results Limits tool output by two independent limits (lines + bytes), whichever hits first. UTF-8 safe: truncates at valid character boundaries.
Structs§
- Truncation
Options - Options for truncation
- Truncation
Result - Result of a truncation operation
Enums§
- Truncated
By - How truncation was applied
Constants§
- DEFAULT_
MAX_ BYTES - Default max output bytes (50KB)
- DEFAULT_
MAX_ LINES - Default max output lines
- GREP_
MAX_ LINE_ LENGTH - Max line length for grep output
Functions§
- format_
bytes - Format bytes for human-readable display
- truncate_
head - Truncate content from the head (keep first N lines/bytes). Never produces partial lines unless the first line itself exceeds byte limit.
- truncate_
line - Truncate a single line to a maximum character length. Appends “… [truncated]” if truncated.
- truncate_
tail - Truncate content from the tail (keep last N lines/bytes). May produce a partial first line if the last line of original exceeds byte limit.