.NET: Update AG-UI samples for latest MAF + AG-UI SDK and align with docs - #7295
Merged
westey (westey-m) merged 11 commits intoAug 19, 2026
Merged
Conversation
The Step04 sample previously wrapped both the server and client agents in custom ServerFunctionApproval*Agent middleware (~470 lines across two files) to marshal a bespoke approval protocol over AG-UI. This is no longer needed: MapAGUIServer natively emits the tool-approval interrupt when the model calls an ApprovalRequiredAIFunction, and AGUIChatClient natively transports the client's ToolApprovalResponseContent decision back to resume the run. Changes: - Server: map the ChatClientAgent directly with MapAGUIServer; remove the ServerFunctionApprovalAgent wrapper, the JsonOptions plumbing, and the ApprovalJsonContext registration. - Client: use the AGUIChatClient-backed agent directly; the existing loop already handles ToolApprovalRequestContent -> CreateResponse idiomatically. - Delete ServerFunctionApprovalServerAgent.cs and ServerFunctionApprovalClientAgent.cs. Verified end-to-end (approval request -> approve -> tool executes -> final response) against GitHub Models. Both projects build with 0 warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eeb2168d-2ecc-4f8d-9830-c287072eb7e1
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
July 23, 2026 14:34 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
July 23, 2026 14:34 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
July 23, 2026 14:34 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
July 23, 2026 14:35 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
July 23, 2026 14:35 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
July 23, 2026 14:35 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies the .NET AG-UI Step04 “Human-in-the-loop” sample by removing the bespoke server/client approval-middleware layer and relying on the framework’s native tool-approval interrupt + resume flow when using ApprovalRequiredAIFunction.
Changes:
- Removes the custom server-side
DelegatingAIAgentthat translated approval requests/responses to a bespokerequest_approvaltool-call protocol. - Removes the custom client-side
DelegatingAIAgentand JSON plumbing used to marshal the bespoke approval protocol. - Updates the Step04 server and client to map/use the underlying agents directly (
MapAGUIServer("/", baseAgent)andchatClient.AsAIAgent(...)).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Server/ServerFunctionApprovalServerAgent.cs | Deletes custom server approval middleware and its custom JSON-serialized approval models. |
| dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Server/Program.cs | Removes custom JSON options + wrapper agent; maps the base agent directly via MapAGUIServer. |
| dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Client/ServerFunctionApprovalClientAgent.cs | Deletes custom client approval middleware and its custom approval models. |
| dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Client/Program.cs | Uses the AGUI-backed agent directly and removes now-unneeded custom approval-agent wiring. |
Daniel Roth (danroth27)
marked this pull request as ready for review
July 23, 2026 19:58
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
July 23, 2026 19:58 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
July 23, 2026 19:58 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
July 23, 2026 19:58 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
July 23, 2026 19:58 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
marked this pull request as draft
July 23, 2026 19:59
The Step04 human-in-the-loop sample no longer uses the custom ServerFunctionApprovalServerAgent / ServerFunctionApprovalClientAgent wrappers. Update the README so it describes the idiomatic native flow: the server maps a plain agent with MapAGUIServer and relies on ApprovalRequiredAIFunction to raise the approval interrupt, and the client handles ToolApprovalRequestContent and replies with ToolApprovalResponseContent.
Roger Barreto (rogerbarreto)
temporarily deployed
to
github-app-auth
July 24, 2026 11:04 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
July 24, 2026 11:05 — with
GitHub Actions
Error
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
July 24, 2026 11:05 — with
GitHub Actions
Error
The Step04 client defaults to http://localhost:5100 (and the server launchSettings also uses 5100), but the README told users to run the server on port 8888, so the client could not reach it. Align the Step04 server run command to 5100. Other steps intentionally keep 8888 because their clients default to that port.
Roger Barreto (rogerbarreto)
temporarily deployed
to
github-app-auth
July 24, 2026 11:09 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
July 24, 2026 11:10 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
July 24, 2026 11:10 — with
GitHub Actions
Failure
Roger Barreto (rogerbarreto)
approved these changes
Jul 24, 2026
Roger Barreto (rogerbarreto)
marked this pull request as ready for review
July 24, 2026 11:12
Daniel Roth (danroth27)
temporarily deployed
to
integration
August 11, 2026 23:48 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
August 11, 2026 23:51 — with
GitHub Actions
Inactive
Javier Calvarro Nelson (javiercn)
approved these changes
Aug 18, 2026
Daniel Roth (danroth27)
requested review from
SergeyMenshykh,
chetantoshniwal,
Peter Ibekwe (peibekwe) and
westey (westey-m)
as code owners
August 18, 2026 17:41
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
August 18, 2026 17:41 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
August 18, 2026 17:47 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
August 18, 2026 17:47 — with
GitHub Actions
Inactive
Resolve the Directory.Packages.props conflict by retaining the AG-UI SDK 0.0.4 versions required by this PR while accepting main's updated System.Text.Json, System.Threading.Channels, and Microsoft.Extensions.AI package versions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eeb2168d-2ecc-4f8d-9830-c287072eb7e1
Daniel Roth (danroth27)
temporarily deployed
to
github-app-auth
August 18, 2026 19:28 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
August 18, 2026 19:30 — with
GitHub Actions
Inactive
Daniel Roth (danroth27)
temporarily deployed
to
integration
August 18, 2026 19:30 — with
GitHub Actions
Inactive
This was referenced Aug 18, 2026
westey (westey-m)
enabled auto-merge
August 19, 2026 09:29
Roger Barreto (rogerbarreto)
approved these changes
Aug 19, 2026
This was referenced Aug 22, 2026
Merged
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
The .NET AG-UI samples had diverged from the current MAF integration, AG-UI C# SDK, and Learn documentation. The human-in-the-loop sample maintained custom approval middleware despite native approval and resume support, while the state-management sample emitted
DataContentthat the released AG-UI server did not map to state events. Several clients also replayed messages already retained byAgentSession, and one frontend tool exposed a compiler-generated name.This update makes the samples accurate references for streaming chat, backend and frontend tools, human approval, multi-turn sessions, and shared state.
Description & Review Guide
AGUI.*packages from 0.0.3 to 0.0.4.get_user_locationname.ApprovalRequiredAIFunction,ToolApprovalRequestContent.CreateResponse, and the native AG-UI resume flow.DataContentoutput withRunAgentInput.State, a thin state-context agent, andAGUIStreamOptions.MapResultAsStateSnapshot.AgentSessionexclusively own prior conversation history so clients send only each new turn.AgentSessionhistory.Related Issue
Fixes #7623
Related documentation update: MicrosoftDocs/semantic-kernel-docs#430
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.