Class: AgUiProtocol::Core::Events::ReasoningMessageStartEvent

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

Overview

Signals the start of a reasoning message within a reasoning block.

The ‘role` is always “reasoning” (enforced). The optional `role:` kwarg exists to support round-trip deserialization from `to_h` output (which emits `role: “reasoning”`); supplying any other value raises ArgumentError.

“‘ruby event = AgUiProtocol::Core::Events::ReasoningMessageStartEvent.new(message_id: “reason_msg_1”) “`

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:, role: nil, timestamp: nil, raw_event: nil) ⇒ ReasoningMessageStartEvent

Returns a new instance of ReasoningMessageStartEvent.



1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
# File 'lib/ag_ui_protocol/core/events.rb', line 1190

def initialize(message_id:, role: nil, timestamp: nil, raw_event: nil)
  if !role.nil? && role != "reasoning"
    raise ArgumentError, "ReasoningMessageStartEvent.role must be \"reasoning\""
  end

  super(type: EventType::REASONING_MESSAGE_START, timestamp: timestamp, raw_event: raw_event)
  @message_id = message_id
  # Role is always "reasoning" for ReasoningMessageStartEvent.
  @role = "reasoning"
end

Instance Attribute Details

#message_idObject (readonly)

Returns the value of attribute message_id.



1180
1181
1182
# File 'lib/ag_ui_protocol/core/events.rb', line 1180

def message_id
  @message_id
end

#roleObject (readonly)

Returns the value of attribute role.



1183
1184
1185
# File 'lib/ag_ui_protocol/core/events.rb', line 1183

def role
  @role
end

Instance Method Details

#to_hObject



1202
1203
1204
# File 'lib/ag_ui_protocol/core/events.rb', line 1202

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