Class: Tools::Remember

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

Overview

Fractal-resolution zoom into message history. Returns a window centered on a target message with full detail at the center and compressed context 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]

The agent discovers target messages via FTS5 search results embedded in viewport recall snippets. This tool drills down into the full context.

Examples:

remember(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

schema, truncation_threshold

Constructor Details

#initialize(session:) ⇒ Remember

Returns a new instance of Remember.



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

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

Class Method Details

.descriptionObject



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

def self.description = "Recall the full conversation around a past message."

.input_schemaObject



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

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

.tool_nameObject



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

def self.tool_name = "remember"

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/remember.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