Skip to content

Run custom_output_extractor AFTER RunHooks.on_tool_end #1375

@panilya

Description

@panilya

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions