Skip to content

Missing Initial Tokens After Tool Call in Streaming Output (But Present in Final Output) with Gemini 2.5 Flash Model Using agent.iter() #2659

@gscfwid

Description

@gscfwid

Question

Has anyone encountered an issue where, when using the Gemini 2.5 Flash model with ‎agent.iter(), the first few tokens after a tool call do not appear in the streaming output via ‎node.stream, but are present in the ‎final_output?

Details:
• Model: Gemini 2.5 Flash
• Method: ‎agent.iter()
• Issue: After invoking a tool, the initial tokens following the tool call are missing from the streaming output (‎node.stream), but do show up in the ‎final_output.
• Expected Behavior: All tokens after the tool call should be streamed and visible in ‎node.stream.
• Actual Behavior: The first few tokens after the tool call are absent in the stream but appear in the final output.

Has anyone else experienced this? Is there a known workaround or solution?

Additional Context

• Pydantic AI version:0.7.4
• Python version: 3.12
• Tools type: MCP

Metadata

Metadata

Assignees

Labels

StalequestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions