How Zep's Context Assembly Works
Zep automatically assembles relevant user memory and business data into optimized context blocks for your agents. No more guessing what information to include or manually managing prompt templates. Your agents get exactly the right context for each interaction.
Memory Context Blocks
Get ready-to-use context blocks that include user traits, recent interactions, and business relationships. Each context block is optimized for your LLM's context window and formatted for reliable agent performance.
Intelligent Context Assembly
Zep analyzes each user query and automatically retrieves relevant facts, preferences, and business data from your knowledge graphs. Context blocks are pre-formatted for LLM consumption with proper structure and token optimization.
Dynamic Relevance Ranking
Zep surfaces the most important information first. Recent conversations, user preferences, and business data are ranked by relevance to the current query, ensuring your agents focus on what matters most.
FACTS and ENTITIES provide relevant context for the current conversation.
# Key facts with their date ranges
# format: FACT (Date range: from - to)
- Emily Painter cannot log in. (2024-11-14 02:13:19+00:00 - present)
- Account Emily0e62 is suspended due to payment failure. (2024-11-14 02:03:58+00:00 - present)
- Payment failed using card ending in 1234. (2024-09-15 00:00:00+00:00 - present)
- Failure reason: Card expired. (2024-09-15 00:00:00+00:00 - present)
# Key entities and their descriptions
# ENTITY_NAME: entity summary
- Emily0e62: User account owned by Emily Painter, currently suspended due to payment failure and login issues.
- Card expired: Reason for the failed payment transaction.
Custom Context Building
Context Templates
Build custom context templates for specific use cases. Define what information to include, how to format it, and when to apply different templates based on user queries or business scenarios.
Graph Search API
Use Zep's lower-level graph search API to build custom context blocks. Query specific entities, traverse relationships, and assemble context that matches your exact requirements.
Custom Entity and Edge Filtering
Filter context retrieval by your custom entities and edges. Search for specific business relationships, user types, or data categories. Get precise context for specialized agent workflows.
# Custom context with entity filtering
results = client.graph.search(
user_id="user123",
query="billing issues",
scope="nodes",
search_filters={
"node_labels": ["Customer", "Invoice"],
},
limit=10
)
Developer Features

Framework Integration
Works with LangChain, LangGraph, and popular agent frameworks. Drop optimized context directly into your existing agent workflows without changing your architecture.

Token Optimization
Context blocks are optimized for token efficiency. Get comprehensive context while minimizing token usage and staying within your LLM's context window limits.

Real-Time Updates
Context assembly happens in real-time as your knowledge graphs update. No caching delays or stale information that could confuse your agents.
Use Cases
Customer Support Agents
Automatically include customer history, previous issues, product usage, and preferences. Support agents provide personalized assistance without manual research.
Sales Assistants
Surface prospect interactions, product interests, pricing discussions, and competitive context. Sales agents understand the complete customer journey.
Personal AI Assistants
Combine user preferences, communication style, past conversations, and personal data. Assistants provide consistent, personalized experiences.
Knowledge Workers
Include relevant documents, project context, team interactions, and business processes. Agents understand organizational knowledge and workflows.
Performance Benefits
Token Efficiency
Get comprehensive context while using minimal tokens. Zep's intelligent ranking and formatting reduce token waste without losing important information.
Results in Milliseconds
Context assembly happens in milliseconds with P95 response times under 200ms. Your agents get immediate access to relevant information without performance delays.
Accuracy Improvements
Agents perform better with proper context. Reduce hallucinations and improve response quality through systematic context engineering.
Ready to Automate Your Context?
Stop manually crafting prompts. Get optimized context automatically with Zep's intelligent assembly.
LangChain • LangGraph • OpenAI • Anthropic • Any LLM framework