Class: Tools::SearchMessages
Overview
Keyword search across long-term memory — every message Anima has ever seen, across every session, except what the agent is already looking at right now. Results sit below her current viewport; anything still in front of her is excluded, so every slot the search returns is new information.
Two-step memory workflow:
1. `search_messages(query: "auth flow")` → discovers relevant messages
2. `view_messages(message_id: 42)` → fractal zoom into full context
Same FTS5 engine Mneme uses for passive recall — this variant fires on demand when Aoide reaches for a memory herself.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(input) ⇒ String, Hash
-
#initialize(session:) ⇒ SearchMessages
constructor
A new instance of SearchMessages.
Methods inherited from Base
prompt_guidelines, prompt_snippet, schema, truncation_threshold
Constructor Details
#initialize(session:) ⇒ SearchMessages
Returns a new instance of SearchMessages.
35 36 37 |
# File 'lib/tools/search_messages.rb', line 35 def initialize(session:, **) @session = session end |
Class Method Details
.description ⇒ Object
22 |
# File 'lib/tools/search_messages.rb', line 22 def self.description = "Search long-term memory (past conversations outside your current viewport) by keyword. Returns ranked message snippets with IDs — pass any ID to view_messages to see the full context around it." |
.input_schema ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/tools/search_messages.rb', line 24 def self.input_schema { type: "object", properties: { query: {type: "string"} }, required: ["query"] } end |
.tool_name ⇒ Object
20 |
# File 'lib/tools/search_messages.rb', line 20 def self.tool_name = "search_messages" |
Instance Method Details
#execute(input) ⇒ String, Hash
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tools/search_messages.rb', line 42 def execute(input) query = input["query"].to_s.strip return {error: "Query cannot be blank"} if query.empty? results = Mneme::Search.query(query, caller_session: @session) return "No results found for \"#{query}\"." if results.empty? format_results(query, results) end |