We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c583dfc commit 9aeb460Copy full SHA for 9aeb460
src/agents/result.py
@@ -213,6 +213,9 @@ async def stream_events(self) -> AsyncIterator[StreamEvent]:
213
yield item
214
self._event_queue.task_done()
215
216
+ # Ensure main execution completes before cleanup to avoid race conditions with session operations
217
+ await self._await_task_safely(self._run_impl_task)
218
+ # Safely terminate all background tasks after main execution has finished
219
self._cleanup_tasks()
220
221
if self._stored_exception:
0 commit comments