On this page
Learning objectives
- Distinguish prompt context, application state, and persistent memory
- Choose what to store, retrieve, summarize, or forget
- Protect memory from stale, poisoned, or cross-user information
Prerequisites
Structured outputs · Basic database concepts
Answer first
Canonical definition
Context is the information provided to a model for the current call, state is the authoritative application record of the task, and memory is selected information persisted for later retrieval.
Operating context
Why it matters
Treating the conversation transcript as the database makes state hard to validate, migrate, or recover.
Useful memory is selective and attributable; storing everything increases privacy, cost, and contamination risk.
Method
Step by step
- 01
Choose the source of truth
Keep task status, permissions, and business records in application state rather than relying on model recollection.
- 02
Assemble context
Retrieve only the instructions, recent events, records, and evidence needed for the next decision.
- 03
Write memory deliberately
Define which observations can persist, their owner, source, confidence, expiry, and deletion rule.
- 04
Test contamination
Check for cross-user leakage, stale preferences, malicious retrieved text, and summary drift.
Hands-on lab
Design a resumable task state
Model an agent job that can pause for approval and resume without replaying or trusting the full chat transcript.
Deliverable
A state schema, context builder, memory policy, expiry rules, and resume tests.
What breaks
Common failure modes
- F1Using summaries as the only authoritative record
- F2Persisting unverified model claims as user facts
- F3Retrieving memory without tenant and permission filters
Beyond the demo
Production notes
- Encrypt sensitive state, scope it to tenant and user, and define retention before launch.
- Version summaries and keep provenance links to the underlying records they compress.
Further reading
Sources
Related Tenten resources