Class: SwarmSDK::Hooks::ToolCall

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_sdk/hooks/tool_call.rb

Overview

Represents a tool call in the hooks system

This is a simple value object that wraps tool call information from RubyLLM in a consistent, immutable format for hooks.

Examples:

Access tool call information in a hook

swarm.add_callback(:pre_tool_use) do |context|
  puts "Tool: #{context.tool_call.name}"
  puts "Parameters: #{context.tool_call.parameters.inspect}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, parameters:) ⇒ ToolCall

Returns a new instance of ToolCall.

Parameters:

  • id (String)

    Unique identifier for this tool call

  • name (String)

    Name of the tool being called

  • parameters (Hash)

    Parameters passed to the tool



21
22
23
24
25
# File 'lib/swarm_sdk/hooks/tool_call.rb', line 21

def initialize(id:, name:, parameters:)
  @id = id
  @name = name
  @parameters = parameters
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/swarm_sdk/hooks/tool_call.rb', line 16

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/swarm_sdk/hooks/tool_call.rb', line 16

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



16
17
18
# File 'lib/swarm_sdk/hooks/tool_call.rb', line 16

def parameters
  @parameters
end

Instance Method Details

#to_hHash

Convert to hash representation

Returns:

  • (Hash)

    Hash with id, name, and parameters



30
31
32
# File 'lib/swarm_sdk/hooks/tool_call.rb', line 30

def to_h
  { id: @id, name: @name, parameters: @parameters }
end