Skip to main content

1. What it is

Memories are user-scoped context HydraDB stores so your application can personalize responses over time. A memory is a unit of user-specific context HydraDB stores on behalf of an agent - a preference, a past conversation, an inferred trait, or a raw fact. Memories let an agent adapt its responses to a specific user across sessions, and surface again through Recall when relevant. Think of memories as persistent user-specific context. That’s distinct from Knowledge, which is shared, tenant-wide context ingested from documents and apps.

2. What it does

When you add a memory, HydraDB:
  1. Parses the input (text, markdown, or user–assistant pairs).
  2. Optionally runs inference (infer: true) to extract preferences and insights.
  3. Processes and indexes it for future retrieval.
  4. Makes it available to recall_preferences.
The infer flag controls how much structure HydraDB extracts on your behalf - see How infer works.

3. When to use it

Use memories when responses need to adapt to a specific user over time:
  • Capture stated or implied preferences (“prefers concise answers”).
  • Store past conversations the agent should reference later.
  • Record decisions, outcomes, or feedback tied to a user.
  • Build up a behavioral profile that compounds across sessions.
Use Knowledge ingestion instead when the content is shared across users - product docs, policy PDFs, internal wikis, Slack threads.

4. Types of memories

A memory item should typically provide either text or user_assistant_pairs, not both.

Raw text

Markdown

User–assistant pairs

Best for capturing implicit signals from dialogue.

5. How it works

infer: extract preferences for me, or store what I give you

The infer flag is the most important decision when writing a memory. It controls how much work your application has to do before sending content to HydraDB. infer: true - HydraDB extracts the preference for you. You hand HydraDB raw signal - interaction logs, dialogue, behavior, observations - and HydraDB infers the underlying preference, trait, or fact. Concretely: ship the events that imply a preference, and HydraDB derives the preference. For example, dump a stream of UI interaction logs showing that a user switched to dark mode on Day 1, kept it on for a month, and toggled it back to light once before reverting. HydraDB infers "user prefers dark mode" and indexes that. Your application never has to write the extraction logic. This is the right mode for:
  • Dialogue (user_assistant_pairs) where the preference is implicit
  • Behavior logs and event streams
  • Feedback (“the last summary was too long”) where the actionable trait isn’t spelled out
  • Anything where the raw input is messy and the useful trait has to be derived
custom_instructions only takes effect when infer: true. Use it to guide what gets extracted (e.g., "Focus on UI and notification preferences only"). infer: false (default) - HydraDB stores what you give it. You’ve already done the extraction. The text you send is the memory, verbatim. HydraDB stores and indexes it as-is. No inference, no derivation. This is the right mode for:
  • Facts you’ve already captured ("User's plan tier is Pro")
  • Pre-structured notes
  • Anything you want to retrieve exactly as written
The trade-off: infer: false is faster and deterministic; infer: true is more useful when your input is raw and unstructured.

Storage and scoping

Memories live in a separate vector store from Knowledge:
  • recall_preferences searches Memories (vectorstore_status index 0).
  • full_recall searches Knowledge (vectorstore_status index 1).

For personalized responses grounded in shared context, call recall_preferences and full_recall in parallel and merge the results before prompting your LLM.

Within a tenant, memories are scoped by sub_tenant_id. For per-user separation (B2C), use the user’s ID as the sub_tenant_id. For shared memory across a workspace, use a stable workspace-level ID. If you omit sub_tenant_id, the memory is written to the tenant’s default sub-tenant. See Multi-tenant support. Ingestion is asynchronous - memories aren’t immediately searchable. Poll /ingestion/verify_processing with the returned source_id until indexing_status is completed.

6. Key parameters

Top-level request body

Memory item fields


N. Forceful relations

Forceful relations let you explicitly link Memory items to each other at ingestion time. When a query matches a memory that has forceful relations declared, HydraDB pulls the linked memories into additional_context alongside the primary results. This is separate from the entity and relationship graph HydraDB builds automatically during ingestion. Graph extraction is derived from content; forceful relations are declared by you. Set the relations field on any item in the memories array:
At recall, linked memories are returned in the additional_context field. Set search_forceful_relations: true (the default) on the request to include them.
Memory items only. Forceful relations work within the same store. Pointing a Memory item at a Knowledge source ID (or vice versa) will silently return nothing at recall time.
thinking mode only. Forceful-relation context is fetched only when mode: "thinking" is set on the recall request. In fast mode, search_forceful_relations is ignored even if set to true.

8. Minimal working example

Store a user preference scoped to a specific user.
You’ll get back a source_id for each memory and an initial status of queued:
Poll /ingestion/verify_processing with the returned source_id until indexing_status is completed. After that the memory will surface in recall_preferences.

9. Inference in practice

A realistic example. The user has been toggling dark mode in your app. Instead of extracting the preference yourself, ship the raw log:
When recall_preferences runs with a query like "what UI settings does the user prefer?", HydraDB returns the inferred preference ("prefers dark mode"), not the raw log. Your application never had to write the extraction logic. The same input with infer: false would index the raw text verbatim - useful only if you actually want to retrieve the event log itself.

10. Common mistakes