Class: Tools::Recall

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

Overview

Active memory search — keyword lookup across conversation history. Returns ranked snippets with message IDs for drill-down via Remember.

Two-step memory workflow:

1. `recall(query: "auth flow")` → discovers relevant messages
2. `remember(message_id: 42)` → fractal zoom into full context

Wraps Mneme::Search — same FTS5 engine used by passive recall, but triggered on demand by the agent instead of automatically by goals.

Examples:

Search all sessions

recall(query: "authentication flow")

Search current session only

recall(query: "OAuth config", session_only: true)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

schema, truncation_threshold

Constructor Details

#initialize(session:) ⇒ Recall

Returns a new instance of Recall.

Parameters:

  • session (Session)

    the current session (used for session_only scoping)



36
37
38
# File 'lib/tools/recall.rb', line 36

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

Class Method Details

.descriptionObject



22
# File 'lib/tools/recall.rb', line 22

def self.description = "Find messages across past conversations by keywords."

.input_schemaObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/tools/recall.rb', line 24

def self.input_schema
  {
    type: "object",
    properties: {
      query: {type: "string"},
      session_only: {type: "boolean", description: "Default: all sessions"}
    },
    required: ["query"]
  }
end

.tool_nameObject



20
# File 'lib/tools/recall.rb', line 20

def self.tool_name = "recall"

Instance Method Details

#execute(input) ⇒ String, Hash

Parameters:

  • input (Hash)

    with “query” and optional “session_only”

Returns:

  • (String)

    formatted search results with message IDs

  • (Hash)

    with :error key when query is blank



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tools/recall.rb', line 43

def execute(input)
  query = input["query"].to_s.strip
  return {error: "Query cannot be blank"} if query.empty?

  session_id = (input["session_only"] == true) ? @session.id : nil
  results = Mneme::Search.query(query, session_id: session_id)

  return "No results found for \"#{query}\"." if results.empty?

  format_results(query, results)
end