Tool call data structures¶
You might be looking for...
- If you're looking for information on the
AIPromptandAIResponseclasses, see AI inputs and outputs: an overview. - If you're looking for information on the different types of
AIMessageobjects, see AI messages.
This section describes the main classes for tool calls:
AIToolCall, which is a data structure representing a tool call.ComputerUseAction, which is a data structure representing a tool call that uses the computer.
Visual explanation¶
As always, visualization should help you understand the class hierarchy of the messages:
Note
To make this section more readable, we're not showing the full
path of the classes, but they can also be imported from the
conatus.models.inputs_outputs.tool_calls module.
Tool call specifications¶
AIToolCall
dataclass
¶
AIToolCall(
name: str,
returned_arguments: dict[str, JSONType] | str,
call_id: str | None = None,
type: Literal["function"] = "function",
requires_local_execution: bool = True,
could_be_structured_output: bool = False,
)
Tool call by the AI.
This is contained in the AssistantAIMessage
.
This is the tool call data returned by the AI provider. What's raw about it
is the arguments field, which is a stringified JSON.
We also provide properties to convert the returned_arguments field to a
dictionary or a stringified JSON.
For more information on its incomplete counterpart, see
IncompleteAIToolCall
.
returned_arguments
instance-attribute
¶
The arguments of the tool call, as returned by the AI.
We do not apply any pre-processing to the arguments, so they can be either a dictionary or a stringified JSON.
The arguments_as_dict
property converts the stringified JSON to a dictionary if necessary.
The arguments_as_str
property returns the stringified JSON.
call_id
class-attribute
instance-attribute
¶
call_id: str | None = None
The ID of the tool call, as given by the AI provider.
This is the ID of the tool call as given by the AI provider. Some providers require that tool responses reference the ID of the tool call.
type
class-attribute
instance-attribute
¶
type: Literal['function'] = 'function'
The type of the tool call. Always "function".
requires_local_execution
class-attribute
instance-attribute
¶
requires_local_execution: bool = True
Whether the tool call requires local execution.
If False, the tool calls is meant to be executed on the server side.
could_be_structured_output
class-attribute
instance-attribute
¶
could_be_structured_output: bool = False
Whether the tool could be a structured output in disguise.
Some AI providers (e.g. Anthropic) will return a structured output in the form of a tool call.
arguments_as_dict
property
¶
arguments_as_str
property
¶
arguments_as_str: str
The arguments of the tool call as a string.
Converts the dictionary to a stringified JSON if necessary.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The arguments of the tool call as a string. |
Computer use actions¶
ComputerUseAction
module-attribute
¶
ComputerUseAction = (
CULeftMouseDown
| CULeftMouseUp
| CULeftMouseClick
| CULeftMouseDoubleClick
| CULeftMouseTripleClick
| CUMiddleClick
| CURightClick
| CUBackClick
| CUForwardClick
| CUDrag
| CUKeypress
| CUKeypressHold
| CUMove
| CUScreenshot
| CUScroll
| CUType
| CUWait
| CUCursorPosition
)
Union type for all the computer use actions.
CUAction
dataclass
¶
CUAction(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
)
Bases: ABC
A computer use action.
This common class defines a few properties that are common to all the computer use actions:
arguments_as_strandarguments_as_dictensure that the classes will be treated by other classes as if they wereAIToolCallinstances.- Some attributes that are good for processing by the runtime:
environment
instance-attribute
¶
The environment in which the action is executed.
environment_variable
instance-attribute
¶
environment_variable: RuntimeVariable
The variable to execute the action on.
arguments_as_dict
property
¶
The arguments of the action as a dictionary.
requires_local_execution
property
writable
¶
requires_local_execution: bool
Whether the action requires local execution.
safe_asdict
abstractmethod
¶
The arguments of the action as a dictionary.
We do this in order not to use asdict on the
action, which might fail if the action contains a field that is not
JSON serializable (in our case, the environment_variable
field).
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
The arguments of the action as a dictionary. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CULeftMouseDown
dataclass
¶
CULeftMouseDown(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["left_mouse_down"] = "left_mouse_down",
)
Bases: CUAction
A left mouse down action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the mouse down. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CULeftMouseUp
dataclass
¶
CULeftMouseUp(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["left_mouse_up"] = "left_mouse_up",
)
Bases: CUAction
A left mouse up action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the mouse up. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CULeftMouseClick
dataclass
¶
CULeftMouseClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["left_mouse_click"] = "left_mouse_click",
)
Bases: CUAction
A left mouse click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the mouse click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CULeftMouseDoubleClick
dataclass
¶
CULeftMouseDoubleClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal[
"left_mouse_double_click"
] = "left_mouse_double_click",
)
Bases: CUAction
A left mouse double click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the mouse double click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CULeftMouseTripleClick
dataclass
¶
CULeftMouseTripleClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal[
"left_mouse_triple_click"
] = "left_mouse_triple_click",
)
Bases: CUAction
A left mouse triple click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the mouse triple click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUMiddleClick
dataclass
¶
CUMiddleClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["middle_click"] = "middle_click",
)
Bases: CUAction
A middle click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the middle click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CURightClick
dataclass
¶
CURightClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["right_click"] = "right_click",
)
Bases: CUAction
A right click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the right click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUBackClick
dataclass
¶
CUBackClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["back_click"] = "back_click",
)
Bases: CUAction
A back click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the back click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUForwardClick
dataclass
¶
CUForwardClick(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int] | None = None,
type: Literal["forward_click"] = "forward_click",
)
Bases: CUAction
A forward click action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the forward click. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUDrag
dataclass
¶
CUDrag(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: list[tuple[int, int]],
type: Literal["drag"] = "drag",
)
Bases: CUAction
A drag action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the drag. Some providers will provide only the coordinates of the drag end, and not the drag start. Sometimes they provide a full path of the drag, in which case the list might have more than two elements. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUKeypress
dataclass
¶
CUKeypress(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
keys: list[str],
type: Literal["keypress"] = "keypress",
)
Bases: CUAction
A keypress action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
keys |
The keys to press. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUKeypressHold
dataclass
¶
CUKeypressHold(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
keys: list[str],
duration: float,
type: Literal["keypress_hold"] = "keypress_hold",
)
Bases: CUAction
A keypress hold action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
keys |
The keys to press. |
duration |
The duration of the keypress hold.
TYPE:
|
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUMove
dataclass
¶
CUMove(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
xy: tuple[int, int],
type: Literal["move"] = "move",
)
Bases: CUAction
A mouse move action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
xy |
The coordinates of the mouse move target. |
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUScreenshot
dataclass
¶
CUScreenshot(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
type: Literal["screenshot"] = "screenshot",
)
Bases: CUAction
A screenshot action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUScroll
dataclass
¶
CUScroll(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
start_xy: tuple[int, int] | None = None,
distance_xy: tuple[int, int] | None = None,
magnitude: float | None = None,
direction: (
Literal["up", "down", "left", "right"] | None
) = None,
type: Literal["scroll"] = "scroll",
)
Bases: CUAction
A scroll action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
start_xy |
The coordinates of the scroll start. |
distance_xy |
The distance to scroll. |
magnitude |
The relative magnitude of the scroll.
TYPE:
|
direction |
The direction of the scroll.
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUType
dataclass
¶
CUType(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
text: str,
type: Literal["type"] = "type",
)
Bases: CUAction
A type action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
text |
The text to type.
TYPE:
|
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
Source code in conatus/models/inputs_outputs/tool_calls.py
CUWait
dataclass
¶
CUWait(
environment: ComputerUseEnvironment,
environment_variable: RuntimeVariable,
call_id: str | None,
duration: float | None = None,
type: Literal["wait"] = "wait",
)
Bases: CUAction
A wait action.
| ATTRIBUTE | DESCRIPTION |
|---|---|
duration |
The duration of the wait.
TYPE:
|
type |
The type of the action. Always
TYPE:
|
safe_asdict
¶
The arguments of the action as a dictionary.
They can later be added to other; we're just making sure that the
arguments that are passed here don't include ones that have issue
with deepcopy.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, JSONType]
|
A dictionary of the arguments of the action. |
