.NET: [BREAKING] Provide agent and session to AIContextProvider & ChatHistoryProvider (#3695)

* Add a StateBag to AgentSession and pass Agent and AgentSession to AIContextProvider and ChatHistoryProviders

* Remove statebag code from this branch, to get the refactoring out of the way first

* Apply suggestion from @rogerbarreto

Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>

* Apply suggestion from @westey-m

* Apply suggestion from @westey-m

---------

Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
This commit is contained in:
westey
2026-02-05 15:58:41 +00:00
committed by GitHub
co-authored by Roger Barreto
parent 2b66ca03b2
commit ec82ed15d2
26 changed files with 489 additions and 173 deletions
@@ -55,14 +55,14 @@ namespace SampleApp
}
// Get existing messages from the store
var invokingContext = new ChatHistoryProvider.InvokingContext(messages);
var invokingContext = new ChatHistoryProvider.InvokingContext(this, session, messages);
var storeMessages = await typedSession.ChatHistoryProvider.InvokingAsync(invokingContext, cancellationToken);
// Clone the input messages and turn them into response messages with upper case text.
List<ChatMessage> responseMessages = CloneAndToUpperCase(messages, this.Name).ToList();
// Notify the session of the input and output messages.
var invokedContext = new ChatHistoryProvider.InvokedContext(messages, storeMessages)
var invokedContext = new ChatHistoryProvider.InvokedContext(this, session, messages, storeMessages)
{
ResponseMessages = responseMessages
};
@@ -87,14 +87,14 @@ namespace SampleApp
}
// Get existing messages from the store
var invokingContext = new ChatHistoryProvider.InvokingContext(messages);
var invokingContext = new ChatHistoryProvider.InvokingContext(this, session, messages);
var storeMessages = await typedSession.ChatHistoryProvider.InvokingAsync(invokingContext, cancellationToken);
// Clone the input messages and turn them into response messages with upper case text.
List<ChatMessage> responseMessages = CloneAndToUpperCase(messages, this.Name).ToList();
// Notify the session of the input and output messages.
var invokedContext = new ChatHistoryProvider.InvokedContext(messages, storeMessages)
var invokedContext = new ChatHistoryProvider.InvokedContext(this, session, messages, storeMessages)
{
ResponseMessages = responseMessages
};