-
Notifications
You must be signed in to change notification settings - Fork 464
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
Returning pydantic result of tool as final_result #847
Comments
Also looking into how to return tool output without having the llm ingest it in its context and regurgitate it. |
Instead of: @new_agent.tool
async def my_func(ctx: RunContext[Deps]) -> list[ProductsResponse]:
return [ProductsResponse(title="test", handle="test", image_url="test")] You could do: # result_validator always gets called in the end but it needs to receive an argument of type `result_type`
@new_agent.result_validator
async def my_func(ctx: RunContext[Deps], result: list[ProductsResponse]) -> list[ProductsResponse]:
return [ProductsResponse(title="test", handle="test", image_url="test")]
You can do this by returning End from a graph Node |
What do you mean by the Instead of tool? I hardcoded it to simplify the issue. Do you mean I should add a new result_validator alongside the tool that returns it's input? Another issue is that my actual agent response type is |
I mean whatever you return from the |
Hi. There is a simple agent code that i suppose to return result of my_func (list[ProductsResponse]) as final result but it fails to execute this task (the model is probably powerful enough). Is there any mechanism for fixing this issue?
sth like set some tools as a
final tools
that their result returns as response of agent.run and execution stops at them.or setting sth in ctx for finishing flow (e.g ctx.break = True)
also making some tools as
final
results to better performance (reduce one llm call for parsing output of them separately)The text was updated successfully, but these errors were encountered: