-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
The Microsoft Agent Framework has all the right infrastructure for AG UI state management - AgentSessionStateBag for session-level state (#3806), StateSnapshotEvent/StateDeltaEvent event types, and a transport layer that correctly converts DataContent into AG-UI SSE events — but it lacks the integration layer that would automatically bridge these pieces together.
As a result, any developer who wants to emit STATE_SNAPSHOT or STATE_DELTA events must write custom middleware (see SharedStateAgent.cs and PredictiveStateUpdatesAgent.cs in the AG-UI samples), manually wiring LLM output → state extraction → DataContent emission on every project. This is a significant ergonomic gap compared to peer frameworks like Pydantic AI and LangGraph, which have first-class framework primitives for exactly this.
What's missing
The framework currently has no way to:
- Automatically emit STATE_SNAPSHOT from AgentSession.StateBag at run start
- Automatically compute and emit STATE_DELTA (RFC 6902 JSON Patch) when StateBag.SetValue() is called
- Emit predictive STATE_DELTA events during tool-argument streaming (today FunctionCallContent is only surfaced after the argument is fully formed). PredictiveStateUpdatesAgent.cs is a workaround for this.
- Declare an agent's AGUI state schema and map tool arguments to state fields
The AGUI pipeline (MapAGUI() in Microsoft.Agents.AI.Hosting.AGUI.AspNetCore, and the conversion layer in ChatResponseUpdateAGUIExtensions) already handles the transport side, converting DataContent to STATE_SNAPSHOT/STATE_DELTA SSE events. What's missing is the upstream step: automatically populating those DataContent payloads from AgentSession.StateBag mutations when a run is being served through that pipeline.
Proposed solution
The basic case - emitting STATE_SNAPSHOT/STATE_DELTA automatically when AgentSession.StateBag is mutated, requires no configuration and could work out of the box. The advanced case, emitting predictive STATE_DELTA events during tool-argument streaming, would benefit from a declarative mapping from tool arguments to state paths, as demonstrated by Pydantic AI's AG-UI example.
References
- .NET: Support for intermediate state from Tools for AG-UI #2081 — maintainer currently points to SharedStateAgent.cs as the manual workaround
- .NET - AG-UI Support more AG-UI event types. #2558 — making internal AGUI event types public
- .NET: [BREAKING] Add session StateBag for state storage and support multiple providers on the Agent #3806 — StateBag on AgentSession (the state foundation this would build on)
Metadata
Metadata
Labels
Type
Projects
Status