Skip to main content
Glama

memory_search

Retrieve relevant stored memories and preferences when context is missing or ambiguous. Results include relevance and staleness signals, so you can resolve requests using verified project knowledge.

Instructions

Search stored memories. Default: do NOT call — reach for it only when the user references shared context you lack ("my project", "the script we wrote") or a request is ambiguous in a way stored preferences could resolve. When a hit shapes your reply, announce it ("Using your stored preference for…") — non-negotiable. (Full policy: the server instructions block.)

Returns ranked hits with snippets. Per-hit fields the model should branch on:

  • relevance (high/medium/low) — how much of your query wording the hit literally contains, not how good it is. Weak hits: re-query with different nouns.

  • staleness_verdict (fresh / spot_check_recommended / spot_check_required) — rolled-up signal; != fresh, act on path_drift below.

  • match_terms — which query words actually hit.

  • path_drift_missing (int) + path_drift ({checked, missing, verified} when drift detected) — body-cited paths gone. claim_anchored_missing (added when non-empty) is the escalating subset: memory_update those, memory_verify the rest. Prose-scraped missing rides fresh — evidence, not a tier.

  • commit_drift_count (int, when applicable) — commits since last_verified_at on the memory's origin repo. Non-zero means the project moved even if calendar-fresh.

  • depends_on_resolved (when present) — bounded auto-pull of depends_on link targets (max 3 per hit, max 10 per call). Each entry: {id, scopes, summary, link_note}. Surfaces context the query wouldn't on its own; saves a memory_show round-trip. OMITTED when the hit has no depends_on links.

  • recent_negative_outcomes (when present) — list of recent ignored/contradicted events for this memory (max two, one per outcome). The user already rejected this; don't re-surface unless you have new reason. OMITTED when none.

Parameters:

  • query: nouns a memory would contain (tool, file, error names) — vocabulary is the lever, not question phrasing. Weak hits: re-query, different nouns.

  • scopes (optional): filter to scope union.

  • max_results (default 5, cap 50).

  • expand_top=True: inline the full body of the top hit when it has high relevance or a decisive score lead over the runner-up — saves a memory_show round trip and surfaces the full path_drift + commit_drift detail.

  • auto_scope=True (default): filter to current repo+worktree; memories with no recorded origin always pass as global. Set False for explicit cross-project queries.

  • since_prior_session=False (default): when True, filter to memories whose updated is strictly after the prior session boundary (latest event from a different session_id in the log). The semantic is 'what has changed in the current session, since the last activity by other sessions' — i.e. this session's intra-session diff. A /loop iteration uses this to track what IT has written/updated; for what the prior iteration did, call episode_handoff instead. Returns empty when there's no prior session in the log; distinguish 'nothing new' (results=[]) from 'no baseline' by also calling memory_scope_overview and checking curation_pending_new_since_last_session is None.

  • mode (optional, default from config; package default hybrid): keyword, bm25, or hybrid (RRF fusion of both). Every mode is deterministic lexical ranking, so vocabulary is the lever — see query.

Outcome is recorded automatically via the use_token within ~2 turns; only call memory_record_use to override (ignored / contradicted / corrected).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNo
queryYes
scopesNo
auto_scopeNo
expand_topNo
max_resultsNo
since_prior_sessionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full behavioral disclosure. It reveals automatic outcome recording, mandatory announcement when hits shape replies, deterministic lexical ranking, auto-scope filtering behavior, and detailed branch-on field semantics (relevance tiers, staleness verdicts, drift counts). This is exactly the kind of behavioral transparency an agent needs to anticipate side effects and follow-up actions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is lengthy but every sentence earns its place: no schema repetition, no fluff. It is front-loaded with purpose and usage, then organized into return fields, parameters, and post-call side effects. The structure aids skimming while maintaining density of unique, decision-critical information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 params, 0% schema coverage, no annotations, plus extensive return-field branching), the description is remarkably complete. It covers all parameters, return behavior, side effects, usage edge cases, and sibling alternatives. The output schema already handles return value details, so the description need not duplicate that. No significant gap remains.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate, and it does comprehensively. For every parameter, it adds actionable semantics: query advises using nouns as 'the lever', max_results indicates default 5 and cap 50 (schema says null), auto_scope explains global pass-through, since_prior_session explains the intra-session diff and how to distinguish 'nothing new' from 'no baseline', and mode enumerates options with default behavior. This fully compensates for the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Search stored memories' with a specific verb and resource, and immediately distinguishes this tool from siblings with 'Default: do NOT call — reach for it only when...', positioning memory_search as a fallback for contextual recall rather than a general-purpose search. This contrasts sharply with sibling tools like memory_list and memory_show.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit when-to-use guidance ('reach for it only when the user references shared context you lack'), names alternatives ('call episode_handoff instead' for prior iterations, 'memory_record_use to override' for outcome overrides), and references memory_scope_overview for disambiguating empty results. This is model-level usage guidance that goes far beyond a simple 'when you need to search.'

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/0Mattias/bettermemory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server