Skip to content

Add agent output size limit to prevent OOM #22

@chanakyav

Description

@chanakyav

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:

  1. Add a max_output_bytes config option (default: 50MB)
  2. In _stream_and_capture(), check captured.tell() before writing
  3. If limit exceeded, log a warning and stop capturing (but keep streaming to terminal)
  4. Set the agent result to indicate truncation

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions