Cortex API
API reference and usage patterns for Teleon Cortex
Cortex is Teleon’s memory system for AI agents.
Role
Cortex provides persistent, searchable memory you can use to store and retrieve information across runs. It is designed to be simple (6 core methods) while supporting production needs like scope enforcement (multi-tenancy), memory layers, and auto-context injection.
When to use
- Add user / customer memory that should persist across agent executions.
- Retrieve context with semantic search (with optional exact-match filters).
- Enforce isolation between tenants using a mandatory
scope(for example,customer_id). - Use auto-save + auto-context injection to reduce boilerplate.
Quick start
Configuration
Simple enable
This enables:
- Auto-save conversations after each execution
- Auto-context injection before execution
- In-memory storage (development mode)
Full configuration
Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
auto | bool | True | Auto-save conversations after execution |
fields | list | None | Fields to capture (None = all args) |
scope | list | [] | Mandatory isolation fields for multi-tenancy |
name | str | agent name | Memory namespace (for sharing) |
layers | dict | {} | Custom memory layers |
auto_context | dict | see below | Auto-context configuration |
API reference
store()
Save content with any fields.
Parameters:
content(str): Text content to storettl(int, optional): Time-to-live in secondsupsert(bool, optional): Update existing entry if fields match**fields: Any additional fields to store
Returns: Entry ID (str)
search()
Semantic search with optional filter.
Parameters:
query(str, optional): Search query for semantic matchingfilter(dict, optional): Field filters (exact match)limit(int): Maximum results (default: 10)
Returns: List of Entry objects with relevance scores
get()
Get entries by filter (faster than search when you don’t need semantic matching).
Parameters:
filter(dict): Field filters (exact match)limit(int): Maximum results (default: 10)
Returns: List of Entry objects ordered by created_at DESC
update()
Update entries matching a filter.
Parameters:
filter(dict): Filter to match entriescontent(str, optional): New content**fields: Fields to update (merged with existing)
Returns: Number of entries updated (int)
delete()
Delete entries matching a filter.
Parameters:
filter(dict): Filter to match entries
Returns: Number of entries deleted (int)
count()
Count entries matching a filter.
Parameters:
filter(dict, optional): Filter to match (counts all if None)
Returns: Number of matching entries (int)
Scope enforcement (multi-tenancy)
Scope ensures data isolation between tenants. When you define scope fields, they are automatically enforced on all operations.
How it works:
- Scope fields are extracted from function arguments
- Every
store()automatically includes scope values - Every
search(),get(),update(),delete(), andcount()is 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 automatically retrieves relevant context before agent execution and makes it available via cortex.context.
Context properties:
Storage backends
Development (default)
In-memory storage for development and testing.
PostgreSQL with pgvector
Requirements:
- PostgreSQL with pgvector extension
pip install asyncpg
Redis with RediSearch
Requirements:
- Redis Stack (includes RediSearch)
pip install redis[asyncio]
Examples
Customer support agent
Sales agent with lead scoring
Next
- Guide:
/docs/guides/cortex-memory - Tutorial:
/docs/tutorials/customer-support-agent