Skip to content

Commit e6b0c88

Browse files
Address PR review: remove unused import, add toolName verification to Go and .NET tests
- Remove unused PermissionRequestResult import from Node.js test - Add toolName assertion in Go test for cross-SDK parity - Add toolName assertion in .NET test for cross-SDK parity Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cb6e0d9 commit e6b0c88

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

dotnet/test/ToolsTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using GitHub.Copilot.SDK.Test.Harness;
66
using Microsoft.Extensions.AI;
77
using System.ComponentModel;
8+
using System.Linq;
89
using System.Text.Json;
910
using System.Text.Json.Serialization;
1011
using Xunit;
@@ -206,8 +207,12 @@ await session.SendAsync(new MessageOptions
206207
Assert.NotNull(assistantMessage);
207208
Assert.Contains("HELLO", assistantMessage!.Data.Content ?? string.Empty);
208209

209-
// Should have received a custom-tool permission request
210-
Assert.Contains(permissionRequests, r => r.Kind == "custom-tool");
210+
// Should have received a custom-tool permission request with the correct tool name
211+
var customToolRequest = permissionRequests.FirstOrDefault(r => r.Kind == "custom-tool");
212+
Assert.NotNull(customToolRequest);
213+
Assert.True(customToolRequest!.ExtensionData?.ContainsKey("toolName") ?? false);
214+
var toolName = ((JsonElement)customToolRequest.ExtensionData!["toolName"]).GetString();
215+
Assert.Equal("encrypt_string", toolName);
211216

212217
[Description("Encrypts a string")]
213218
static string EncryptStringForPermission([Description("String to encrypt")] string input)

go/internal/e2e/tools_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ func TestTools(t *testing.T) {
312312
for _, req := range permissionRequests {
313313
if req.Kind == "custom-tool" {
314314
customToolReqs++
315+
if toolName, ok := req.Extra["toolName"].(string); !ok || toolName != "encrypt_string" {
316+
t.Errorf("Expected toolName 'encrypt_string', got '%v'", req.Extra["toolName"])
317+
}
315318
}
316319
}
317320
mu.Unlock()

nodejs/test/e2e/tools.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { join } from "path";
77
import { assert, describe, expect, it } from "vitest";
88
import { z } from "zod";
99
import { defineTool, approveAll } from "../../src/index.js";
10-
import type { PermissionRequest, PermissionRequestResult } from "../../src/index.js";
10+
import type { PermissionRequest } from "../../src/index.js";
1111
import { createSdkTestContext } from "./harness/sdkTestContext";
1212

1313
describe("Custom tools", async () => {

0 commit comments

Comments
 (0)