-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Question
Is it possible to run custom output extractor AFTER RunHooks.on_tool_end
for Agent-as-a-tool agents?
My case
I have a system where my Agent-as-a-tool (with tool_use_behavior="stop_on_first_tool"
) produces a data class (Structured Output) with final_response: str
and a metadata field.
Where final_response: str
should be sent to the user, and metadata field intercepted in RunHooks.on_tool_end
and assigned in my Context object.
The blocker for me is that custom_output_extractor
is being run BEFORE hooks are run, thus, my RunHooks.on_tool_end
hook doesn't have access to that metadata field anymore, because it was "deleted" in my custom_output_extractor
.
The question is:
Is it possible to reorder execution flow of custom_output_extractor
and RunHooks.on_tool_end
?
If not, can I expect a feature in future releases that can help me with my use case?
I don't think my use case is very specific only for my project.
It would be great to have an ability to populate context object with "metadata" fields generated as SO, while keeping a single field or so in the full schema as the final response to show to the user or other agents.