Execute a list of tool calls returned by an LLM. This function safely executes each tool, handling errors gracefully and returning a standardized result format.
Implements multi-layer defense strategy:
Tool name repair (case fixing, snake_case conversion, fuzzy matching)
Invalid tool routing for graceful degradation
Argument parsing with JSON repair
Error capture and structured error responses
execute_tool_calls(
tool_calls,
tools,
hooks = NULL,
envir = NULL,
repair_enabled = TRUE
)A list of execution results, each containing:
id: The tool call ID
name: The tool name
result: The execution result (or error message)
is_error: TRUE if an error occurred during execution
A list of tool call objects, each with id, name, and arguments.
A list of Tool objects to search for matching tools.
Optional HookHandler object.
Optional environment in which to execute tools. When provided, tool functions can access and modify variables in this environment, enabling cross-agent data sharing through a shared session environment.
Whether to attempt tool call repair (default TRUE).