-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
Summary
Output tools are called zero, twice or more times in streaming mode (but only once in sync mode)
(I'm not sure about the zero case for sync mode)
What happens
The first call happens at _agent_graph.py:861 during tool call processing in the graph execution, and the second call happens at result.py:179 when validating the response in get_output().
Details
Output tool processors are invoked:
- 2 times when using
get_output()alone - 2 times when using
stream_output()alone - 4 times when using both
stream_output()+get_output() - 0 times when the stream isn't consumed at all (IMHO think the expected behavior is to get called anyway)
MRE:
Note: written by an LLM, but shows the current behavior with streaming
https://gist.github.com/Danipulok/f27bedddfc2b7fc476b1836bbf3af14d
Python, Pydantic AI & LLM client version
Python 3.13.4
pydantic==2.12.4
pydantic-ai==1.25.1
Wh1isper and bodlan
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working