Agents SDK: Modifying Messages Array Mid-Loop during a Single Run

Curious if this is possible — i haven’t found any docs online demonstrating this.

The main reason for wanting this is to measure whether or not to truncate messages mid loop over concerns the model could reach its max context window while it’s in a long workflow composed of many previous messages / tool calls.

I’d prefer to assess (and modify if applicable) the messages array over each turn during a single run.