Class: Agent::Sessions::Readers::Amp

Inherits:
Base
  • Object
show all
Defined in:
lib/agent/sessions/readers/amp.rb

Overview

Amp threads. Written against the one real thread available (2026-08-14): 24 messages, content parts tool_use 14, tool_result 14, text 2, thinking 1. One thread is thin evidence beside Codex's 415 files, and this reader says so through partial? rather than pretending otherwise.

Two things make Amp unlike the JSONL readers:

A thread is ONE JSON document, so it cannot be streamed a record at a time. Reading any of it means holding all of it, which is the gem's one unbounded read (0.2 follow-up 8). each_record below is where that bound finally lives.

And its tool results are spelled its own way — toolUseID rather than tool_use_id, the payload under run.result rather than content. A mapper copied from Claude's would produce empty tool results and no warning, which is why each reader maps its own agent rather than sharing one.

Constant Summary collapse

MAX_DOCUMENT_BYTES =

150x the observed thread. A cap has to exist because nothing about a thread file announces its size before it is opened, and JSON.parse of a 200 MB document costs several times that in live objects. Refused and reported beats NoMemoryError, and beats silence either way.

32_000_000
CONTENT_PARTS =
{ "text" => :text, "thinking" => :thinking,
"tool_use" => :tool_use, "tool_result" => :tool_result,
"image" => :image }.freeze
ROLES =
{ "user" => :user, "assistant" => :assistant,
"system" => :system, "tool" => :tool }.freeze

Constants inherited from Base

Base::MAX_RECORD_BYTES

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods inherited from Base

#branching?, #compactions, #each_message, #fidelity, #initialize, #messages, #tree, #usage, #warnings

Constructor Details

This class inherits a constructor from Agent::Sessions::Readers::Base

Instance Method Details

#partial?Boolean

The server holds the canonical copy; a local thread may be a mirror of part of the conversation. The adapter carries the same warning.

Returns:

  • (Boolean)


38
# File 'lib/agent/sessions/readers/amp.rb', line 38

def partial? = true