Expand description
Utility functions for output handling and OOM protection.
Shell commands and agent processes can produce arbitrarily large output.
This module provides truncate_output to cap captured output at
MAX_OUTPUT_SIZE bytes, preventing out-of-memory conditions in
long-running workflows.
Constants§
- CHARS_
PER_ TOKEN - Average number of characters per token used for estimation.
- MAX_
OUTPUT_ SIZE - Maximum number of bytes kept from a single process output stream (10 MB).
Functions§
- estimate_
tokens - Estimate the number of tokens from a character count.
- truncate_
output - Truncate raw process output to at most
MAX_OUTPUT_SIZEbytes and convert it to a UTF-8String.