problem: cannot operate with message store without any context

This commit is contained in:
Korolev Dmitry
2025-11-18 00:32:13 +01:00
Unverified
parent 0c02824853
commit 6c8b821b2c
4 changed files with 436 additions and 17 deletions
@@ -6,6 +6,7 @@ using AgentWebChat.AgentHost.Custom;
using AgentWebChat.AgentHost.Utilities;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Hosting;
using Microsoft.Agents.AI.Hosting.OpenAI.Conversations;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
@@ -21,6 +22,17 @@ builder.Services.AddProblemDetails();
// Configure the chat model and our agent.
builder.AddKeyedChatClient("chat-model");
var testAgent = builder.AddAIAgent("problemCheck", (sp, name) =>
{
var chatClient = sp.GetRequiredKeyedService<IChatClient>("chat-model");
return new ChatClientAgent(chatClient, options: new()
{
ChatMessageStoreFactory = ctx => new ConversationAgentThreadStore(ctx),
Name = "problemCheck",
Instructions = "You need to state a problem and fix it!"
});
});
var pirateAgentBuilder = builder.AddAIAgent(
"pirate",
instructions: "You are a pirate. Speak like a pirate",