So far, the quote agent forgets everything as soon as a session ends. Most of the time, that's right. But some things a person would rather say only once: "Always write a payment term of 14 days in my quotes." In this lesson, the agent gets a memory for such preferences. And because everything it remembers about a person is data about that person, the opposite belongs to the memory from the start: deleting.
What this lesson says about the GDPR is teaching material in outline and not legal advice. Which legal basis and which retention periods apply to your application, you settle with your company's data protection officer.
Three ways to remember
An agent in Agent Framework can remember in three ways. They differ in how long something stays and who sees it:
| Kind | Where | How long | Example in the Kladde |
|---|---|---|---|
| The session's history | a ChatHistoryProvider; without an explicit setting, the InMemoryChatHistoryProvider in the session's state |
as long as the session | the two questions from lesson 1 |
| The session's state | the StateBag of the AgentSession |
as long as the session | the open approval from lesson 3 |
| Long-term memory | an AIContextProvider with a store of its own, such as ChatHistoryMemoryProvider |
until it is deleted | "always a 14-day payment term" |
On every run of a ChatClientAgent, the parts work together like this:
- The
ChatHistoryProvidersupplies the session's history so far. - Every
AIContextProvidermay add context: instructions, messages or tools. - The model answers, possibly in several rounds with tools.
- The
ChatHistoryProviderappends question and answer to the history. - Every
AIContextProvidergets question and answer and may remember something of it.
You already know the first two kinds: SerializeSessionAsync from lesson 3 writes history and state into a JSON. New in this lesson are
two things: a history that doesn't grow endlessly, and a memory that outlasts a session.