Class: AgUiProtocol::Core::Events::ToolCallResultEvent

Inherits:
BaseEvent show all
Defined in:
lib/ag_ui_protocol/core/events.rb

Overview

Provides the result of a tool call execution.

“‘ruby

event = AgUiProtocol::Core::Events::ToolCallResultEvent.new(

message_id: "m1",
tool_call_id: "tc1",
content: "ok"

)

“‘

Instance Attribute Summary collapse

Attributes inherited from BaseEvent

#raw_event, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Types::Model

#as_json, #to_json

Constructor Details

#initialize(message_id:, tool_call_id:, content:, role: nil, timestamp: nil, raw_event: nil) ⇒ ToolCallResultEvent

Returns a new instance of ToolCallResultEvent.

Raises:

  • (ArgumentError)


547
548
549
550
551
552
553
554
555
# File 'lib/ag_ui_protocol/core/events.rb', line 547

def initialize(message_id:, tool_call_id:, content:, role: nil, timestamp: nil, raw_event: nil)
  raise ArgumentError, "role must be \"tool\", got #{role.inspect}" if !role.nil? && role != "tool"

  super(type: EventType::TOOL_CALL_RESULT, timestamp: timestamp, raw_event: raw_event)
  @message_id = message_id
  @tool_call_id = tool_call_id
  @content = content
  @role = role
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



526
527
528
# File 'lib/ag_ui_protocol/core/events.rb', line 526

def content
  @content
end

#message_idObject (readonly)

Returns the value of attribute message_id.



520
521
522
# File 'lib/ag_ui_protocol/core/events.rb', line 520

def message_id
  @message_id
end

#roleObject (readonly)

Returns the value of attribute role.



529
530
531
# File 'lib/ag_ui_protocol/core/events.rb', line 529

def role
  @role
end

#tool_call_idObject (readonly)

Returns the value of attribute tool_call_id.



523
524
525
# File 'lib/ag_ui_protocol/core/events.rb', line 523

def tool_call_id
  @tool_call_id
end

Instance Method Details

#to_hObject



558
559
560
561
562
563
564
565
# File 'lib/ag_ui_protocol/core/events.rb', line 558

def to_h
  super.merge(
    message_id: @message_id,
    tool_call_id: @tool_call_id,
    content: @content,
    role: @role
  )
end