You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Port the upstream .NET tool-approval auto-approval context change into Go by introducing toolapproval.ToolAutoApprovalRuleContext and updating toolapproval.Config.AutoApprovalRules to receive the richer context instead of only a function call. This keeps the Go toolapproval middleware aligned with the newer .NET surface so custom auto-approval logic can inspect the current session, request messages, and run options without future callback-signature churn.
Yes. toolapproval.Config.AutoApprovalRules changed from callbacks with signature func(context.Context, *message.FunctionCallContent) (bool, error) to callbacks with signature toolapproval.AutoApprovalRule, which receives toolapproval.ToolAutoApprovalRuleContext. Existing rules must read the function call from context.FunctionCallContent. This is acceptable because the Go SDK is still in beta and the new context wrapper matches the upstream .NET direction while making future context additions non-breaking.
Tests and Examples
Ran go test ./agent/harness/toolapproval
Added coverage for forwarding request messages, session, and run options into auto-approval rules
Updated the feature comparison doc entry for tool approval parity
Other recent upstream harness and provider changes were intentionally skipped because they were either broader than a single nightly PR or were better categorized as fix/misalignment work rather than a public API port.
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-port/toolapproval-rule-context-30518781713-18017d74ba563d35.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (315 of 315 lines)
From c4015a0272063ac54a8f7e08b384f4187008b574 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 30 Jul 2026 06:20:03 +0000
Subject: [PATCH] [dotnet-port-api] Align toolapproval auto-approval rule
context
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
agent/harness/toolapproval/toolapproval.go | 56 ++++++++---
.../harness/toolapproval/toolapproval_test.go | 93 +++++++++++++++----
docs/dotnet-go-sdk-feature-comparison.md | 2 +-
3 files changed, 117 insertions(+), 34 deletions(-)
diff --git a/agent/harness/toolapproval/toolapproval.go b/agent/harness/toolapproval/toolapproval.go
index d07482b69..cacca86e5 100644
--- a/agent/harness/toolapproval/toolapproval.go+++ b/agent/harness/toolapproval/toolapproval.go@@ -76,6 +76,26 @@ func saveState(opts []agent.Option, s state) {
session.Set(stateKey, s)
}
+// ToolAutoApprovalRuleContext provides the tool call plus surrounding run+// context available to an auto-approval rule.+type ToolAutoApprovalRuleContext struct {+ // FunctionCallContent is the tool call that requires approval.+ FunctionCallContent *message.FunctionCallContent++ // Session is the session associated with the current run, if any.+ Session *agent.Session++ // RequestMessages are the messages originally supplied to the current run.+ RequestMessages []*message.Message++ // Options are the run options supplied to the current run.+ Options []agent.Option+}++// AutoApprovalRule evaluates whether a tool call should be approved without+// surfacing it to the caller.+type AutoApprovalRule func(context.Context, ToolAutoApprovalRuleContext) (bool, error)+
// New creates a tool-approval middleware that wraps agent runs with
// human-in-the-loop approval management.
func New(cfg Config) agent.Middleware {
@@ -88,16 +108,17 @@ func New(cfg Config) agent.Middleware {
type Config struct {
// AutoApprovalRules is an optional list of heuristic
... (truncated)
Summary
Port the upstream .NET tool-approval auto-approval context change into Go by introducing
toolapproval.ToolAutoApprovalRuleContextand updatingtoolapproval.Config.AutoApprovalRulesto receive the richer context instead of only a function call. This keeps the Go toolapproval middleware aligned with the newer .NET surface so custom auto-approval logic can inspect the current session, request messages, and run options without future callback-signature churn.Ported .NET PRs
ToolAutoApprovalRuleContextUpstream commit:
b3f2e5392(.NET: [BREAKING] Graduate ToolApprovalAgent and add ToolAutoApprovalRuleContext)Breaking Changes
Yes.
toolapproval.Config.AutoApprovalRuleschanged from callbacks with signaturefunc(context.Context, *message.FunctionCallContent) (bool, error)to callbacks with signaturetoolapproval.AutoApprovalRule, which receivestoolapproval.ToolAutoApprovalRuleContext. Existing rules must read the function call fromcontext.FunctionCallContent. This is acceptable because the Go SDK is still in beta and the new context wrapper matches the upstream .NET direction while making future context additions non-breaking.Tests and Examples
go test ./agent/harness/toolapprovalNotes
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
dotnet-port/toolapproval-rule-context-30518781713-18017d74ba563d35.Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (315 of 315 lines)