Skip to main content
Glama
0Mattias
by 0Mattias

memory_search

Search stored memories to recover missing shared context or disambiguate requests, returning ranked hits with snippets.

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) + matched_leg (lexical/semantic/both) — relevance is how much of your query wording the hit literally contains, not how good it is; on a semantic leg it is low by construction, so read them together.

  • 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, semantic (needs an embeddings extra), or hybrid (RRF of all three; picks the extra up automatically). With no extra installed every mode is lexical, so 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?

No annotations exist, so the description carries full burden and fulfills it: it discloses auto-scoping, expand_top behavior, since_prior_session semantics, outcome auto-recording, and detailed result-field semantics. It also explains how to interpret relevance on semantic legs and what to do when staleness_verdict is not fresh. This is exceptional behavioral disclosure.

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

Conciseness4/5

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

The description is long but structured with clear sections and front-loaded with purpose/usage. The length is justified by the tool's complexity (7 parameters, nuanced output fields, cross-tool interactions); no filler sentences are present. It could be seen as dense, but every block carries necessary guidance.

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?

With output schema present, it still explains return-field semantics (relevance, path_drift, commit_drift, etc.) and edge cases like empty vs no baseline. It also provides sibling tool context, making the tool's role in a workflow complete. Highly complete for a complex search tool.

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%, and the description compensates fully: every parameter gets an explanation beyond type/default, e.g. query should use nouns, max_results default/cap, auto_scope behavior, since_prior_session diff semantics, mode options and fallback. This goes well beyond the input 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 opening phrase 'Search stored memories' gives a specific verb and resource. It distinguishes itself from siblings by stating when not to call and referencing alternatives like episode_handoff and memory_show, so purpose is unambiguous.

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 explicitly says 'Default: do NOT call' and gives exact conditions for use (user references shared context, ambiguous request). It names alternatives such as episode_handoff and memory_scope_overview for different cases, and memory_record_use for overriding. This is comprehensive.

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