.NET: [Bug]: AddAGUIServer's JSON setup writes null optional fields (rejected by @ag-ui/client) and cannot serialize interrupts
维护者通常 1 天内回复
@javiercn 已经在做这个了。
开始于 2026年10月2日。
评估
这个 Issue 还没有评估数据。
描述
Description
MapAGUIServer writes a stream that the official AG-UI TypeScript client (@ag-ui/client 1.0.1, used by CopilotKit 1.76) rejects. Separately, any interrupt makes the run end in RUN_ERROR. Both defects come from ConfigureAGUIJsonOptions in Microsoft.Agents.AI.Hosting.AGUI.AspNetCore, which AddAGUIServer() registers:
// Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.ConfigureAGUIJsonOptions (1.23.0-preview.260928.1, decompiled)
public void Configure(JsonOptions options)
{
var chain = options.SerializerOptions.TypeInfoResolverChain;
chain.Add(AgentAbstractionsJsonUtilities.DefaultOptions.TypeInfoResolver);
chain.Add(((JsonSerializerContext)AGUIJsonSerializerContext.Default).Options.TypeInfoResolver);
}
1. Optional event fields are written as null, and the official client rejects them.
- Cause: the method appends the raw
AGUIJsonSerializerContextresolver.AGUI.AbstractionsdocumentsAGUIJsonUtilities.DefaultTypeInfoResolver(that context plusOmitPropertiesWithoutAValue) as the resolver to use instead. - What happens:
RUN_STARTEDgoes out with"parentRunId": nulland"input": null, and interrupts carry"subagentRunId": null.@ag-ui/client's schema validation fails on the first event, so no run can be followed from a browser. - Expected: optional fields without a value are omitted, as
AGUIJsonUtilities.DefaultTypeInfoResolverdoes.
2. Interrupts cannot be serialized.
- Cause: the method never calls
AGUIJsonUtilities.RegisterInterruptContentTypes. - What happens: an agent that yields
InterruptRequestContentmakes the server fail the run. The same happens when the response update containing one is serialized, for example forrawEvent. The client receivesRUN_ERROR("An error occurred while streaming the agent response.") instead of aRUN_FINISHEDwhose outcome is an interrupt. - Expected:
AddAGUIServer()registers the interrupt content types, so the protocol's own interrupt/resume works out of the box.
Steps to reproduce
- Use
builder.Services.AddAGUIServer();andapp.MapAGUIServer("/agui", agent);with anyChatClientAgent. - POST a run and read the stream with
@ag-ui/client'sHttpAgent. You get a ZodError onRUN_STARTED(defect 1). - Have the agent's chat client yield
new ChatResponseUpdate(ChatRole.Assistant, [new InterruptRequestContent("ask-1") { Reason = "input_required", Message = "?" }]). The run ends inRUN_ERROR(defect 2).
Code Sample
```csharp
// Workaround we use today; with it, both cases work end to end with @ag-ui/client and CopilotKit.
builder.Services.AddAGUIServer();
builder.Services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(o =>
AGUIJsonUtilities.RegisterInterruptContentTypes(o.SerializerOptions));
builder.Services.PostConfigure<Microsoft.AspNetCore.Http.Json.JsonOptions>(o =>
o.SerializerOptions.TypeInfoResolverChain.Insert(0, AGUIJsonUtilities.DefaultTypeInfoResolver));
```
Error Messages / Stack Traces
```
// 1 — @ag-ui/client 1.0.1 on RUN_STARTED:
ZodError: parentRunId: expected string, received null; input: expected object, received null
// 2 — server, when an InterruptRequestContent is serialized:
System.NotSupportedException: Runtime type 'AGUI.Abstractions.InterruptRequestContent' is not supported by polymorphic type 'Microsoft.Extensions.AI.AIContent'.
```
Package Versions
Microsoft.Agents.AI.Hosting.AGUI.AspNetCore: 1.23.0-preview.260928.1, Microsoft.Agents.AI: 1.23.0, Microsoft.Agents.AI.Hosting: 1.23.0-preview.260928.1, AGUI.Abstractions: 1.0.0, AGUI.Server: 1.0.0, Microsoft.Extensions.AI.Abstractions: 10.10.1
.NET Version
.NET 10 (SDK 10.0.401)
Additional Context
- Version scope: 1.22.0-preview.260918.1 has the same
ConfigureAGUIJsonOptions, and it also targetsAGUI.*0.0.6. - Suggested fix: in
ConfigureAGUIJsonOptions.Configure, insertAGUIJsonUtilities.DefaultTypeInfoResolver(rather than adding the raw context) and callAGUIJsonUtilities.RegisterInterruptContentTypes(options.SerializerOptions).
- 主要语言
- Python
- 星标
- 13.9k
- 派生
- 2.4k
- 平均合并
- 1 天 16 小时
- 30 天内合并 PR
- 432
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/agent-framework 的其他 Issue
-
.NET python triage
难度 1/5 1 小时以内 新手友好度 85/100
microsoft/agent-framework#9092 · 1 条评论 ·
维护者通常 1 天内回复
-
Python: raw-data content mappings lose annotations and attachment metadata可能已有人在做 @moonbox3 于 7 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/agent-framework#8632 · 2 条评论 ·
维护者通常 1 天内回复
-
Python: Clarify when to use platform可能已有人在做 @eavanvalkenburg 于 6 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/agent-framework#8599 · 1 条评论 ·
维护者通常 1 天内回复
-
.NET Compaction - Update docs to refer to `AIContextProvider` deep dive可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭.NET compaction documentation
难度 1/5 1 小时以内 新手友好度 82/100
microsoft/agent-framework#4629 · 1 条评论 ·
维护者通常 1 天内回复
-
Python: [Bug]: Public stream close does not release delegated provider responses可能已有人在做 @eavanvalkenburg 今天认领。 未关闭ag-ui python reproduced
microsoft/agent-framework#9099 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 microsoft/agent-framework 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
area:docs
难度 2/5 1-3 小时 新手友好度 72/100
RailtownAI/railtracks#1633 ·
维护者通常 2 天内回复
-
review-panel severity:low
难度 1/5 1 小时以内 新手友好度 85/100
kristovatlas/coin-accounting#152 ·
维护者通常 1 天内回复
-
documentation :blue_book:
难度 1/5 1 小时以内 新手友好度 88/100
PennyLaneAI/pennylane#10280 ·
维护者通常 2 天内回复
-
`pipx reinstall` prints a Python traceback when the reinstall fails可能已有人在做 @ParamTanna 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复