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
Arguments
- tool_calls
A list of tool call objects, each with id, name, and arguments.
- tools
A list of Tool objects to search for matching tools.
- hooks
Optional HookHandler object.
- envir
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.
- repair_enabled
Whether to attempt tool call repair (default TRUE).