From 18c8f04e3f81418ec29d00b68d2606fb9b1c94fb Mon Sep 17 00:00:00 2001 From: syedmuneeb321 <130203424+syedmuneeb321@users.noreply.github.com> Date: Wed, 21 May 2025 20:05:22 +0500 Subject: [PATCH 1/2] add get_tool_call_name method to extract tool name from ToolCallItem Adds a utility method get_tool_call_name to extract the name of a tool from a ToolCallItem. Useful for identifying which tool was invoked during agent execution. --- src/agents/items.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/agents/items.py b/src/agents/items.py index 8fb2b52a..8effbcee 100644 --- a/src/agents/items.py +++ b/src/agents/items.py @@ -248,3 +248,8 @@ def tool_call_output_item( "output": output, "type": "function_call_output", } + + @classmethod + def get_tool_call_name(cls, tool_call: ToolCallItem) -> str: + """Returns the tool name from a ToolCallItem.""" + return tool_call.raw_item.name From 2dd3fa627332b97881aab2e0031c2d4a66928db7 Mon Sep 17 00:00:00 2001 From: syedmuneeb321 <130203424+syedmuneeb321@users.noreply.github.com> Date: Wed, 21 May 2025 20:12:42 +0500 Subject: [PATCH 2/2] add tool_response_output method to extract output Adds a class method tool_response_output that extracts and returns the output data from a ToolCallOutputItem. This helps retrieve the result of a tool call in agent workflows. --- src/agents/items.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/agents/items.py b/src/agents/items.py index 8effbcee..f48e54fa 100644 --- a/src/agents/items.py +++ b/src/agents/items.py @@ -253,3 +253,10 @@ def tool_call_output_item( def get_tool_call_name(cls, tool_call: ToolCallItem) -> str: """Returns the tool name from a ToolCallItem.""" return tool_call.raw_item.name + + @classmethod + def tool_response_output( + cls, tool_call: ToolCallOutputItem + ): + """Extracts and returns the output from a ToolCallOutputItem.""" + return tool_call.output \ No newline at end of file