class

Autobot::Agent::ToolExecutor

Inherits Reference < Object

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

new(provider : Providers::Provider, context : Context::Builder, model : String, max_iterations : Int32 = 20, max_tokens : Int32 = Config::AgentDefaults.new.max_tokens, temperature : Float64 = Config::AgentDefaults.new.temperature)
Source

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 tools
  • session_key: for per-session rate limiting and prompt cache routing (nil for subagents)
  • exclude_tools: tool names to omit from LLM tool definitions
  • stop_after: tool names whose successful call ends the turn (e.g. "message" for cron)
Source

Nested types