.NET ChatHistoryProvider vs Session #4443
Unanswered
ahmar-husain
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have some confusion regarding ChatHistoryProvider and AgentSession, specifically in the context of resuming an ongoing conversation.
From what I understand:
If I don’t use sessions and only use a persistent ChatHistoryProvider, the agent should still be able to resume the conversation because the full chat history can be retrieved from the provider.
On the other hand, if I don’t use a persistent chat history provider (instead an InMemory one) ,serialize and store the AgentSession, then later deserialize it and resume the same session, the agent will also have the full conversation context.
So both approaches seem to allow resuming a conversation.However, I’m trying to understand which approach is recommended or intended.
One concern I noticed is that persisting sessions alone can cause the session object to grow significantly, since it contains the entire chat history, and currently there doesn’t seem to be a built-in way to reduce or trim the history within the session. With a ChatHistoryProvider, however, we can apply a history reducer, which helps control the size of the stored history.
Right now I’m using a hybrid approach:
What I noticed is that when the history reducer runs, it reduces the stored history, and when the session is serialized again afterward, the session history also appears reduced. So there seems to be some connection between the session state and the chat history provider.
I’m trying to better understand:
What is the recommended pattern for long-running conversations? Should we rely primarily on sessions, chat history providers, or a combination of both? Any guidance would be appreciated.
Custom history Provider
Beta Was this translation helpful? Give feedback.
All reactions