Control what each run remembers.
1. Session identity
Associate session IDs with authenticated ownership. An in-memory development session is not durable storage and should not be mistaken for production persistence.
2. Conversation versus facts
Chat history records what was said; trusted application facts come from authorized services. A prior model statement does not become reliable simply because it is in memory.
3. Context trimming
Bound history and preserve the facts necessary for the task. Summaries can lose detail or introduce errors, so record the source of important state outside generated prose.
Worked scenario
A customer changes their shipping address in the application. An old chat message must not override the current trusted record.
Apply it
Run two users with similar questions and verify no session state crosses between them.
Check your understanding
You can clear or replace session memory without losing authoritative business data. Explain the decision and show evidence from your implementation or design. If you cannot demonstrate it yet, revisit the relevant section before continuing.