Class: Mneme::PassiveRecall

Inherits:
Object
  • Object
show all
Defined in:
lib/mneme/passive_recall.rb

Overview

Passive recall — automatic memory surfacing triggered by Goal updates. When goals are created or updated, searches event history for related context and caches the results on the session for viewport injection.

The agent never calls a tool; relevant memories appear automatically in the viewport between snapshots and the sliding window. This mirrors recognition memory in humans — context surfaces without conscious effort.

Examples:

Trigger after a goal update

Mneme::PassiveRecall.new(session).call

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ PassiveRecall

Returns a new instance of PassiveRecall.

Parameters:

  • session (Session)

    the session whose goals drive recall



16
17
18
# File 'lib/mneme/passive_recall.rb', line 16

def initialize(session)
  @session = session
end

Instance Method Details

#callArray<Mneme::Search::Result>

Searches event history using active goal descriptions as queries. Returns recall results suitable for viewport injection.

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mneme/passive_recall.rb', line 24

def call
  goals = @session.goals.active.root.includes(:sub_goals)
  return [] if goals.empty?

  search_terms = build_search_terms(goals)
  return [] if search_terms.blank?

  results = Mneme::Search.query(search_terms, limit: Anima::Settings.recall_max_results)

  # Exclude events from the current session's viewport — no point recalling
  # what the agent already sees.
  viewport_ids = @session.viewport_message_ids.to_set
  results.reject { |result| viewport_ids.include?(result.message_id) }
end