class RubyLLM::AgUI::Reconnect

What a client that re-sends an input whose run already ended gets (FR-05).

A reconnect is not a second execution. The run ended, so the client gets its outcome and the state snapshot the run recorded instead of the deltas it may already have — or may have missed. Replaying deltas would apply text twice and could run a tool twice, so they are never replayed.

What cannot be served this way is a run that has not ended: attaching a second stream to a live run needs a relay the gem does not own, and a silent second stream would duplicate the work. Those are refused.

Constants

UNRECORDED_FAILURE

The failure reported for a run that failed before its sanitized error was recorded — a record from an older release, or one whose write was interrupted.

Public Class Methods

new(record:, input:) click to toggle source
# File lib/ruby_llm/ag_ui/reconnect.rb, line 28
def initialize(record:, input:)
  @record = record
  @input = input
end
serves?(record) click to toggle source

Whether record can be served to a client that reconnects.

# File lib/ruby_llm/ag_ui/reconnect.rb, line 24
def self.serves?(record)
  record.terminal?
end

Public Instance Methods

events() click to toggle source

The events to write, in order: the run opens, declares the state it owns, and reports the outcome already recorded.

# File lib/ruby_llm/ag_ui/reconnect.rb, line 35
def events
  [open_event, *snapshot_events, terminal_event]
end