Cortex Memory
Patterns for multi-tenant memory, layers, auto-context, and storage backends
Cortex is Teleon’s memory system for AI agents. It provides persistent, searchable memory for your agent runs.
For the full method-level API (all parameters, return types, and examples), see Cortex API in API Reference.
What this guide covers
- How to enable Cortex on an agent
- How scope enforcement provides multi-tenant isolation
- How to use layers for hierarchical memory (company/team/personal)
- How auto-context injection works via
cortex.context - How to configure storage backends for persistence
Enable Cortex
Scope enforcement (multi-tenancy)
Scope ensures data isolation between tenants. When you define scope fields, they are automatically enforced on all operations.
How scope works
When scope fields are configured:
- Scope values are extracted from function arguments
- Every
store()automatically includes the scope fields - Every
search(),get(),update(),delete(), andcount()is automatically filtered by scope - Users cannot override scope values
Memory layers
Layers provide hierarchical memory organization. Each layer has its own scope.
Auto-context injection
Cortex can automatically retrieve relevant context before agent execution and make it available via cortex.context.
Context properties
Storage backends
By default, Cortex uses in-memory storage for development/testing. For persistence, configure a backend.
PostgreSQL with pgvector
Redis with RediSearch
Best practices
- Use scope for multi-tenancy.
- Keep content concise.
- Use meaningful fields (
type,topic,status) for filtering. - Set TTL for temporary data.
- Use layers for hierarchy.
- Enable auto-context when appropriate.
Troubleshooting
Memory not persisting
By default, Cortex uses in-memory storage. For persistence, configure PostgreSQL or Redis backend.
Scope field not found
Ensure scope fields are in function arguments:
Empty search results
- Check scope values match stored data
- Verify filter fields exist in stored entries
- Try a broader query or remove filters