Autobot::Agent::ToolExecutor
Executes the ReAct-style tool-calling loop.
Calls the LLM, executes any requested tool calls, appends results, and repeats until the LLM returns a text response or max iterations is reached.
Used by Loop (for user messages, system messages, cron) and SubagentManager (for background tasks) to avoid duplicating the core agentic loop logic.
Constants
Log = ::Log.for("agent.tool_executor")
MAX_TOOL_RESULT_CHARS = 20000
MESSAGE_PREVIEW_LENGTH = 120
Constructors
Instance methods
execute(messages : Array(Hash(String, JSON::Any)), tools : Tools::Registry, session_key : String | Nil = nil, exclude_tools : Array(String) | Nil = nil, stop_after : Array(String) = [] of String) : Result
Run the tool-calling loop.
messages: the full message array (system + history + user)tools: registry of available toolssession_key: for per-session rate limiting and prompt cache routing (nil for subagents)exclude_tools: tool names to omit from LLM tool definitionsstop_after: tool names whose successful call ends the turn (e.g. "message" for cron)