middleware.ToolResponseMiddleware limits successful tool results before they enter history or a durable journal. It measures text bytes or the JSON encoding of multipart output. Control fields such as IDs, state updates, interruptions, and background task metadata are preserved.
Import pkg/agents/middleware and pkg/agents. With store implementing attachments.UploadStore: