Class: Riffer::StreamEvents::Interrupt

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/stream_events/interrupt.rb

Overview

Represents an interrupt event during streaming.

Emitted when a callback interrupts the agent loop via throw :riffer_interrupt.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(reason: nil, healed_tool_call_ids: []) ⇒ Interrupt

– : (?reason: (String | Symbol)?, ?healed_tool_call_ids: Array) -> void



18
19
20
21
22
# File 'lib/riffer/stream_events/interrupt.rb', line 18

def initialize(reason: nil, healed_tool_call_ids: [])
  super(role: :system)
  @reason = reason
  @healed_tool_call_ids = healed_tool_call_ids
end

Instance Attribute Details

#healed_tool_call_idsObject (readonly)

Call ids of tool_use blocks that riffer filled with placeholder results when the interrupt fired. Populated only when Riffer.config.experimental_history_healing is on.



14
15
16
# File 'lib/riffer/stream_events/interrupt.rb', line 14

def healed_tool_call_ids
  @healed_tool_call_ids
end

#reasonObject (readonly)

The reason provided with the interrupt, if any.



9
10
11
# File 'lib/riffer/stream_events/interrupt.rb', line 9

def reason
  @reason
end

Instance Method Details

#to_hObject

Converts the event to a hash.

– : () -> Hash[Symbol, untyped]



28
29
30
31
32
33
# File 'lib/riffer/stream_events/interrupt.rb', line 28

def to_h
  h = {role: @role, interrupt: true}
  h[:reason] = @reason if @reason
  h[:healed_tool_call_ids] = @healed_tool_call_ids unless @healed_tool_call_ids.empty?
  h
end