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. Empty when the model’s text was not a JSON object.
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 56 def arguments value = self[:arguments] value.is_a?(Hash) ? value : {} end
Returns the arguments the model passed, as a Hash, or an empty Hash when the model’s text was not a JSON object.
Source
# File lib/ruby_llm/active_record/tool_call.rb, line 75 def paused? has_attribute?(:mcp_state) && mcp_state.present? end
Returns whether the call waits on a task or on questions it asked.
Source
# File lib/ruby_llm/active_record/tool_call.rb, line 70 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. The process running it keeps renewing the claim, which expires within a minute of that process dying.
Source
# File lib/ruby_llm/active_record/tool_call.rb, line 41 def to_llm RubyLLM::ToolCall.new( id: tool_call_id, provider_call_id: self[:provider_call_id], name: name, namespace: self[:namespace], arguments: arguments, malformed_arguments: malformed_arguments, thought_signature: thought_signature, remote: self[:remote] ) end
Returns this row as a RubyLLM::ToolCall.