In agent.py, _stream_and_capture() writes all stdout into a StringIO with no size cap:
captured.write(decoded) # Could accumulate GBs in StringIO
A runaway agent (e.g. accidentally printing a large binary file) could fill RAM.
Proposed fix:
- Add a
max_output_bytes config option (default: 50MB)
- In
_stream_and_capture(), check captured.tell() before writing
- If limit exceeded, log a warning and stop capturing (but keep streaming to terminal)
- Set the agent result to indicate truncation
In
agent.py,_stream_and_capture()writes all stdout into aStringIOwith no size cap:A runaway agent (e.g. accidentally printing a large binary file) could fill RAM.
Proposed fix:
max_output_bytesconfig option (default: 50MB)_stream_and_capture(), checkcaptured.tell()before writing