class RubyLLM::AgUI::Rails::Record
The durable form of one core run record.
The core RunRecord stays the authority; this row is where it lives between requests, so a run reserved on one Puma worker is the same run on the next. Identity is duplicated out of the payload into indexed columns so a thread can be listed without parsing JSON, and the payload is written whole because a record is immutable: there is no partial update to make.
The payload is JSON text, not a database JSON column. The record is never queried by content, and encoding it here keeps the stored shape exactly ‘RunRecord#to_storage` on every database and every Rails version, instead of inheriting whichever encoder the host’s ActiveSupport picks.
Create the table with ‘bin/rails generate ruby_llm:ag_ui:install`.
Public Class Methods
An unsaved row carrying record.
# File lib/ruby_llm/ag_ui/rails/record.rb, line 42 def self.from_run_record(record) new( scope: record.scope, thread_id: record.thread_id, run_id: record.run_id, digest: record.digest, status: record.status.to_s, sequence: record.sequence, payload: ::JSON.generate(record.to_storage) ) end
Public Instance Methods
The core record this row stores.
# File lib/ruby_llm/ag_ui/rails/record.rb, line 27 def as_run_record ::RubyLLM::AgUI::RunRecord.from_storage(::JSON.parse(payload)) end
Writes record onto this row and returns the record.
The identity columns are not writable: a row keeps the identity it was reserved with, so a record cannot be stored under another run’s key.
# File lib/ruby_llm/ag_ui/rails/record.rb, line 35 def write_run_record(record) update!(digest: record.digest, status: record.status.to_s, sequence: record.sequence, payload: ::JSON.generate(record.to_storage)) record end