Stop run stream for Agent/Team

Hey Team,
I am using arun with streaming
For some cases I need to stop the run of the Agent/Team
Code example:

async for event in await agent.arun(
                message=session.last_user_message,
                session_id=session_id,
                user_id=user_id,
                stream=True,
                stream_intermediate_steps=True,
                stream_member_events=True,
            ):
               # specific use-case
               break

Instead of just break, I wonder how can I save the current run to the session DB?
I want to make sure that I am saving the current state
Any suggestions?
Thank you!

Hi @shahaf, thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.If it’s urgent, please let us know. We appreciate your patience!

Hey @shahaf in case of streaming you get events that you can catch. There is also a store_events flag on the Agent level that will store these events in the db automatically and you can also control if you want to skip storing some events using the flag `events_to_skip`.

Read about this in the documentation here- Running your Agent - Agno