Skip to main content

Overview

Memory Retrieval is how your application reads useful context from Memind. Memind provides two retrieval strategies: Use SIMPLE when memory should feel instant. Use DEEP when memory should be more complete. This page focuses on how to call retrieval APIs, choose a strategy, use the result as agent context, configure retrieval, and debug retrieval behavior. For how retrieval works internally, see Retrieval.

When to retrieve memory

Retrieve memory when the agent needs context that may not be present in the current prompt. Common moments include:
  • before generating an assistant response
  • before planning a task
  • before calling tools
  • when a user asks about past preferences, decisions, or project context
  • when restoring context across sessions
  • when building a prompt for a long-running agent
  • when the agent needs prior tool experience or reusable playbooks
You do not need to retrieve memory for every request. Skip retrieval when the current prompt already contains enough context, or when the query does not depend on previous memory.

Choose a retrieval strategy

Choose the strategy based on latency and retrieval quality requirements. In most applications, start with SIMPLE. Use DEEP selectively for harder questions where missing context is more expensive than waiting longer.

Retrieve with SIMPLE

Use SIMPLE for fast memory recall.
SIMPLE is designed for low-latency agents and chatbots. It can retrieve relevant insights, memory items, and Raw Data captions without using the heavier deep-retrieval path. Use it for:
  • normal chat turns
  • frequent memory injection
  • direct questions
  • preference lookup
  • recent context recall
  • latency-sensitive agent loops

Retrieve with DEEP

Use DEEP for quality-first retrieval.
DEEP is designed for complex or ambiguous queries. It can use sufficiency checking, typed query expansion, graph/thread assist, optional reranking, and evidence-backed output. Use it for:
  • cross-session investigation
  • project-level questions
  • ambiguous user requests
  • tasks that need stronger evidence
  • situations where retrieval quality matters more than latency

Use retrieval results as agent context

The easiest way to use retrieval output in an agent prompt is formattedResult().
The formatted result is designed for LLM context construction. It may include:
Each section serves a different purpose. Use a guard when memory may be empty:
Example prompt assembly:
This gives the agent both evidence and interpretation.

Response format

Retrieval returns a RetrievalResult.
A useful retrieval result usually combines multiple layers:
  • items provide concrete facts
  • insights provide interpretation
  • rawData provides source-level context
  • evidences provide supporting information for complex retrieval

Configure retrieval

For simple use cases, pass a strategy directly:
For more control, build a RetrievalRequest with a custom RetrievalConfig.
Retrieval configuration is organized around three memory tiers. Use RetrievalConfig.simple() for low-latency retrieval configuration.
Use RetrievalConfig.deep() for quality-first retrieval configuration.
Common configuration areas include: Start with the default configuration. Tune only when retrieval traces show a clear need.

Retrieve by scope or category

Use a RetrievalRequest when you want to restrict retrieval scope. For user memory:
For agent memory:
You can also retrieve by memory categories.
Use filters when you know the query should target a specific memory scope or category.

Debug with retrieval traces

Memory retrieval can be difficult to debug. Memind provides retrieval traces so developers can inspect what happened during retrieval. A trace can help answer:
  • which strategy was used
  • what query was executed
  • whether cache was used
  • which retrieval channels ran
  • whether keyword search returned candidates
  • whether temporal retrieval activated
  • whether graph assist changed the result
  • whether memory-thread assist changed the result
  • whether DEEP triggered query expansion
  • whether reranking was applied
  • why a specific item appeared in the final result
Use traces when retrieval feels incomplete, noisy, or surprising. Instead of treating memory as a black box, inspect the retrieval path and tune configuration based on evidence.

Best practices

Start simple:
  • Use SIMPLE as the default strategy.
  • Use DEEP only when the query is complex or quality matters more than latency.
  • Do not use DEEP for every chatbot turn unless latency is acceptable.
Write focused retrieval queries:
  • Ask retrieval for the memory you need, not the whole user prompt.
  • Keep the query short enough to express intent clearly.
  • Preserve useful time expressions such as “last week”, “recently”, or “before the release”.
Use the result as context:
  • Use formattedResult() as the default prompt context format.
  • Include memory only when the result is not empty.
  • Let insights guide behavior, items support facts, and captions provide source context.
Debug before tuning:
  • Inspect retrieval traces before changing top-k or scoring settings.
  • Check whether the missing information was extracted first.
  • Check Raw Data and Memory Items if retrieval cannot find expected context.
Choose the right memory scope:
  • Use user memory for user preferences, facts, and history.
  • Use agent memory for directives, tool experience, playbooks, and resolutions.
  • Use category filters when you know what type of memory the query needs.