-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
When using the agent-as-tool pattern, custom_output_extractor doesn't have access to the tool call's call_id, making it not possible to associate the nested agent's RunResult (e.g., to_input_list()) back to the original ToolCallItem/ToolCallOutputItem for debugging.
Current flow:
- Agent B is defined and has a number of tools. Agent A is defined and uses Agent B as a tool.
- Agent A calls Agent B as a tool → creates
ToolCallItemwithcall_id - Agent B runs, calls its own tools, and creates its final output → produces
RunResult custom_output_extractorreceives theRunResultobject, but it has no association to the originalcall_id
As a result, the nested RunResult is lost. This way, there is no visibility over what the agent-as-tool is doing under the hood.
Proposed Solution
Pass the call_id through the RunResult's context_wrapper so custom_output_extractor can access it.
This would enable something like this:
async def my_custom_output_extractor(run_result: RunResult) -> str:
call_id = run_result.context_wrapper.context.tool_call_id # Currently not available
my_custom_session.attach_nested_run_result(call_id, run_result.to_input_list())
return run_result.final_outputWould love to here if there is a better solution, and if there is a temporary workaround for this problem.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request