POST /context/ingest with type=memory, and gets it back with POST /query. HydraDB does not capture memories on its own.
Good moments to save one: a user states a preference, makes a decision, finishes a task, or corrects the agent. Saving “this customer already tried restarting” lets a support agent skip that suggestion later.
Product docs, policies, and wiki pages are knowledge, not memories.
In this guide:
- Save a memory: a user preference, start to finish.
- Choose where memories live: the
collectionfield. - Let HydraDB infer the memory: the
inferswitch, with a behavior-log example. - Send text or a conversation: the two input shapes.
- Retrieve memories: on their own, or together with knowledge.
- Update or delete a memory.
- Field reference and common mistakes.
1. Save a memory
This request saves one preference for the userjohn_123. Every memory uses the same request; only the items inside memories change.
The request is multipart/form-data with these fields:
Save a memory: Python, TypeScript, or cURL
Save a memory: Python, TypeScript, or cURL
Set up your SDK client before running the Python or TypeScript example.The response lists each memory in
data.results with its id and a status of queued. The payload is wrapped in the standard envelope, so read it from response.data:What each property in the item means
Status
Ingestion runs in the background: HydraDB parses the input, infers the memory if you asked it to, and indexes the result. CheckGET /context/status with the returned id and the same collection. The memory is searchable once indexing_status reaches graph_creation; completed means the graph work is done too. If you would rather not poll, register a webhook.
2. Choose where memories live
Memories are saved in a collection inside your database. To keep each person’s memories apart, give each person their own collection, such asuser_john_123, and send it on every write, status check, and query. Your backend picks it from the signed-in session; the name itself does not authenticate anyone.
If you leave collection out, the memory lands in the database’s default collection, and a query that names another collection does not read it. See Multi-tenancy.
3. Let HydraDB infer the memory
infer controls how much extraction work your application does before sending data to HydraDB.
Use infer: true when the input is raw signal
With infer: true, you give HydraDB messy or indirect evidence (dialogue, logs, behavior, feedback, or observations), and HydraDB extracts the useful preference, trait, or fact.
Use infer: true for:
- Dialogue where the preference is implicit.
- Behavior logs and event streams.
- Feedback like “the last summary was too long.”
custom_instructions only takes effect when infer: true. Use it to guide extraction, for example: "Focus on UI and notification preferences only".
Use infer: false when the input is already the memory
With infer: false (the default), HydraDB stores and indexes exactly what you send. There is no extraction step.
Use infer: false for:
- Facts you already captured, such as
"User's plan tier is Pro". - Pre-structured notes.
- Text you want to retrieve exactly as written.
infer: false is faster and deterministic. infer: true is better when your input is raw, noisy, or indirect.
Infer a preference from a behavior log: Python, TypeScript, or cURL
Infer a preference from a behavior log: Python, TypeScript, or cURL
A user has been toggling dark mode in your app. Instead of extracting the preference yourself, send the raw behavior log and let HydraDB infer the useful memory.Later, when
POST /query runs with type: "memory" and a query like "what UI settings does the user prefer?", HydraDB can return the inferred preference (for example, "prefers dark mode") rather than the raw event log.If you sent the same input with infer: false, HydraDB would index the event log verbatim. That is useful only when you want to retrieve the log itself.4. Send text or a conversation
Each memory item takes eithertext or user_assistant_pairs, not both (sending both returns 400). Choose the shape that matches the data you already have.
text: prose of any kind, such as observations, captured facts, meeting notes, or semi-structured records. Setis_markdown: truewhen the content uses Markdown (headings, lists, code blocks) so HydraDB keeps that structure during chunking and embedding.user_assistant_pairs: dialogue, especially when the preference is implied rather than stated. Each pair is{ "user": "...", "assistant": "..." }.
Input shapes: text, Markdown, and user-assistant pairs
Input shapes: text, Markdown, and user-assistant pairs
Markdown notes, stored as written:A plain statement, with the preference extracted:A conversation, with the preference extracted:
5. Retrieve memories
Memories live in their own store, separate from knowledge.POST /query reaches each store through the type parameter:
type: "memory"queries the memories store (vectorstore_status.memories).type: "knowledge"queries the knowledge store (vectorstore_status.knowledge).type: "all"runs both in parallel and returns a single merged, re-ranked result set.
collection you used when saving. Both stores are read from that collection, so if shared documents live in their own collection, list it next to the user’s in collections. See Query.
Query a user's memories: Python, TypeScript, or cURL
Query a user's memories: Python, TypeScript, or cURL
data.chunks, ranked by relevance. Pass their text to your model as context. See How to Use API Results to turn the response into a prompt.6. Update or delete a memory
To change a memory, send it again with the sameid and the new text. upsert defaults to true, so the saved memory is replaced. Wait for the previous ingestion to reach completed or errored before sending the next update for the same id.
To remove a memory, call DELETE /context with its id and the same collection.
Field reference
Request fields
Request fields
Memory item fields
Memory item fields
memories is a JSON string. Inside each item, metadata and additional_metadata are plain objects; do not stringify them again.Common mistakes
Related
- Knowledge: shared document context
- Query: how memories are retrieved at query time
- Multi-tenancy: scoping memories per user or workspace
- Metadata: designing filterable fields
