M
MastraAI15h ago
Bobapi

Stopping an agent stream part finished and ensuring that part response is persisted to conversation?

Is there a recommended way to do this? For example, I have a step that repeats until the agent produces valid output. I can tell that the agent is producing invalid output part way through the stream. If I 'return' the step part way through the stream, then the agent appears to have no record of what it had previously part generated, so it can't fix it on iteration i.e. returning the error message from step and iterating results in a confused agent. My current workaround is to only return the error back into the step once the agent stream is complete. I'd like to be able to return early, and persist the state of the stream at that point, as it will save many seconds from a UX perspective. Is there a recommended approach for this?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?