.NET: [Bug]: Replying in a CopilotKit webchat with reasoning results in "System.InvalidOperationException: Unknown chat role: reasoning"
@javiercn is already working on this.
Since Sep 17, 2026.
Assessment
This issue has not been assessed yet.
Description
Description
Setup:
- Set up Harness Agent with reasoning
- CopilotKit as webchat
Reproduction:
- User sends first message --> Agent responds with reasoning and output
- User sends followup message --> 500 status code from agent service
Code Sample
Program.cs
#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
// The Responses API variant is needed for the Reasoning field to work without a 400 Bad Request from the LLM.
builder.Services.AddKeyedSingleton<IChatClient>("responses-chatclient", (sp, _) =>
{
var projectClient = new AIProjectClient(foundryUri, new DefaultAzureCredential());
var openAIClient = projectClient.GetProjectOpenAIClient();
return openAIClient.GetResponsesClient().AsIChatClient(azureOpenAIDeploymentName);
});
#pragma warning restore OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
Agent:
return chatClient.AsHarnessAgent(new HarnessAgentOptions
{
// FileAccessStore is left unset, which disables file access; leaving DisableFileMemory/DisableTodoProvider/
// DisableAgentModeProvider false keeps their defaults, including writing to ./agent-file-memory on disk.
Name = name,
HarnessInstructions = Instructions,
ChatOptions = new ChatOptions { Tools = tools, Reasoning = new() { Effort = ReasoningEffort.Medium, Output = ReasoningOutput.Summary} },
AIContextProviders = contextProviders,
DisableWebSearch = true,
OpenTelemetrySourceName = GenAiSourceNames.Agents,
});
Error Messages / Stack Traces
HTTP 500: System.InvalidOperationException: Unknown chat role: reasoning
at AGUI.Abstractions.AGUIChatMessageExtensions.MapChatRole(String role)
at AGUI.Abstractions.AGUIChatMessageExtensions.AsChatMessages(IEnumerable`1 aguiMessages)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at AGUI.Server.RunAgentInputExtensions.ToChatRequestContext(RunAgentInput input, JsonSerializerOptions jsonSerializerOptions, AGUIStreamOptions streamOptions)
at Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.AGUIEndpointRouteBuilderExtensions.<>c__DisplayClass2_0.<<MapAGUIServer>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Http.Generated.<GeneratedRouteBuilderExtensions_g>FB87DEE35F409427C0993BF3A8E11207C78AB7E4167B350548AEB87B222E3F58E__GeneratedRouteBuilderExtensionsCore.<>c__DisplayClass2_0.<<MapPost0>g__RequestHandler|5>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Package Versions
Microsoft.Agents.AI.Hosting.AGUI.AspNetCore: 1.21.0-preview.260911.1
Microsoft.Agents.AI.Harness: 1.21.0
@copilotkit/react-core: ^1.71.1
.NET Version
.NET 10
Additional Context
No response
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 342
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/agent-framework
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/agent-framework#8523 · 1 comment ·
-
.NET compaction documentation
Difficulty 1/5 Under an hour Newbie friendliness 82/100
microsoft/agent-framework#4629 · 1 comment ·
-
harness python reproduced
microsoft/agent-framework#8567 · 2 comments · 1 assignee ·
-
.NET agents reproduced
microsoft/agent-framework#8566 · 1 comment · 1 assignee ·
-
.NET agents python
microsoft/agent-framework#8562 · 1 assignee ·
All issues in microsoft/agent-framework
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100