Skip to content

add get_tool_call_name method to extract tool name from ToolCallItem#728

Closed
syedmuneeb321 wants to merge 2 commits intoopenai:mainfrom
syedmuneeb321:main
Closed

add get_tool_call_name method to extract tool name from ToolCallItem#728
syedmuneeb321 wants to merge 2 commits intoopenai:mainfrom
syedmuneeb321:main

Conversation

@syedmuneeb321
Copy link
Copy Markdown

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.

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.
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.
Comment thread src/agents/items.py
Comment on lines +253 to +255
def get_tool_call_name(cls, tool_call: ToolCallItem) -> str:
"""Returns the tool name from a ToolCallItem."""
return tool_call.raw_item.name
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just add this to ToolCallItem instead? so you can just do item.tool_name

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I used it inside ItemHelper, like how you made different methods that take out the agent’s message.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, those are for Responses APIitems, to which we cannot add methods because they are not part of this SDK (they are in the openai sdk). Doing item.tool_name is far better devx than ItemHelper.get_tool_call_name(item)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2025

This PR is stale because it has been open for 10 days with no activity.

@github-actions github-actions Bot added the stale label Jun 2, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 9, 2025

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions Bot closed this Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants