Skip to content

Tools

Tools are the atomic unit of agent action — the functions an agent can call to read files, execute commands, query APIs, or interact with the world. In the A2E model, every tool call is a typed tool/call/req message, making execution auditable, interruptible, and swappable across backends.

Overview

The tools capability provides native environment tool execution — primitive operations like file I/O, shell commands, HTTP requests, and code evaluation. Tools are the most fundamental building block for agent interaction.

Protocol Messages (5 types)

Type StringModelDirection
tool/list/reqToolListRequestAgent → Host
tool/list/respToolListResponseHost → Agent
tool/call/reqToolCallRequestAgent → Host
tool/call/respToolCallResponseHost → Agent
tool/eventToolEventHost → Agent (streaming)

ToolDefinition

FieldTypeDescription
namestrUnique tool name (e.g. "read_file")
descriptionstrWhat the tool does
input_parameterslist[ToolParameter]Input schema
output_parameterslist[ToolParameter]Output schema
streamingboolSupports streaming events
idempotentboolSafe to retry
tagslist[str]Classification tags
versionstrTool version
toolkitstrParent toolkit name
defer_loadingboolExclude from initial list; discoverable via search

ToolParameter

FieldTypeDescription
namestrParameter name
typestrJSON Schema type (string, number, object, etc.)
descriptionstrParameter description
requiredboolWhether this parameter is required
enumlistAllowed values
propertieslist[ToolParameter]Nested object properties

ToolListRequest

FieldTypeDescription
filter_kindstrTool kind filter (empty = all)
filter_tagslist[str]Tag filter (AND semantics)
querystrSearch query — empty = list mode, non-empty = search mode
include_deferredboolInclude deferred tools in results

ToolCallRequest

FieldTypeDescription
session_idstrSession identifier
tool_namestrTool to invoke
argumentsdictInput arguments
correlation_idstrOptional correlation
streamingboolRequest streaming events
timeoutfloatExecution timeout

ToolResult

FieldTypeDescription
successboolWhether execution succeeded
datadictResult data
summarystrHuman-readable summary
truncatedboolOutput was truncated
exit_codeintProcess exit code (if applicable)
errorstrError message
error_codeToolErrorCodeMachine-readable error
duration_msintExecution time
eventslist[ToolEvent]Collected streaming events

ToolEvent (extends A2EEvent)

Streaming mid-call events with kind: progress, status, artifact, log.

ToolErrorCode

CodeDescription
UNKNOWN_TOOLTool name not found
TOOL_DENIEDTool not allowed by policy
TOOL_ERRORTool execution failed

ToolPlugin ABC

python
class ToolPlugin(A2EPlugin):
    name = "base_tool"

    @abstractmethod
    def _list_tools(self) -> list[ToolDefinition]: ...

    @abstractmethod
    def _execute_tool(self, tool_name: str, arguments: dict) -> dict: ...

    def _search_tools(self, query, filter_tags=None, tools=None) -> list[ToolDefinition]:
        """Default: substring match. Override for BM25/embeddings."""

    def set_event_callback(self, cb): ...
    def emit(self, kind, data): ...  # Build and send ToolEvent

Handler: handle(msg) dispatches:

  • ToolListRequest with empty query → calls _list_tools(), filters out defer_loading=True, returns ToolListResponse
  • ToolListRequest with non-empty query → calls _search_tools(), returns ToolListResponse
  • ToolCallRequest → calls _execute_tool(), returns ToolCallResponse or A2EError

ToolAPI (Client)

python
from a2e.caps.tools.client import ToolAPI

tools = ToolAPI(client)

# List active (non-deferred) tools
tool_list = tools.list()
# Returns List[ToolDefinition]

# Search all tools by name/description/tags (including deferred)
search_results = tools.list(query="github", include_deferred=True)
for t in search_results:
    print(f"  {t.name}: {t.description}")

# Filter by tags
network_tools = tools.list(tags=["network"])

# Call a tool
result = tools.call(
    tool_name="read_file",
    arguments={"path": "/etc/hostname"},
    streaming=False,       # Enable streaming events
    on_event=None,         # Callback for ToolEvents
    timeout=30.0,
    correlation_id=None
)
# Returns ToolResult

if result.success:
    print(result.data)
else:
    print(f"Error: {result.error_code} - {result.error}")

Caching: tools.list() caches results in client._tools_cache.

A2E Protocol v1.0 — Released under the MIT License.