[dotnet-port] Port auto-approval rules (heuristics) to toolapproval middleware - #254
Conversation
Port microsoft/agent-framework#6335: add heuristic auto-approval rules to ToolApprovalAgent. AutoApprovalFuncs in Config lets callers provide predicate functions that are evaluated after standing rules but before surfacing an approval request to the user. The first function returning true auto-approves the call without interrupting the caller. - Add AutoApprovalFuncs []func(*message.FunctionCallContent) bool to Config - Change New to capture cfg via closure instead of ignoring it - Change run to accept Config and thread it through to drainAutoApprovable - Add matchesAutoApprovalFuncs helper (first-match-wins semantics) - Apply auto-approval funcs in drainAutoApprovable (queued requests) and in the outbound classification loop (new requests from inner agent) - Add 5 tests covering: matching, non-matching, first-match-wins, queued request drain, and standing-rule precedence Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR ports heuristic auto-approval support into the Go agent/harness/toolapproval middleware, allowing callers to provide custom predicate functions (AutoApprovalFuncs) that can auto-approve tool calls after standing rules but before surfacing approval requests to the caller.
Changes:
- Adds
Config.AutoApprovalFuncs []func(*message.FunctionCallContent) booland threadsConfigthrough the middleware run loop. - Applies heuristic auto-approval both when draining queued requests and when classifying newly emitted approval requests.
- Updates docs and adds tests for basic matching/non-matching and ordering semantics.
Show a summary per file
| File | Description |
|---|---|
| docs/dotnet-go-sdk-feature-comparison.md | Updates the feature matrix to mention auto-approval heuristics for tool approval. |
| agent/harness/toolapproval/toolapproval.go | Introduces AutoApprovalFuncs config and applies it in queued draining + outbound request classification. |
| agent/harness/toolapproval/toolapproval_test.go | Adds tests covering auto-approval func behavior and ordering; includes a test naming/coverage gap around standing-rule precedence. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 4
This comment has been minimized.
This comment has been minimized.
…aming parity note
|
Implemented in 0817fc9.
|
Implemented in fd446e7 (API change) and d63a91d (follow-up terminology cleanup).
|
…-6f3fbaff71786421
This comment has been minimized.
This comment has been minimized.
|
@copilot AutoApprovalRules callbacks return signature should also have an error. |
Implemented in 79eb87b.
|
Cross-Repo Parity ReviewThis PR ports API shape comparison
VerdictThe Go implementation is semantically aligned with the upstream .NET implementation. The differences (
|
Port microsoft/agent-framework#6335: add heuristic auto-approval rules to ToolApprovalAgent.
AutoApprovalRulesinConfiglets callers provide callbacks that are evaluated after standing rules but before surfacing an approval request to the user. The first rule returningapproved=trueauto-approves the call without interrupting the caller; if a rule returns an error, the run fails with that error.AutoApprovalRules []func(context.Context, *message.FunctionCallContent) (bool, error)toConfigNewto capturecfgvia closure instead of ignoring itrunto acceptConfigand thread it through todrainAutoApprovablematchesAutoApprovalRuleshelper (first-match-wins semantics, nil entries skipped, error propagation)drainAutoApprovable(queued requests) and in the outbound classification loop (new requests from inner agent)AutoApprovalRulesnaming and context-aware callback signature with error return