Overview

Methods for assembling context from user knowledge graphs

After adding data to Zep, you need to retrieve relevant context to provide to your agent. Zep offers three methods for assembling context, each with different levels of control over queries and formatting.

Available methods

MethodQuery ControlFormat ControlBest For
Zep’s context blockAutomatic (last 2 messages)FixedMost use cases - optimized relevance and format
Context templatesAutomatic (last 2 messages)CustomConsistent custom formatting across threads
Advanced constructionFull controlFull controlMaximum flexibility with custom queries

Choosing a method

Use Zep’s context block when you want the simplest integration with optimized defaults. This works well for most conversational agents.

Use context templates when you need consistent custom formatting but want Zep to handle relevance detection. This is useful for structured contexts (customer support, sales) where you always want specific sections.

Use advanced construction when you need full control over what context is retrieved and how it’s formatted. This is ideal for complex applications with custom entity types or specialized retrieval logic.