What a context entry is
A context entry is a labeled, typed piece of structured data formatted into the AI agent’s system prompt. Unlike traits (simple key-value), context entries can hold complex structures: arrays of objects, nested objects, or any JSON value.Context types
Thetype field tells the AI formatter how to render the data and gives the AI semantic understanding of what it represents.
list
Arrays of items — events, products, features, or any collection.label/name/title as the primary descriptor and shows status separately.
integration
External service connections and their states. Errors are highlighted.error
Active issues or errors the AI should acknowledge and help with.status
General status indicators about the user or account.config
Configuration or settings state.feature
Feature flags or enabled capabilities.metric
Numeric KPIs or measurements.relationship
Entity relationships and cross-references.custom
Use"custom" (or omit the type entirely) for anything that doesn’t fit the other categories. The formatter auto-detects the best rendering based on the value type.
No type? No problem
If you omittype, the formatter auto-detects from the value:
- Array — rendered as a bulleted list
- Object — rendered as key-value pairs
- String/number/boolean — rendered as a simple value
Best practices
Use descriptive labels
Use descriptive labels
Labels appear as section headers in the AI prompt. Make them clear and specific:
- Good:
"Active Tracking Events","Connected Integrations" - Bad:
"Events","Data","Stuff"
Include both IDs and labels for list items
Include both IDs and labels for list items
For lists, include both the machine ID (
event_name) and the human label (label). This lets the AI reference items naturally.Use error type for things the AI should proactively acknowledge
Use error type for things the AI should proactively acknowledge
When a user asks for help and they have active errors, the AI references them automatically.
Keep context entries focused
Keep context entries focused
Prefer multiple focused entries over one giant blob. Each entry should represent one concept (events, integrations, errors, etc.).
Update context dynamically
Update context dynamically
Call
setContext() whenever the user’s state changes — connecting an integration, encountering an error, changing a setting. The AI always sees the latest data.Where to go next
Examples
Full real-world examples for common SaaS patterns.
Context Planning
A step-by-step guide to deciding what to send and how to keep it fresh.