Class: Miniswen::Trajectory

Inherits:
Object
  • Object
show all
Defined in:
lib/miniswen/trajectory.rb

Overview

Serializes a finished Agent::Result into an ATIF-v1.7 document.

Constant Summary collapse

SCHEMA_VERSION =
"ATIF-v1.7"
SOURCE =

ATIF has no "tool" source: a tool result is not a step of its own but an observation on the step whose call produced it, so tool entries are folded rather than mapped. Everything left is a step.

{ "system" => "system", "user" => "user", "assistant" => "agent" }.freeze
NOTES =
"total_steps counts model turns; the steps array also carries the system and task " \
"messages, and each tool result rides as an observation on the step that called it"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result:, model:, session_id: nil, agent: {}) ⇒ Trajectory

Returns a new instance of Trajectory.



20
21
22
23
24
25
# File 'lib/miniswen/trajectory.rb', line 20

def initialize(result:, model:, session_id: nil, agent: {})
  @result = result
  @model = model
  @session_id = session_id
  @agent = agent || {}
end

Class Method Details

.from(result, model:, session_id: nil, agent: {}) ⇒ Object



16
17
18
# File 'lib/miniswen/trajectory.rb', line 16

def self.from(result, model:, session_id: nil, agent: {})
  new(result: result, model: model, session_id: session_id, agent: agent)
end

Instance Method Details

#to_atifObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/miniswen/trajectory.rb', line 27

def to_atif
  {
    schema_version: SCHEMA_VERSION,
    session_id: session_id,
    agent: agent_info,
    steps: steps,
    notes: NOTES,
    final_metrics: final_metrics,
    extra: { status: result.status, submission: result.submission, error: result.error }.compact
  }.compact
end