Reload the AI context from the previous session #5356
Replies: 2 comments
-
|
@westey-m are you able to help, please? |
Beta Was this translation helpful? Give feedback.
-
|
@Sachin-Nand, where you store the context will largely depend on your scenario. You can even store state directly in the session via the session state bag. Just ensure that how/where you store your serialized sessions are able to handle the size of data that you may be adding to the session. If you store the data elsewhere, you would typically also want to associate what you store with the current session so that context doesn't leak across sessions. You can do this by putting the identifier of the data that you stored (e.g. filename, or db key, etc), into the session state bag. Also see the docs for more information: https://learn.microsoft.com/agent-framework/agents/conversations/context-providers?pivots=programming-language-csharp |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I was going through this example : https://github.com/microsoft/agent-framework/blob/main/dotnet/samples/02-agents/Agents/Agent_Step17_AdditionalAIContext/Program.cs
I understand what the code is trying to do. My question is how do I store the AIContext ? I am aware that there is a StoreAIContextAsync method for AIContextProvider.
I am trying to understand the difference between StoreChatHistoryAsync from ChatHistoryProvider and StoreAIContextAsync from AIContextProvider.
In the code that I referenced earlier had the following user chat
Console.WriteLine(await agent.RunAsync("I need to pick up milk from the supermarket.", session) + "\n");
Console.WriteLine(await agent.RunAsync("I need to take Sally for soccer practice.", session) + "\n");
Console.WriteLine(await agent.RunAsync("I need to make a dentist appointment for Jimmy.", session) + "\n");
Console.WriteLine(await agent.RunAsync("I've taken Sally to soccer practice.", session) + "\n");
I then saved the entire conversation to a .json file through ChatHistoryProvider , then loaded it into a new session and prompted the model.
"Did I pick up milk from the supermarket and took Sally to soccer practice ? "
The response was, both the task were complete which is incorrect, as only “taking Sally to soccer practice” was done. The reason both tasks were marked as complete was because the to-do list was empty as it was a new session. The reloaded conversation was ignored.
I am trying to understand if there is a way that the AIContext can be made aware across sessions, the way it is possible through ChatHistoryProvider.
Beta Was this translation helpful? Give feedback.
All reactions