Skip to content

ToolCall

autogen.testing.messages.ToolCall #

ToolCall(tool_name, /, **arguments)

Represents a tool call with a specified tool name and arguments.

PARAMETER DESCRIPTION
tool_name

Tool name to call. Tool should be rigestered in Agent you send message.

TYPE: str

arguments

keyword arguments to pass to the tool.

TYPE: Any DEFAULT: {}

Source code in autogen/testing/messages.py
def __init__(self, tool_name: str, /, **arguments: Any) -> None:
    self.tool_message = RawToolCall(
        id=f"call_{uuid4()}",
        type="function",
        function=FunctionCall(name=tool_name, arguments=to_json(arguments).decode()),
    ).model_dump()

tool_message instance-attribute #

tool_message = model_dump()

to_message #

to_message()

Convert the tool call to a message format suitable for API calls.

RETURNS DESCRIPTION
dict[str, Any]

A dictionary containing the tool call in message format,

dict[str, Any]

ready to be used in API requests or message queues.

Source code in autogen/testing/messages.py
def to_message(self) -> dict[str, Any]:
    """Convert the tool call to a message format suitable for API calls.

    Returns:
        A dictionary containing the tool call in message format,
        ready to be used in API requests or message queues.
    """
    return tools_message(self)