Agents That Always Remember What Matters
Zep is a context engineering platform for AI agents built on a temporal knowledge graph that captures evolving user interactions and business data. On every chat turn, Zep retrieves the most relevant information to the current user message from that user's knowledge graph, enabling agents to respond in a more personalized and reliable way.
Although retrieving context based on relevance to the current user message works great in many circumstances, there are many use cases where you want to specify certain information that is retrieved in context every single time. For example, a real estate sales agent needs to remember a buyer's budget on every interaction—not just when it's semantically relevant to what they're currently saying. This is where User Summary Instructions come in.
Video walk-through of Zep's user summary instructions
Defining What Always Matters
User Summary Instructions let you define questions or directives that your agent should always have answers to. For a real estate sales agent, you might define:
- "What is the user's budget or price range for purchasing a home?"
- "How many bedrooms does the user need and why?"
- "What are the user's must-have features in a home?"
- "What locations or school districts is the user prioritizing?"
These instructions customize how the user node summary is generated and updated in the knowledge graph. As new chat history arrives—conversations, search queries, user interactions—Zep continuously refines the summary to answer these specific questions.
How It Works in Practice
Example: Real Estate Agent Memory
Let's walk through a real example. First, you configure User Summary Instructions:
zep_client.user.add_user_summary_instructions(
instructions=[
UserInstruction(
name="bedroom_requirements",
text="How many bedrooms does the user need and why?"
),
UserInstruction(
name="price_range",
text="What is the user's budget or price range for purchasing a home?"
),
# Add more instructions as needed for your use case
]
)
Then you populate the user's knowledge graph with:
- Previous conversations with the real estate agent
- Search queries and filters for home listings
- Structured preference data (budget, bedroom count, location priorities)
As Zep processes this data, the generated user summary might include details like these:
The user requires 3-4 bedrooms for their growing family. Their budget is set between $300,000 and $410,000. They prioritize homes near top-rated schools, with a preference for the Riverside school district. Must-have features include home office space for remote work, a 2-car garage, and an updated kitchen. They prefer move-in ready homes with hardwood floors and central AC.
As new conversations and data come in, this summary automatically updates to reflect changes. If the user mentions their budget has increased or they now need five bedrooms instead of four, Zep reconciles these updates and adjusts the summary accordingly—ensuring the agent always works with current information, not stale preferences.
Now when the user sends their next message—even something minimal like "Actually, we want our house in Palo Alto"—the agent receives this custom user summary alongside the standard semantic search results from Zep.
This means the agent can respond with full context:
"Great! I'll focus on Palo Alto properties. Based on your preferences, I'll look for 3-4 bedroom homes in your $300K-$410K range, prioritizing those near top-rated schools with home office space and updated kitchens. The Palo Alto school district has excellent ratings, which aligns perfectly with your priorities."
The agent isn't guessing or asking repetitive questions. It remembers what matters.
Where This Makes the Biggest Difference
User Summary Instructions shine in three critical scenarios:
1. Conversation Starts
When threads begin with greetings or minimal context, there's little for semantic search to work with. The custom user summary ensures the agent starts every conversation informed, not blank-slate.
2. Topic Shifts
Users don't always stay on-script. A real estate conversation might drift to financing, then back to home features. The summary keeps core preferences accessible regardless of conversational flow.
3. Multi-Turn Interactions
As conversations span days or weeks, the customized user summary acts as a persistent memory anchor. The agent doesn't need to re-learn preferences—they're embedded in the retrieved context from turn one.
Implementation Simplicity
The code implementation is straightforward. When retrieving context from Zep:
# Retrieve user context (including the customized user summary)
results = await zep_client.thread.get_user_context(
thread_id=thread_id,
mode="basic"
)
context_block = results.context
# Include in your system prompt
system_prompt = (
"You are a helpful real estate sales agent. "
"Use the context provided to personalize your recommendations.\n\n"
f"{context_block}"
)
The get_user_context() method automatically includes the user summary in the returned context. You define the User Summary Instructions once in your Zep project settings, and they shape how the user node summary is generated and updated across all user interactions.
Try It Yourself
We've built a complete example application that demonstrates User Summary Instructions in action. The real estate agent chatbot includes:
- Pre-populated knowledge graphs with realistic user data
- Side-by-side comparison of responses with and without Zep memory
- Latency tracking for both Zep retrieval and LLM response times
- Multi-user and multi-thread support
Get started with the example yourself:
git clone https://github.com/getzep/zep.git
cd zep/examples/python/user-summary-instructions-example
From there, install dependencies, configure your API keys in a .env file, run the ingestion script to populate sample data, and launch the interactive dashboard. See how User Summary Instructions transform agent memory in minutes.
What's Next
User Summary Instructions are one piece of Zep's broader context engineering platform. For more advanced scenarios, you can:
- Customize context blocks using lower-level graph search for fine-grained control
- Combine conversational memory with structured business data (CRM records, transaction history)
- Define custom entity types to ensure consistent recognition of domain-specific concepts
The goal remains the same: give your agents the context they need, when they need it, without manual prompt engineering or fragile retrieval heuristics.
Start with what matters most to your users. Define those facts as User Summary Instructions. Watch your agents become meaningfully more helpful.
Resources: