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)


525
526
527
528
529
530
531
532
533
# File 'lib/ag_ui_protocol/core/events.rb', line 525

def initialize(message_id:, tool_call_id:, content:, role: nil, timestamp: nil, raw_event: nil)
  raise ArgumentError, "role must be tool, got #{role}" 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.



504
505
506
# File 'lib/ag_ui_protocol/core/events.rb', line 504

def content
  @content
end

#message_idObject (readonly)

Returns the value of attribute message_id.



498
499
500
# File 'lib/ag_ui_protocol/core/events.rb', line 498

def message_id
  @message_id
end

#roleObject (readonly)

Returns the value of attribute role.



507
508
509
# File 'lib/ag_ui_protocol/core/events.rb', line 507

def role
  @role
end

#tool_call_idObject (readonly)

Returns the value of attribute tool_call_id.



501
502
503
# File 'lib/ag_ui_protocol/core/events.rb', line 501

def tool_call_id
  @tool_call_id
end

Instance Method Details

#to_hObject



536
537
538
539
540
541
542
543
# File 'lib/ag_ui_protocol/core/events.rb', line 536

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