Skip to main content
Demonstrates that async generator tools (async def + yield) correctly receive Pydantic BaseModel instances when the LLM passes a JSON object for a model-typed parameter. Previously (pre-fix for #8711), the parameter arrived as a raw dict on the async path only, producing AttributeError: 'dict' object has no attribute '...' on the first attribute access. Sync generator tools already worked.
This example omits stream_events=True, so Agno discards the yielded custom progress events and both final assertions fail. Add the option before running.
async_generator_tool_with_pydantic_args.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Enable custom events

In the saved file, add stream_events=True next to stream=True in the agent.arun() call.
5

Run the example

Save the code above as async_generator_tool_with_pydantic_args.py, then run:
Full source: cookbook/91_tools/async_generator_tool_with_pydantic_args.py