Expand description
Output limits to prevent unbounded memory growth. Output truncation limits inspired by OpenAI Codex multi-tier truncation. Prevents OOM with three independent size limits. Reference: https://openai.com/index/unrolling-the-codex-agent-loop/
Constants§
- DEFAULT_
MESSAGE_ LIMIT - Default message count limit for history.
- MAX_
AGENT_ MESSAGES_ SIZE - Maximum size for single agent message payloads (bytes) - 10 MB.
- MAX_
ALL_ MESSAGES_ SIZE - Maximum size for entire message history payloads (bytes) - 50 MB.
- MAX_
LINE_ LENGTH - Maximum size per line (bytes) - 1 MB. Prevents OOM on malformed output with very long lines.
- MAX_
MESSAGE_ LIMIT - Maximum message count limit.
- TRUNCATION_
MARKER - Truncation marker appended when content is cut off.
Functions§
- collect_
with_ truncation - Collect content with lazy truncation (Codex pattern). Marks truncated but continues draining to prevent pipe blocking.