Search Memory
When to Search
Strong signals:
- References prior work: "the approach we used", "like last time"
- Resumes a named feature, project, or migration
- Review, regression, release, docs-alignment, or connector-behavior task
- Debugging resembles a past fix or known root cause
- Asks for rationale: "why did we choose X?"
- Recurring theme discussed in earlier sessions
Contextual signals:
- Complex debugging (may match past root causes)
- Architecture discussion (choices may be documented)
- Domain-specific question (conventions likely stored)
- User mentions a timeframe: "last week", "back in January"
Skip when:
- Fundamentally new topic with no prior context
- Generic syntax or language questions
- User explicitly requests a fresh perspective
Retrieval Routing
1. Search memories (distilled knowledge)
nmem --json m search "3-7 word semantic query"
If the runtime already knows the active project or agent lane, add --space "<space name>".
2. Search threads (past conversations)
When the user asks about a prior session, discussion, or exact exchange:
nmem --json t search "query" --limit 5
3. Bounded thread inspection
If a thread looks relevant, inspect one small targeted message range:
nmem --json t show <thread_id> --limit 8 --offset 0 --content-limit 1200
Use a known target --offset once; do not advance through pages.
For continuation-heavy engineering work, search near the start of the task rather than waiting for an explicit recall request.
Key Flags
| Flag | Purpose |
|------|---------|
| --mode deep | Conceptual or weak first-pass results |
| -l label | Filter by label (multiple uses AND logic) |
| -n limit | Limit number of results (default: 10) |
| --importance MIN | Minimum importance score (0.0-1.0) |
| --time RANGE | Time filter: today, week, month, year |
Examples
# Semantic search with importance filter
nmem --json m search "database optimization" --importance 0.7
# Filter by labels
nmem --json m search "React patterns" -l frontend -l react
# Recent memories only
nmem --json m search "deployment fix" --time week -n 5
# Deep mode for conceptual queries
nmem --json m search "auth architecture rationale" --mode deep
Interpreting Results
Scores: 0.6-1.0 direct match. 0.3-0.6 related. Below 0.3, skip.
Found: Synthesize and cite when helpful.
None: State clearly. Suggest distilling if the current discussion is valuable.
When NOT to Search
Do not search for every message. Search when there is a reasonable expectation that prior knowledge exists and would improve the response. One well-targeted search is better than three speculative ones.
Links
Bounded thread reads
Search memories or threads first, then choose the specific conversation and message range needed. Call thread_fetch_messages, a host thread-fetch tool, or nmem --json t show at most once per question, using a small message limit (for example 8) and a content limit of 1200 where supported. A known target range may use a nonzero offset once.
Never loop over offsets to reconstruct a conversation. Do not raise --content-limit to compensate for a slow or incomplete read. Small output limits do not guarantee cheap server-side work on every deployed backend. If a read is slow, incomplete, fails or times out, stop, report the evidence gap, and refine the search rather than retrying pages. A later explicit user request for another range is a new bounded read; a routine “continue” is not permission to drain the thread.
What Each Search Matches
- Memory search is semantic: describe the concept. Memories are distilled, so
exact times, people, and wording live in the source conversation. A result's
source_pointer names that thread and the message range the Memory came
from. For one bounded CLI read, use the offset and limit from
source_pointer.expand in nmem --json t show <thread_id> --offset <offset> --limit <limit>.
If the hint omits the range, use offset 0 and limit 8. Verify a result
labeled anchor_support (low confidence) there before relying on it.
- Thread search is keyword full-text search, not semantic search: query with
names, exact words, and distinctive terms, and try a few phrasings when the
first finds nothing. A search_guidance hint lists the query terms no Memory
contained; they are good thread-search terms. A thread_evidence block holds
a few keyword-matched raw messages; treat them as leads, not conclusions.