Skip to navigation

Agent memory

Build a durable memory layer similar to Mem0 without putting every conversation turn into the prompt. Talqora stores compact memories as independently addressable vectors and retrieves only the facts relevant to the current turn.

Memory lifecycle

  1. Extract: turn a conversation into a concise fact such as “The user prefers weekly CSV reports.”
  2. Store: embed the fact and write it with tenant, user, category, and retention metadata.
  3. Recall: query with the new message and filter to the current user or workspace.
  4. Use: place only the best matching memories in the model context.
  5. Correct or forget: delete the individual memory and write its replacement when needed.
import uuid
from talqora import TalqoraApi, VectorItem
client = TalqoraApi(talqora_api_key="tq_live_...")
memory = "The user prefers weekly CSV reports."
memory_vector = embed(memory) # Use the same embedding model as the index.
client.vectors.upsert(
INDEX_ID,
idempotency_key=f"memory-{uuid.uuid4()}",
vectors=[
VectorItem(
id="memory_user_42_reports",
values=memory_vector,
sparse_text=memory,
metadata={
"user_id": "user_42",
"kind": "preference",
"status": "active",
},
)
],
)
recalled = client.vectors.query(
INDEX_ID,
search_type="hybrid",
vector=embed("How should I deliver the report?"),
sparse_query="report delivery preference",
filter={"user_id": "user_42", "status": "active"},
top_k=5,
)

Use cosine search for paraphrased preferences and decisions. Hybrid search is stronger when memories contain names, SKUs, ticket IDs, dates, or other exact identifiers.

Isolation and retention

  • Always filter recall by organization_id, workspace_id, or user_id as appropriate.
  • Keep memories short and independently addressable instead of storing entire transcripts.
  • Put expiry, consent, and status fields in metadata so retention rules remain explicit.
  • Use deterministic IDs or idempotency keys to avoid duplicating the same extracted fact.
  • A correction should delete or tombstone the old memory before inserting the replacement.

Talqora enforces index-level API-key scopes server-side; metadata filters add application-level isolation but do not replace scoped credentials.