Skip to content

[dotnet-port-api] Bind tool approval responses to surfaced requests - #1002

Open
Michelle Clayton (michelle-clayton-work) wants to merge 3 commits into
mainfrom
dotnet-port-api-approval-response-binding-ec06dcb2a240cae7
Open

[dotnet-port-api] Bind tool approval responses to surfaced requests#1002
Michelle Clayton (michelle-clayton-work) wants to merge 3 commits into
mainfrom
dotnet-port-api-approval-response-binding-ec06dcb2a240cae7

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

Summary

Port the harness-side approval-response binding behavior from .NET PR microsoft/agent-framework#7111 into Go's agent/harness/toolapproval middleware.

This change records surfaced approval requests in session state, rebinds inbound approval responses to the recorded request tool call by default, drops unbound or duplicate responses, and exposes toolapproval.Config.DisableApprovalResponseBinding as the public opt-out. It also adds focused regression coverage for snapshot binding, history-carried requests, duplicate responses, unbound responses, and the opt-out path, and updates the parity note in docs/dotnet-go-sdk-feature-comparison.md.

Primary upstream commit: 09473fa7edc4142d89d4269fc3f8d4ae35c3bcf3
Upstream link: microsoft/agent-framework@09473fa

Ported .NET PRs

Breaking Changes

Yes. Previously, Go forwarded inbound ToolApprovalResponseContent unchanged, including responses whose tool call no longer matched the surfaced request or that were not tied to any surfaced request at all. Now, approval responses are rebound to the surfaced request's tool call by default and unbound/duplicate responses are ignored. This is acceptable in the beta Go SDK because it closes a user-facing approval-flow integrity gap while still providing an explicit compatibility opt-out via toolapproval.Config.DisableApprovalResponseBinding.

Tests and Examples

  • Ran go test ./agent/harness/toolapproval ./agent/harness/toolautocall
  • Added focused agent/harness/toolapproval regression tests for surfaced-request snapshot binding, history request binding, unbound response dropping, duplicate response consumption, and DisableApprovalResponseBinding
  • No examples updated; the user-facing scenario remains the existing tool-approval middleware flow

Notes

  • This PR ports the harness-side behavior only. The broader .NET chat-client decorator added in #7111 does not have a direct Go equivalent because Go exposes the approval flow through explicit middleware rather than the .NET chat-client pipeline.
  • Recent upstream approval-related items already tracked by the nightly workflows, such as microsoft/agent-framework#6970 and microsoft/agent-framework#7107, were intentionally skipped to avoid duplication.

Generated by .NET to Go API Porting Agent · 1.2K AIC · ⌖ 33.5 AIC · ⊞ 21.7K ·

Closes #588

Port .NET approval-response binding from microsoft/agent-framework#7111 into the Go tool approval middleware.

Add surfaced-request tracking and default response rebinding in agent/harness/toolapproval, expose a DisableApprovalResponseBinding opt-out in toolapproval.Config, add focused regression coverage, and update the feature comparison note.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Binding currently trusts ToolApprovalRequestContent from any inbound message, which allows caller/user-provided forged request+response pairs to be treated as “bound,” undermining the unbound-response drop behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Ports the .NET harness behavior for tool-approval response binding into Go’s agent/harness/toolapproval middleware to ensure inbound approval responses are tied to previously surfaced approval requests (with an opt-out), and adds regression coverage + documentation parity updates.

Changes:

  • Persist surfaced approval requests in session state and rebind inbound approval responses to the recorded request tool call by default (dropping unbound/duplicate responses).
  • Add toolapproval.Config.DisableApprovalResponseBinding as a compatibility opt-out to preserve prior passthrough behavior.
  • Add focused tests for snapshot binding, history-carried requests, unbound/duplicate response handling, and the opt-out path; update the feature parity note.
File summaries
File Description
agent/harness/toolapproval/toolapproval.go Adds surfaced-request tracking + default approval-response rebinding, plus a public opt-out flag.
agent/harness/toolapproval/toolapproval_test.go Adds regression tests covering binding behavior, duplicates/unbound handling, history binding, and opt-out.
docs/dotnet-go-sdk-feature-comparison.md Updates the tool-approval parity note to mention response rebinding + the new disable knob.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread agent/harness/toolapproval/toolapproval.go
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:tests Changes tests, fixtures, or test infrastructure pending-auto-risk Automatic risk classification is in progress risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Sep 4, 2026
@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

Copilot resolve merge conflicts and address PR feedback

…val-response-binding-ec06dcb2a240cae7

# Conflicts:
#	agent/harness/toolapproval/toolapproval.go
#	agent/harness/toolapproval/toolapproval_test.go
#	docs/dotnet-go-sdk-feature-comparison.md

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve merge conflicts and address PR feedback

Resolved the main merge conflicts and restricted binding to middleware-surfaced requests or assistant-history requests. User-supplied request/response pairs are no longer trusted. Addressed in f4673df.

@github-actions github-actions Bot added pending-auto-risk Automatic risk classification is in progress and removed risk:medium Contained production impact requiring normal review depth labels Sep 6, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs risk:high Large blast radius, difficult rollback, or sensitive behavior and removed pending-auto-risk Automatic risk classification is in progress labels Sep 6, 2026
@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

Copilot fix linter issues

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Copilot fix linter issues

Fixed the gofumpt failure in 003a819. The targeted toolapproval and toolautocall tests pass.

@github-actions github-actions Bot added pending-auto-risk Automatic risk classification is in progress and removed risk:high Large blast radius, difficult rollback, or sensitive behavior labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Scope: public API, user-visible behavior

Changed Go contract: toolapproval.Config.DisableApprovalResponseBinding (new exported bool field, default false); prepareInbound/run in agent/harness/toolapproval/toolapproval.go now rebind inbound ToolApprovalResponseContent/AlwaysApproveToolApprovalResponseContent to the surfaced/history-carried ToolApprovalRequestContent by request ID, drop unbound or duplicate responses, and inject the recorded (snapshotted) tool call downstream when binding is enabled.

Upstream evidence reviewed:

  • dotnet/src/Microsoft.Agents.AI/ChatClient/ApprovalResponseBindingChatClient.cs (commit 09473fa) — records surfaced ToolApprovalRequestContent per session, rebinds inbound ToolApprovalResponseContent to the recorded request's tool call, drops responses with no matching pending request.
  • dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentOptions.csDisableApprovalResponseBinding (bool, default false) opt-out, with the binding decorator injected by default.
  • dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgentOptions.cs — harness-level DisableApprovalResponseBinding (bool, default false), same semantics, mirrored at the harness layer (the layer Go's toolapproval middleware corresponds to).
  • dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ApprovalResponseBindingChatClientTests.cs and dotnet/tests/.../ToolApprovalAgentTests.cs — cover binding, unbound-response dropping, and duplicate-response handling, mirrored by the new Go tests in toolapproval_test.go.

Result: aligned. Field name, default (binding enabled unless explicitly disabled), and behavior (bind-by-request-ID, rebind tool call to the surfaced/history request, drop unbound/duplicate responses) match the upstream .NET port at both the chat-client-decorator and harness-options layers. The PR correctly notes Go implements this as middleware rather than a chat-client decorator, which is an acceptable, documented architectural difference (Go doesn't have .NET's chat-client pipeline layering). docs/dotnet-go-sdk-feature-comparison.md was updated consistently. No exported API naming, default, or behavior divergence found.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent for #1002 · copilot · auto · 28 AIC · ⌖ 10 AIC · ⊞ 9.5K ·

@github-actions github-actions Bot added risk:medium Contained production impact requiring normal review depth and removed pending-auto-risk Automatic risk classification is in progress labels Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs risk:medium Contained production impact requiring normal review depth size:xlarge More than 300 changed lines or 10 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port-api] Bind tool approval responses to surfaced requests

3 participants