Class: Events::ToolExecuted

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

Overview

Emitted by ToolExecutionJob after a tool finishes running. Carries the tool result so the response subscriber can create a tool_response PendingMessage and release the session back to idle — which in turn wakes the drain loop for the next LLM round.

Constant Summary collapse

TYPE =
"session.tool_executed"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session_id:, tool_use_id:, tool_name:, content:, success:) ⇒ ToolExecuted

Returns a new instance of ToolExecuted.

Parameters:

  • session_id (Integer)

    session the tool ran on behalf of

  • tool_use_id (String)

    pairing ID for the originating tool_use block

  • tool_name (String)

    name of the tool that executed

  • content (String)

    tool output (already formatted and truncated)

  • success (Boolean)

    true on normal completion, false on error or interrupt



18
19
20
21
22
23
24
# File 'lib/events/tool_executed.rb', line 18

def initialize(session_id:, tool_use_id:, tool_name:, content:, success:)
  @session_id = session_id
  @tool_use_id = tool_use_id
  @tool_name = tool_name
  @content = content
  @success = success
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



11
12
13
# File 'lib/events/tool_executed.rb', line 11

def content
  @content
end

#session_idObject (readonly)

Returns the value of attribute session_id.



11
12
13
# File 'lib/events/tool_executed.rb', line 11

def session_id
  @session_id
end

#successObject (readonly)

Returns the value of attribute success.



11
12
13
# File 'lib/events/tool_executed.rb', line 11

def success
  @success
end

#tool_nameObject (readonly)

Returns the value of attribute tool_name.



11
12
13
# File 'lib/events/tool_executed.rb', line 11

def tool_name
  @tool_name
end

#tool_use_idObject (readonly)

Returns the value of attribute tool_use_id.



11
12
13
# File 'lib/events/tool_executed.rb', line 11

def tool_use_id
  @tool_use_id
end

Instance Method Details

#event_nameObject



26
27
28
# File 'lib/events/tool_executed.rb', line 26

def event_name
  "#{Bus::NAMESPACE}.#{TYPE}"
end

#to_hObject



30
31
32
# File 'lib/events/tool_executed.rb', line 30

def to_h
  {type: TYPE, session_id:, tool_use_id:, tool_name:, content:, success:}
end