Skip to main content

Memory Integration

This guide shows how to integrate memory into your agents and workflows. Memory lets agents remember information across sessions, accumulate domain knowledge, and personalize responses. Memory is built into the Utils service (em-runtime-utils) — the same service that handles schedules, metadata, and catalog tags. No separate service is required.

Prerequisites

  • A valid JWT token from the platform (user or service account)
  • The JWT must contain an org_id claim for organization scoping
  • An X-Project-ID header for project scoping on all memory requests

Basic Integration Pattern

The most common pattern for an agent:
  1. Before responding, list memories from the relevant Context Pack for context
  2. After responding, extract and store new memories from the conversation

Storing Memories

The following snippets show individual API calls. In an async agent, wrap them in async with httpx.AsyncClient() as client: and use await client.post(...) / await client.get(...) as shown in the integration pattern above.

Basic Memory Creation

Memories are created within a named Context Pack:

Memory Types

Choose the type based on the nature of the information:
TypeWhen to useExample
factFactual knowledge”The orders table has 50M rows”
experienceLearned behaviors”Query optimization worked better with CTEs”
observationObserved patterns”Revenue spikes every Q4”
instructionDirectives / guidelines”Always include date filters for large tables”
preferenceUser/system preferences”Prefers concise output without verbose explanations”
summaryCondensed summaries”Session covered revenue analysis across 3 regions”
glossaryBusiness terms”ARR = Annual Recurring Revenue”
joinTable relationships”Table orders has FK to customers
ontologyDomain classifications”Column status uses enum: active, inactive, churned”
policyGovernance rules”PII columns must not appear in SQL results”
textual_patternText patterns in data”Email column matches a standard email regex pattern”
kpiKPI definitions”Churn Rate = lost customers / total customers x 100”
exemplarRepresentative examples”Typical order: id=1234, amount=49.99, status=completed”
numeric_patternNumeric distributions”Revenue column: mean=1250, median=980, stddev=450”

Named Memories

Use name for memories you want to retrieve directly by name within a pack:

Retrieving Memories

List All Memories in a Context Pack

List All Memories in the Project

Context Packs

For structured memory management, use Context Packs to group related memories by domain:

Updating and Deleting

Update a Memory

Delete a Memory

Pin a Memory

Pinned memories stay in the Active tier and bypass inactivity decay:

Best Practices

Each memory should make sense without knowing the conversation that produced it. Instead of “Yes, that’s right” store “User confirmed that the ‘revenue’ column uses gross revenue, not net.”
Typed memories retrieve more accurately. If you know a memory is a preference, mark it preference, use specific types for better retrieval.
Before creating a new memory, list the pack’s memories and check whether an existing one covers the same information. Update existing memories rather than creating duplicates.
For domain-specific knowledge bases (data dictionaries, business rules, entity relationships), group memories into typed Context Packs. This improves retrieval precision and enables pack-level operations.
Memories are scoped by the org_id claim in the JWT token and the X-Project-ID header. Ensure each agent uses a token scoped to the correct organization and passes the correct project ID to prevent information leakage.

Memory Service

Concepts overview and API reference.

Context Packs

Detailed Context Pack architecture and management.