Skip to content

agent.run_stream doesn't run with tools #2308

@ryx2

Description

@ryx2

Initial Checks

Description

When I use agent.run, it loops through the tools until completion, however run_stream's implementation is that it just returns after one iter. Wouldn't it make more sense for the default behavior to be do the same thing as agent.run does, and loop through tool executions until completion?

Example Code

Instead of including my own code, I think I can see the problematic area of logic in the run_stream implementation:

final_result = await stream_to_final(streamed_response)
if final_result is not None:
    yield StreamedRunResult(...)
    break  # ← Exits early, preventing tool processing steps

Python, Pydantic AI & LLM client version

0.4.6

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions