Skip to main content

Module utils

Module utils 

Source
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_SIZE bytes and convert it to a UTF-8 String.