Class: Tools::ViewMessages

Inherits:
Base
  • Object
show all
Defined in:
lib/tools/view_messages.rb

Overview

Fractal-resolution window into long-term memory. Given a message_id, returns the surrounding conversation with full detail at the center and compressed snapshots at the edges — sharp fovea, blurry periphery.

Output structure:

[Previous snapshots — compressed context before]
[Messages N-M — full detail, tool_responses compressed to checkmarks]
[Following snapshots — compressed context after]

Aoide discovers target message IDs via SearchMessages and drills down here to recover the full context around any moment.

Examples:

view_messages(message_id: 42)

Constant Summary collapse

CONTEXT_WINDOW =

Messages around the target to include at full resolution. ±10 messages provides sharp foveal detail while keeping output readable.

20
ROLE_LABELS =
{
  "user_message" => "User",
  "agent_message" => "Assistant",
  "system_message" => "System"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

prompt_guidelines, prompt_snippet, schema, truncation_threshold

Constructor Details

#initialize(session:) ⇒ ViewMessages

Returns a new instance of ViewMessages.



43
44
45
# File 'lib/tools/view_messages.rb', line 43

def initialize(session:, **)
  @session = session
end

Class Method Details

.descriptionObject



31
# File 'lib/tools/view_messages.rb', line 31

def self.description = "View the full conversation around a message in long-term memory. Pass a message_id — typically one returned by search_messages — to see the surrounding exchange with compressed snapshots at the edges."

.input_schemaObject



33
34
35
36
37
38
39
40
41
# File 'lib/tools/view_messages.rb', line 33

def self.input_schema
  {
    type: "object",
    properties: {
      message_id: {type: "integer"}
    },
    required: ["message_id"]
  }
end

.tool_nameObject



29
# File 'lib/tools/view_messages.rb', line 29

def self.tool_name = "view_messages"

Instance Method Details

#execute(input) ⇒ String

Returns fractal-resolution window around the target message.

Parameters:

  • input (Hash)

    with “message_id”

Returns:

  • (String)

    fractal-resolution window around the target message



49
50
51
52
53
54
55
# File 'lib/tools/view_messages.rb', line 49

def execute(input)
  message_id = input["message_id"].to_i
  target = Message.find_by(id: message_id)
  return {error: "Message #{message_id} not found"} unless target

  build_fractal_window(target)
end