.NET: Fix AG-UI SSE events written with explicit nulls - #7920
Open
Atharva Vichare (atty57) wants to merge 1 commit into
Open
.NET: Fix AG-UI SSE events written with explicit nulls#7920Atharva Vichare (atty57) wants to merge 1 commit into
Atharva Vichare (atty57) wants to merge 1 commit into
Conversation
ConfigureAGUIJsonOptions appended its resolvers to the ASP.NET Core
TypeInfoResolverChain, which already has a reflection-based resolver at
its head. Both appended resolvers were therefore unreachable for every
type reflection can handle, so the AG-UI wire-format rules never applied.
This was invisible with AGUI 0.0.5, whose omit-empty rule rides on
attributes the reflection resolver honors. AGUI 0.0.6 moved that rule to
a type-info modifier on AGUIJsonUtilities.DefaultTypeInfoResolver, which
only applies when that resolver is actually consulted. Bumping the pin
without fixing the ordering makes every SSE event go out with explicit
nulls for its optional fields ("parentRunId": null and similar), which
@ag-ui/client rejects with a ZodError.
Insert both resolvers ahead of the reflection resolver and compose
AGUIJsonUtilities.DefaultTypeInfoResolver rather than the context
directly, as the AGUI docs direct. The AGUI pin moves to 0.0.6 in the
same change since DefaultTypeInfoResolver is new in that version.
Adds a regression test asserting the serialized event carries no explicit
nulls; it fails against the previous ordering.
Atharva Vichare (atty57)
requested review from
SergeyMenshykh,
chetantoshniwal,
Peter Ibekwe (peibekwe),
Roger Barreto (rogerbarreto) and
westey (westey-m)
as code owners
August 27, 2026 16:52
Atharva Vichare (atty57)
deployed
to
github-app-auth
August 27, 2026 16:52 — with
GitHub Actions
Active
Atharva Vichare (atty57)
deployed
to
github-app-auth
August 27, 2026 16:52 — with
GitHub Actions
Active
Atharva Vichare (atty57)
deployed
to
github-app-auth
August 27, 2026 16:52 — with
GitHub Actions
Active
Atharva Vichare (atty57)
deployed
to
github-app-auth
August 27, 2026 16:52 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes AG-UI SSE serialization so optional fields are omitted rather than emitted as null.
Changes:
- Prioritizes AG-UI serialization metadata.
- Updates AG-UI packages to 0.0.6.
- Adds null-omission regression coverage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ConfigureAGUIJsonOptions.cs |
Reorders and updates JSON resolvers. |
ConfigureAGUIJsonOptionsTests.cs |
Tests optional-field omission. |
Directory.Packages.props |
Updates AG-UI package versions. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| // | ||
| // Agent Framework abstractions follow so that M.E.AI types are handled via its resolver. | ||
| chain.Insert(0, AGUIJsonUtilities.DefaultTypeInfoResolver); | ||
| chain.Insert(1, AgentAbstractionsJsonUtilities.DefaultOptions.TypeInfoResolver!); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
AddAGUIServer()configures the ASP.NET CoreJsonOptionsused to serialize AG-UI events, but it appends its resolvers toTypeInfoResolverChain. ASP.NET Core already places a reflection-based resolver at the head of that chain, so both appended resolvers are unreachable for every type reflection can handle — the AG-UI wire-format rules never applied on this path.That was invisible with AGUI 0.0.5, whose omit-empty rule rides on attributes the reflection resolver honors. AGUI 0.0.6 moved the rule to a type-info modifier on
AGUIJsonUtilities.DefaultTypeInfoResolver, which only applies when that resolver is actually consulted. Bumping the pin without fixing the ordering makes every SSE event go out with explicit nulls for its optional fields:@ag-ui/clientdeclares those fields optional, not nullable, so it rejects the first event with aZodErrorand the whole run fails client-side.Description & Review Guide
What are the major changes?
ConfigureAGUIJsonOptionsnowInserts both resolvers ahead of the reflection resolver instead of appending them, and composesAGUIJsonUtilities.DefaultTypeInfoResolverrather thanAGUIJsonSerializerContext.Defaultdirectly — the composition the AGUI docs direct integrators to use.DefaultTypeInfoResolveris new in 0.0.6.What is the impact of these changes?
What do you want reviewers to focus on?
Insert(0, …)places the AG-UI resolver ahead of any resolver an application registered itself. That is what the wire format requires and matches the workaround in the issue, but the precedence call is worth a maintainer's eye.ChatMessagealso serializes with explicit nulls through these options for the same ordering reason. That affects request/response bodies rather than the AG-UI event stream, so it felt out of scope for this fix — happy to fold it in if you would rather it move together.Related Issue
Fixes #7919
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.Verified locally: 19/19 unit tests pass on net8.0 and net9.0, 13/13 on net10.0. The new test fails against the previous
Add(...)ordering and passes with the fix.