Class: Phronomy::Agent::JournalProjection

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/agent/journal_projection.rb

Constant Summary collapse

MESSAGE_KINDS =
%i[
  external_message assistant_message tool_message
  llm_message tool_call tool_result
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(persistence:, agent_root:) ⇒ JournalProjection

Returns a new instance of JournalProjection.



11
12
13
14
# File 'lib/phronomy/agent/journal_projection.rb', line 11

def initialize(persistence:, agent_root:)
  @persistence = persistence
  @agent_root = agent_root
end

Instance Method Details

#llm_call_recordsObject



25
26
27
# File 'lib/phronomy/agent/journal_projection.rb', line 25

def llm_call_records
  records.select { |record| record.kind == :llm_call_recorded }
end

#recordsObject



29
30
31
# File 'lib/phronomy/agent/journal_projection.rb', line 29

def records
  @records ||= @persistence.journals.read(@agent_root.agent_id)
end

#transcript_recordsObject



16
17
18
19
20
21
22
23
# File 'lib/phronomy/agent/journal_projection.rb', line 16

def transcript_records
  generation = @agent_root.transcript_generation
  records.select do |record|
    record.context_candidate &&
      record.context_generation == generation &&
      MESSAGE_KINDS.include?(record.kind)
  end
end