You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix async streaming support for Agno Team.arun() - Resolves#1262 (#1265)
* Fix async streaming support for Agno Team.arun()
Fixes#1262
The issue was that Team.arun() with stream=True returns an async generator
directly, not a coroutine. The team async wrapper was defined as 'async def'
which caused it to wrap the async generator in a coroutine, leading to the
error: 'async for' requires an object with __aiter__ method, got coroutine.
Changes:
- Added AsyncStreamingResultWrapper class to properly wrap async generators
- Modified create_team_async_wrapper to be a regular function (not async)
- Added inspect.isasyncgen() check to detect async generators
- Updated create_streaming_agent_async_wrapper to check for __aiter__ first
The fix ensures that async generators are returned directly without being
wrapped in a coroutine, allowing proper async iteration with 'async for'.
Co-Authored-By: Alex <[email protected]>
* Fix Agent async streaming support
Also fixes Agent.arun() async streaming in addition to Team.arun().
Changes:
- Changed create_streaming_agent_async_wrapper from async def to def
- Added inspect.isasyncgen() check for detecting async generators
- For non-streaming case, created inner async_wrapper function
- Both Team and Agent async streaming now work correctly
Co-Authored-By: Alex <[email protected]>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Alex <[email protected]>
0 commit comments