Class: AgUiProtocol::Core::Events::RunFinishedEvent

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

Overview

Signals the completion of an agent run. The ‘outcome` field discriminates between success and interrupt: provide either a `RunFinishedSuccessOutcome` or `RunFinishedInterruptOutcome` (or use the legacy `result` field; the two are mutually exclusive).

“‘ruby

event = AgUiProtocol::Core::Events::RunFinishedEvent.new(thread_id: “t1”, run_id: “r1”, result: { “a” => 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(thread_id:, run_id:, result: nil, outcome: nil, timestamp: nil, raw_event: nil) ⇒ RunFinishedEvent

Returns a new instance of RunFinishedEvent.



1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/ag_ui_protocol/core/events.rb', line 1034

def initialize(thread_id:, run_id:, result: nil, outcome: nil, timestamp: nil, raw_event: nil)
  if !result.nil? && !outcome.nil?
    raise ArgumentError, "result and outcome are mutually exclusive; provide one or the other, not both"
  end

  super(type: EventType::RUN_FINISHED, timestamp: timestamp, raw_event: raw_event)
  @thread_id = thread_id
  @run_id = run_id
  @result = result
  @outcome = outcome
end

Instance Attribute Details

#outcomeObject (readonly)

Returns the value of attribute outcome.



1015
1016
1017
# File 'lib/ag_ui_protocol/core/events.rb', line 1015

def outcome
  @outcome
end

#resultObject (readonly)

Returns the value of attribute result.



1012
1013
1014
# File 'lib/ag_ui_protocol/core/events.rb', line 1012

def result
  @result
end

#run_idObject (readonly)

Returns the value of attribute run_id.



1009
1010
1011
# File 'lib/ag_ui_protocol/core/events.rb', line 1009

def run_id
  @run_id
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



1006
1007
1008
# File 'lib/ag_ui_protocol/core/events.rb', line 1006

def thread_id
  @thread_id
end

Instance Method Details

#to_hObject



1047
1048
1049
# File 'lib/ag_ui_protocol/core/events.rb', line 1047

def to_h
  super.merge(thread_id: @thread_id, run_id: @run_id, result: @result, outcome: @outcome)
end