Skip to content

add get_tool_call_name method to extract tool name from ToolCallItem #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

syedmuneeb321
Copy link

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 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
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
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
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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants