Class: Events::ToolCall

Inherits:
Base
  • Object
show all
Defined in:
lib/events/tool_call.rb

Constant Summary collapse

TYPE =
"tool_call"

Instance Attribute Summary collapse

Attributes inherited from Base

#content, #session_id, #timestamp

Instance Method Summary collapse

Methods inherited from Base

#event_name

Constructor Details

#initialize(content:, tool_name:, tool_input: {}, tool_use_id: nil, timeout: nil, session_id: nil) ⇒ ToolCall

Returns a new instance of ToolCall.

Parameters:

  • content (String)

    human-readable description of the tool call

  • tool_name (String)

    registered tool name (e.g. “web_get”)

  • tool_input (Hash) (defaults to: {})

    arguments passed to the tool

  • tool_use_id (String) (defaults to: nil)

    Anthropic-assigned ID for correlating call/result

  • timeout (Integer) (defaults to: nil)

    maximum seconds before the call is considered orphaned

  • session_id (String, nil) (defaults to: nil)

    optional session identifier



15
16
17
18
19
20
21
# File 'lib/events/tool_call.rb', line 15

def initialize(content:, tool_name:, tool_input: {}, tool_use_id: nil, timeout: nil, session_id: nil)
  super(content: content, session_id: session_id)
  @tool_name = tool_name
  @tool_input = tool_input
  @tool_use_id = tool_use_id
  @timeout = timeout
end

Instance Attribute Details

#timeoutObject (readonly)

Returns the value of attribute timeout.



7
8
9
# File 'lib/events/tool_call.rb', line 7

def timeout
  @timeout
end

#tool_inputObject (readonly)

Returns the value of attribute tool_input.



7
8
9
# File 'lib/events/tool_call.rb', line 7

def tool_input
  @tool_input
end

#tool_nameObject (readonly)

Returns the value of attribute tool_name.



7
8
9
# File 'lib/events/tool_call.rb', line 7

def tool_name
  @tool_name
end

#tool_use_idObject (readonly)

Returns the value of attribute tool_use_id.



7
8
9
# File 'lib/events/tool_call.rb', line 7

def tool_use_id
  @tool_use_id
end

Instance Method Details

#to_hObject



27
28
29
# File 'lib/events/tool_call.rb', line 27

def to_h
  super.merge(tool_name: tool_name, tool_input: tool_input, tool_use_id: tool_use_id, timeout: timeout)
end

#typeObject



23
24
25
# File 'lib/events/tool_call.rb', line 23

def type
  TYPE
end