-
Notifications
You must be signed in to change notification settings - Fork 806
Disable reflection after tool use #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@Kludex @dmontagu @samuelcolvin class ResearchResponse(BaseModel): This forces PydAI to call the final_result tool to return a structured output. The first screenshot shows PydAI, and the second one is Autogen. The difference is significant. As I understand, there is no way in PydAI to avoid calling final_result when generating text. |
Is this issue similar/related? #142 |
@Finndersen My approach is interrupting the agent run once all tools have completed execution. Example: This enables the creation of agents that work exclusively with tools, eliminating unnecessary tool calls and reducing latency—something currently missing. |
Does that change mean that all to calls will always return the results directly instead of to LLM? would probably want to make it a bit more flexible than that |
@Finndersen You are right. I think we can use the Autogen approach—just create a message with all tool_call outputs to reuse later. In Autogen, there is a specific class to distinguish between LLM-generated text. It’s called ToolCallsSummaryMessage, and it stores tool calls in string format. A very useful feature for speed optimizations |
You could probably also just use a decorator on a tool to signal that usage of that tool will always imply return of the function output without any interpretation. This is pretty core functionality and it is very odd that it hasn't been implemented yet. It is arguably more important than Graphs or other advanced features. |
Description
Hello, Pydantic AI Team 👋
I’d like to propose a feature that allows for the creation of highly specialized agents that only execute tools without streaming textual output from LLM model (Disable reflection after tool use).
Use Case:
Consider a Search Agent that solely runs tool calls, passing their outputs to an Analyst Agent for processing. The Analyst Agent then collaborates with a Critique Agent to construct the final response. This setup enables modular and efficient agent interactions where streaming text from intermediate agents is unnecessary.
Current Limitation:
From my understanding, the framework does not currently support an agent that exclusively executes tools without attempting to stream a final response. I attempted to implement a workaround using .iter() and breaking the stream when an answer starts forming, but this approach was unsuccessful.
Questions & Contribution:
Looking forward to your thoughts! 🚀
References
I like how autogen managed to do this, their AssistantAgent (similar to Agent in pydantic-ai) has reflect_on_tool_use param and if it is False - FinalResult is just tool outputs.

Check the link to their docs for more details and check last block in diagram pls https://microsoft.github.io/autogen/dev/reference/python/autogen_agentchat.agents.html#autogen_agentchat.agents.AssistantAgent
The text was updated successfully, but these errors were encountered: