Skip to content

[dotnet-port-fixes] Add tool approval no-session parity test #874

Description

@github-actions

Summary

Add a regression test in agent/harness/toolapproval/toolapproval_test.go that ports the intent of the upstream .NET no-session tool-approval fix. The Go middleware already preserves the original user message when an approval request is auto-approved and the inner agent is re-invoked in the same run, so this change locks that behavior in with explicit parity coverage rather than changing the implementation.

Upstream reference: microsoft/agent-framework#7310 and commit 28e02d466997972d51c0a435b133a875f7444976.

Ported .NET PRs

Breaking Changes

No.

Tests and Examples

  • go test ./agent/harness/toolapproval
  • Added TestToolApproval_AutoApprovalWithoutSessionPreservesOriginalMessages
  • No examples changed

Notes

The broader recent dotnet/ inspection did not produce a smaller behavior fix that was both unported and in scope for [dotnet-port-fixes]. This PR keeps the nightly change narrow by adding parity coverage for the remaining applicable tool-approval regression path instead of changing public or internal behavior that is already aligned.

Generated by .NET to Go Fixes and Test Porting Agent · gpt54 · 182.5 AIC · ⌖ 12 AIC · ⊞ 24.2K · ◷


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-fixes-toolapproval-nosession-test-96025d5d57d2401e.

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 (104 of 104 lines)
From 89b44222b6dfd8952848b30374dbd247ee68ac01 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 20 Aug 2026 02:53:12 +0000
Subject: [PATCH] [dotnet-port-fixes] Add tool approval no-session parity test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../harness/toolapproval/toolapproval_test.go | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/agent/harness/toolapproval/toolapproval_test.go b/agent/harness/toolapproval/toolapproval_test.go
index d078861fd..04e34784a 100644
--- a/agent/harness/toolapproval/toolapproval_test.go
+++ b/agent/harness/toolapproval/toolapproval_test.go
@@ -227,6 +227,85 @@ func TestToolApproval_AlwaysApproveToolCreatesRule(t *testing.T) {
 	}
 }
 
+func TestToolApproval_AutoApprovalWithoutSessionPreservesOriginalMessages(t *testing.T) {
+	fcc := &message.FunctionCallContent{CallID: "c1", Name: "deploy", Arguments: `{"env":"prod"}`}
+
+	runner := &agenttest.Runner{
+		Responses: agenttest.NewResponseBuilder().
+			Add(&agent.ResponseUpdate{
+				Role: message.RoleAssistant,
+				Contents: []message.Content{
+					&message.ToolApprovalRequestContent{RequestID: "r1", ToolCall: fcc},
+				},
+			}).
+			NewTurn(func(_ context.Context, messages []*message.Message, _ ...agent.Option) {
+				if len(messages) != 2 {
+					t.Fatalf("expected original user message plus injected approval response, got %d messages", len(messages))
+				}
+
+				if messages[0].Role != message.RoleUser {
+					t.Fatalf("first message role = %q, want %q", messages[0].Role, message.RoleUser)
+				}
+				text, ok := messages[0].Contents[0].(*message.TextContent)
+				if !ok || text.Text != "go" {
+					t.Fatalf("first message contents = %#v, want original user text", messages[0].Contents)
+				}
+
+				if messages[1].Role != message.RoleUser {
+					t.Fatalf("second message role = %q, want %q", messages[1].Role, message.RoleUser)
+				}
+				if len(messages[1].Cont
... (truncated)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions