-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support for function tool direct/structured output #436
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
Yeah this should work as you described. The output does need to be stratified before we send it to the LLM, so you should ensure your object has a good |
Thank you. To clarify: this does work, but once the agent picks the tool result back up, the output is always forced to a string. And I don't want to strictly set a single output_type on this agent because it can also validly return strings when not calling this tool. |
Am i understanding correctly that you want the output of the tool to be the output of the agent? Maybe the agent's Let me know if there's a different desired behavior you want. |
Thank you. I think tool_use_behavior should accomplish what I am looking for. I had not yet updated my agents module so I didn't see this option. |
Please read this first
Describe the feature
Unless I've missed something, any agent tool output from final_output or new_item is forced to a string. I have a use case where it would be nice to be able to directly return an object from a function tool. For example, I am using Tavily search as a tool, which returns a dict, which I am converting to a Pydantic model. I know this can be done using an Agent as a tool and setting the output_type, but I'd prefer to just use the tool itself, if possible.
My workaround is as follows:
But it would be nice to be able to convert the output directly in the function tool and return that:
Or possibly even set an output_type on the function tool itself.
The text was updated successfully, but these errors were encountered: