How long-term context is built
Every document you ingest into Synap passes through a multi-stage extraction pipeline that transforms raw text into structured, queryable memories. This pipeline runs asynchronously after ingestion and produces memories that are immediately available for retrieval once processing completes.Document ingestion
You submit a document to Synap via the SDK or API, specifying the
document_type (e.g., ai-chat-conversation, document), scope identifiers (user_id, customer_id), and the raw content.Entity extraction and resolution
The pipeline identifies entities mentioned in the document — people, organizations, projects, products, locations — and resolves them against the entity registry. This ensures that “Alice,” “Alice Chen,” and “A. Chen” all map to the same canonical entity.
Memory extraction
The pipeline extracts structured memories from the document, categorizing each as one of the five memory types: facts, preferences, episodes, emotions, or temporal events. Each memory receives a confidence or strength score and is linked to its source entities and document.
Vector and graph storage
Extracted memories are stored in two complementary engines:
- Vector storage: memories are embedded as vectors (default dimension: 1536) for semantic similarity search
- Graph storage: entity relationships and structured connections are stored for graph-based queries and traversal
The five memory types
Long-term context is organized into five structured types, each capturing a different dimension of knowledge:| Type | Purpose | Example |
|---|---|---|
| Facts | Verifiable statements and knowledge | ”Acme Corp uses PostgreSQL for all services” |
| Preferences | Behavioral choices and tendencies | ”User prefers bullet-point summaries over paragraphs” |
| Episodes | Event narratives and past interactions | ”Discussed the Q2 roadmap in Monday’s standup” |
| Emotions | Detected emotional states and sentiment | ”User was frustrated with the onboarding flow” |
| Temporal Events | Time-anchored information and schedules | ”Board meeting every first Monday of the month” |
Retrieval: from storage to context
When your agent needs long-term context, it sends a retrieval request to Synap. The retrieval engine performs a multi-step process to find and rank the most relevant memories:Search and ranking
- Semantic search: The search query is embedded and compared against stored memory vectors to find semantically similar memories
- Scope filtering: Results are filtered to include only memories from applicable scope levels (user, customer, client, world) based on the provided identifiers
- Type filtering: If the retrieval request specifies memory types (e.g., only facts and preferences), non-matching types are excluded
- Ranking: Remaining candidates are scored using a combination of:
- Relevance: semantic similarity to the query
- Recency: when the memory was created or last accessed
- Confidence: the extraction confidence score of the memory
- Budget enforcement: Results are truncated to fit within the configured token budget
Scoped access
Long-term memories respect scope boundaries. When you retrieve context for a specific user and customer, Synap searches across the full scope chain:Two sub-categories of long-term context
Long-term context is further organized into two sub-categories based on scope:Organizational Context
Knowledge at the CLIENT scope — your product documentation, feature announcements, and domain knowledge. Visible to all users across all customers. Ingested without
user_id or customer_id. Cached with a 30-minute TTL for performance.Customer Context
Knowledge at the CUSTOMER scope — shared within a specific customer organization. Company policies, team structure, shared projects. Ingested with
customer_id but without user_id. Visible to all users in that customer.How long-term memory grows over time
Long-term context is cumulative. Every ingested document adds to the memory store, and memories persist indefinitely (subject to retention policies). Over time, this creates a rich, deep knowledge base for your agent.- Entity resolution improves: more context means better disambiguation and linking
- Retrieval becomes richer: more candidate memories for any given query
- Personalization deepens: the agent develops a more nuanced understanding of each user and customer
- Ranking becomes more important: with more memories to choose from, the relevance/recency/confidence ranking ensures the best memories surface
Long-term memory growth is self-managing. Synap’s retrieval engine scales with memory volume, and the ranking system ensures that only the most relevant memories are returned regardless of how many exist in storage. You do not need to manually prune or curate memories.
Configuration
You can control how long-term context is built and retrieved through the Memory Architecture Configuration:| Setting | Controls | Location in MACA |
|---|---|---|
| Memory types | Which of the five types are extracted | ingestion.categories |
| Extraction hints | Guidance for the extraction pipeline | ingestion.extraction_hints |
| Retrieval mode | How memories are searched (semantic, graph, hybrid) | retrieval.mode |
| Ranking weights | Balance of relevance vs recency vs confidence | retrieval.ranking |
| Token budget | Maximum tokens returned in a context response | retrieval.budget |
| Retention policy | How long memories are kept | storage.retention |
Next steps
Organizational Context
Learn how to ingest and retrieve application-wide knowledge at the Client scope.
Customer Context
Learn how to manage shared knowledge within customer organizations.
Memory Types
Deep dive into the five structured memory types and their extraction behavior.
Memory Scopes
Understand scope boundaries and retrieval priority in detail.