Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

.NET: [Bug]: AddAGUIServer's JSON setup writes null optional fields (rejected by @ag-ui/client) and cannot serialize interrupts

Abierto
#8,962 4 comentarios 1 reacción 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@javiercn ya está trabajando en esto.

Desde el 2/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

.NET ag-ui hosting reproduced
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 AGUIJsonSerializerContext resolver. AGUI.Abstractions documents AGUIJsonUtilities.DefaultTypeInfoResolver (that context plus OmitPropertiesWithoutAValue) as the resolver to use instead.
  • What happens: RUN_STARTED goes out with "parentRunId": null and "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.DefaultTypeInfoResolver does.

2. Interrupts cannot be serialized.

  • Cause: the method never calls AGUIJsonUtilities.RegisterInterruptContentTypes.
  • What happens: an agent that yields InterruptRequestContent makes the server fail the run. The same happens when the response update containing one is serialized, for example for rawEvent. The client receives RUN_ERROR ("An error occurred while streaming the agent response.") instead of a RUN_FINISHED whose 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

  1. Use builder.Services.AddAGUIServer(); and app.MapAGUIServer("/agui", agent); with any ChatClientAgent.
  2. POST a run and read the stream with @ag-ui/client's HttpAgent. You get a ZodError on RUN_STARTED (defect 1).
  3. Have the agent's chat client yield new ChatResponseUpdate(ChatRole.Assistant, [new InterruptRequestContent("ask-1") { Reason = "input_required", Message = "?" }]). The run ends in RUN_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 targets AGUI.* 0.0.6.
  • Suggested fix: in ConfigureAGUIJsonOptions.Configure, insert AGUIJsonUtilities.DefaultTypeInfoResolver (rather than adding the raw context) and call AGUIJsonUtilities.RegisterInterruptContentTypes(options.SerializerOptions).
Lenguaje dominante
Python
Estrellas
13.9k
Forks
2.4k
Merge medio
1 d 16 h
PR fusionados (30 d)
432

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/agent-framework

Todos los issues de microsoft/agent-framework

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.