.NET: [BREAKING] Bind tool-approval responses to surfaced approval requests - #7111
Merged
Roger Barreto (rogerbarreto) merged 7 commits intoJul 21, 2026
Conversation
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 and Context
Tool approvals in the .NET stack are honored from the ToolApprovalResponseContent carried in the message stream. This change hardens that flow so an approved tool call always corresponds to the approval request the framework actually surfaced, keeping the human-in-the-loop control aligned with what a user was asked to approve.
Description
Adds
ApprovalResponseBindingChatClient, registered as the outermost decorator aboveFunctionInvokingChatClientin the defaultChatClientAgentpipeline:ToolApprovalRequestContentinto the sessionAgentSessionStateBag, keyed by request id.ToolApprovalResponseContentto its recorded request, rebinds the response tool call to the recorded call, consumes matched entries for one-time use, and honors only approvals tied to a framework-issued request.Applies the same binding in the
ToolApprovalAgentharness by tracking surfaced requests and binding collected responses to them during a queue cycle.Adds
ChatClientAgentOptions.DisableApprovalResponseBinding(default off) and aUseApprovalResponseBindingbuilder extension for custom chat client stacks. The Foundry hosting path already reconstructs the call from the server-side approval map and is unaffected.Contribution Checklist
dotnet formatclean on changed filesBreaking change
Approval-response binding introduces new session state for surfaced/recorded approval requests. A session serialized by an older build while an approval was still outstanding deserializes with this state empty, so its approval responses no longer bind to a request and are ignored on resume. Re-issue the request to obtain a fresh approval.