class RubyLLM::ActiveRecord::ToolCall
A tool call a message requested, in RubyLLM’s ruby_llm_tool_calls table. An assistant message reaches its calls through ruby_llm_tool_calls, oldest first, and a tool message reaches the call it answers through ruby_llm_parent_tool_call.
message.ruby_llm_tool_calls.pluck(:name) # => ["weather", "search"] RubyLLM::ActiveRecord::ToolCall.where(name: "weather").count
Each row belongs to message, the assistant message that requested it, and to result, the tool message that answers it once there is one. Both associations are polymorphic. Its columns:
tool_call_id-
The call’s id, unique across the table.
name-
The tool’s name.
namespace-
The namespace of a namespaced tool, or
nil. arguments-
The arguments the model passed, as a Hash.
approval-
"pending","approved","remembered", or"denied", ornilwhen no approval was asked. remote-
Whether the provider ran the tool instead of
RubyLLM.
RubyLLM writes these rows. Read and query them, and add scopes and columns of your own, but do not create or update them.
Public Instance Methods
Source
# File lib/ruby_llm/active_record/tool_call.rb, line 59 def paused? has_attribute?(:mcp_state) && mcp_state.present? end
Returns whether the call waits on a task or an MCP input request.
Source
# File lib/ruby_llm/active_record/tool_call.rb, line 54 def running? (result_id.nil? && has_attribute?(:claimed_until) && claimed_until&.future?) || false end
Returns whether a process is running this tool call: it has no result yet and its claim has not expired.
Source
# File lib/ruby_llm/active_record/tool_call.rb, line 40 def to_llm RubyLLM::ToolCall.new( id: tool_call_id, provider_call_id: self[:provider_call_id], name: name, namespace: self[:namespace], arguments: arguments || {}, thought_signature: thought_signature, remote: self[:remote] ) end
Returns this row as a RubyLLM::ToolCall.