-
Notifications
You must be signed in to change notification settings - Fork 317
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
Support tool calling when a structured result is provided #184
Conversation
Deploying pydantic-ai with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise this looks great.
I'm happy to help or take over if my feedback is too annoying.
All good feedback. Will clean up today or tomorrow as time allows. |
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style guide flagged several spelling errors that seemed like false positives. We skipped posting inline suggestions for the following words:
- [Ss]how_root_heading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style guide flagged several spelling errors that seemed like false positives. We skipped posting inline suggestions for the following words:
- show_root_heading
@samuelcolvin I think this is all cleaned up now |
This PR addresses behavior when an agent requests multiple tool calls, one of which is a "final" result call. I believe it closes #161 and follows #179.
In this PR:
end_strategy
parameter that can be either "early" or "correct".Early
means that the presence of a "final" result short-circuits all other tool calls, and they are not made. Passing "correct" will call all tools, even if a final result was provided.correct
is the default value.end_strategy
is, a ToolResult message is always generated for every tool call. This ensures that messages from the agent call can safely be used as the input to another call._handle_model_response
method was very complicated, so I split it into a few straightforward method calls. If that's not desirable, it's easy to recombine.Note: this PR does not address the streaming case, as that is more complexing pending conversation with @samuelcolvin .