Class: Tools::Remember

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

Overview

Fractal-resolution zoom into event history. Returns a window centered on a target event with full detail at the center and compressed context at the edges — sharp fovea, blurry periphery.

Output structure:

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

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

Examples:

remember(event_id: 42)

Constant Summary collapse

CONTEXT_WINDOW =

Events around the target to include at full resolution. ±10 events 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

Constructor Details

#initialize(session:) ⇒ Remember

Returns a new instance of Remember.



52
53
54
# File 'lib/tools/remember.rb', line 52

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

Class Method Details

.descriptionObject



31
32
33
34
35
36
37
# File 'lib/tools/remember.rb', line 31

def self.description
  "Recall the full context around a past event. " \
    "Returns a fractal-resolution window: high detail at the center " \
    "(the target event and its neighbors), compressed context at the edges " \
    "(snapshots before and after). Use this when search results surface " \
    "a relevant event and you need the surrounding conversation."
end

.input_schemaObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/tools/remember.rb', line 39

def self.input_schema
  {
    type: "object",
    properties: {
      event_id: {
        type: "integer",
        description: "The event ID to zoom into (from search results or recall snippets)"
      }
    },
    required: ["event_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 event.

Parameters:

  • input (Hash)

    with “event_id”

Returns:

  • (String)

    fractal-resolution window around the target event



58
59
60
61
62
63
64
# File 'lib/tools/remember.rb', line 58

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

  build_fractal_window(target)
end