Skip to main content

Module output_limit

Module output_limit 

Source
Expand description

Configurable output size limits for agent safety.

When output exceeds the threshold the result is capped and ExecResult.out is replaced with a head+tail preview. Two strategies, selected at runtime by SpillMode:

  • SpillMode::Disk (default): the full output is written to a spill file on the real filesystem and the preview points at it. The agent can then selectively read the file.
  • SpillMode::Memory: the output is truncated in memory only — no disk I/O, no recoverable file. For runtime read-only kernels (e.g. kaibo) that must not touch the host filesystem even when localfs is compiled in. Memory stays bounded regardless of how much the command produces.

Either way the exit code is remapped to 3 (did_spill) so callers can tell the output was capped.

Per-mode defaults: MCP kernels get an 8KB limit, REPL/test kernels are unlimited. Runtime-switchable via the kaish-output-limit builtin.

Structs§

OutputLimitConfig
Configurable output size limit.
SpillResult
Result of a spill operation.

Enums§

SpillMode
Where overflow output goes when it exceeds the limit.

Functions§

parse_size
Parse a size string with optional K/M suffix into bytes.
spill_if_needed
Check if the result output exceeds the limit and spill to disk if so.