Skip to main content
Glama

memory_search

Search stored memories to retrieve ranked context and snippets when a request references shared context or is ambiguous. Returns hits with staleness and drift signals.

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.

  • client / model: writer's DECLARED actor, exact; undeclared matches neither.

  • 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
modelNo
queryYes
clientNo
scopesNo
auto_scopeNo
expand_topNo
max_resultsNo
since_prior_sessionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv7.15.0
    • addedInput schema / properties / client
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
    • addedInput schema / properties / model
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  2. First observedv3.34.0

TDQS

A4.9/5.0
Behavior5/5

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

No annotations are provided, so the description carries the full burden and meets it: it discloses the mandatory announcement obligation, automatic outcome recording via use_token, the exact semantics of since_prior_session vs episode_handoff, the empty-results vs no-baseline distinction, and the cap semantics (max 3 depends_on per hit / 10 per call). This is rich behavioral context well beyond a typical schema.

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?

Front-loads the decisive routing rule ('Default: do NOT call') before any field documentation, then organizes return-field semantics as a bulleted list. It is long, but the length is justified by 9 undocumented parameters and 8 output fields. Minor deduction for density — some clauses (annotated can't call it 'padding' but the depends_on cap parenthetical is hard to parse) could be tightened.

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?

Despite an output schema existing, the description goes further and explains how to branch on each returned field (relevance vs quality, staleness_verdict rollup, path_drift_missing vs claim_anchored_missing escalation, commit_drift_count meaning). Combined with parameter semantics and cross-tool routing, nothing an agent needs to call and interpret this tool is missing.

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 description coverage is 0%, so the description must compensate entirely — and it does, defining every one of the 9 parameters with non-obvious semantics: query vocabulary guidance, client/model exact-match on declared actor, auto_scope default behavior and the global fallback, expand_top trigger conditions, since_prior_session's strict-after-baseline semantic, and mode defaulting. This is exceptional coverage for an unannotated 9-parameter tool.

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?

States a specific verb+resource (search stored memories) and distinguishes itself from siblings by naming memory_show, episode_handoff, memory_scope_overview, and memory_record_use as alternatives for related tasks. An agent can route between memory_search and its siblings from the description alone.

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?

Explicitly states when NOT to call ('Default: do NOT call'), the trigger conditions ('shared context you lack', 'ambiguous in a way stored preferences could resolve'), and names alternatives for adjacent needs (episode_handoff for prior-iteration activity, memory_scope_overview for baseline distinction). This is about as prescriptive as guidance gets.

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