class RubyLLM::ToolCall
A ToolCall is a request to run a tool with specific arguments. Instances appear in Message#tool_calls. Local calls are yielded to tool callbacks such as Chat#before_tool_call. Remote calls awaiting approval return true from remote? and appear in Chat#pending_approvals.
chat.before_tool_call do |tool_call| puts "Calling tool: #{tool_call.name}" puts "Arguments: #{tool_call.arguments}" end
Attributes
The arguments the model supplied for the invocation, as a Hash. Keys are ordered the way PostgreSQL jsonb and MySQL json store them, shorter keys first, so a call reloaded from the database renders the same request bytes and keeps the provider’s prompt cache.
The RubyLLM identifier for this invocation. The tool result message answering this call carries the same id, including after a reload. This is independent of the ID in the provider’s response.
The name of the tool the model wants to invoke.
The Gemini thought signature attached to this call, or nil. RubyLLM replays it to the provider on later requests.
Public Instance Methods
Source
# File lib/ruby_llm/tool_call.rb, line 42 def remote? = @remote
Returns true if the provider executes this call after approval. Local tools executed by the application return false.
Source
# File lib/ruby_llm/tool_call.rb, line 72 def to_h { id: @id, provider_call_id: @provider_call_id, name: @name, arguments: @arguments, remote: remote? || nil, thought_signature: @thought_signature }.compact end
Returns the call as a Hash, omitting nil values.