Add AGUIStreamOptions.IncludeRawEvents - #2298
Open
halllo wants to merge 1 commit into
Open
Conversation
…ents to save bandwidth
4 tasks
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.
Closes #2297.
.NET servers attach the serialized originating
ChatResponseUpdateasrawEventto everyTEXT_MESSAGE_*,TOOL_CALL_*, andREASONING_ENCRYPTED_VALUEevent, with no way to opt out. On this repo's ownStep*baselines that field is 66% of the wire. Nothing reads it, and neither the TS nor the Python server side emits it — so it is a .NET-only divergence from the canonical wire format.This adds an init-only
bool IncludeRawEvents(defaulttrue) toAGUIStreamOptions. The guard sits on the serialization rather than the assignment, so opting out also recovers the per-update CPU and allocations:The default is
truedeliberately.falseis arguably the parity-correct long-term default, but flipping it breaks anyone reading the field and moves every recorded baseline — better as its own deliberate change. This one is purely additive.Every
Createalready tookJsonElement?, so one internal signature widened (ReasoningMessageTracker.EmitEncryptedValue). Caller-supplied events (RawRepresentationor aMap*mapping) keep their ownRawEvent. The event sequence is identical either way, so this is not a protocol change.Tests
Six unit tests: default
true; the field drops from text, tool-call, andREASONING_ENCRYPTED_VALUEevents; caller-suppliedrawEventsurvives; identical event sequence either way. PlusRawEventSuppressionIntegrationTest, asserting the SSE body contains"rawEvent"only when the flag is on.AGUI.Server.UnitTests120/120 on net8.0/9.0/10.0, solution builds with 0 warnings, other suites pass. Two pre-existing failures are unaffected and reproduce on a clean checkout: cross-language needs a running TS server, andStep08_MultimodalMessagesTestreads an unfetched git-lfs pointer as its PNG.Docs
New
IncludeRawEventssection inhosting/extensibility.mdx, plus pointers fromabstractions/events.mdxandsdks/dotnet/docs/architecture.md.