Skip to content

Commit 696d14c

Browse files
Updates after rebase
1 parent d45db9d commit 696d14c

4 files changed

Lines changed: 28 additions & 15 deletions

File tree

dotnet/test/AgentAndCompactRpcTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task Should_List_Available_Custom_Agents()
3333
}
3434
};
3535

36-
var session = await Client.CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
36+
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
3737

3838
var result = await session.Rpc.Agent.ListAsync();
3939
Assert.NotNull(result.Agents);
@@ -58,7 +58,7 @@ public async Task Should_Return_Null_When_No_Agent_Is_Selected()
5858
}
5959
};
6060

61-
var session = await Client.CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
61+
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
6262

6363
var result = await session.Rpc.Agent.GetCurrentAsync();
6464
Assert.Null(result.Agent);
@@ -78,7 +78,7 @@ public async Task Should_Select_And_Get_Current_Agent()
7878
}
7979
};
8080

81-
var session = await Client.CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
81+
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
8282

8383
// Select the agent
8484
var selectResult = await session.Rpc.Agent.SelectAsync("test-agent");
@@ -106,7 +106,7 @@ public async Task Should_Deselect_Current_Agent()
106106
}
107107
};
108108

109-
var session = await Client.CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
109+
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
110110

111111
// Select then deselect
112112
await session.Rpc.Agent.SelectAsync("test-agent");

go/internal/e2e/agent_and_compact_rpc_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func TestAgentSelectionRpc(t *testing.T) {
2626
}
2727

2828
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
29+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
2930
CustomAgents: []copilot.CustomAgentConfig{
3031
{
3132
Name: "test-agent",
@@ -80,6 +81,7 @@ func TestAgentSelectionRpc(t *testing.T) {
8081
}
8182

8283
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
84+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
8385
CustomAgents: []copilot.CustomAgentConfig{
8486
{
8587
Name: "test-agent",
@@ -119,6 +121,7 @@ func TestAgentSelectionRpc(t *testing.T) {
119121
}
120122

121123
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
124+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
122125
CustomAgents: []copilot.CustomAgentConfig{
123126
{
124127
Name: "test-agent",
@@ -173,6 +176,7 @@ func TestAgentSelectionRpc(t *testing.T) {
173176
}
174177

175178
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
179+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
176180
CustomAgents: []copilot.CustomAgentConfig{
177181
{
178182
Name: "test-agent",
@@ -222,7 +226,9 @@ func TestAgentSelectionRpc(t *testing.T) {
222226
t.Fatalf("Failed to start client: %v", err)
223227
}
224228

225-
session, err := client.CreateSession(t.Context(), nil)
229+
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
230+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
231+
})
226232
if err != nil {
227233
t.Fatalf("Failed to create session: %v", err)
228234
}
@@ -254,7 +260,9 @@ func TestSessionCompactionRpc(t *testing.T) {
254260
t.Run("should compact session history after messages", func(t *testing.T) {
255261
ctx.ConfigureForTest(t)
256262

257-
session, err := client.CreateSession(t.Context(), nil)
263+
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
264+
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
265+
})
258266
if err != nil {
259267
t.Fatalf("Failed to create session: %v", err)
260268
}

nodejs/test/e2e/agent_and_compact_rpc.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*--------------------------------------------------------------------------------------------*/
44

55
import { describe, expect, it } from "vitest";
6+
import { approveAll } from "../../src/index.js";
67
import type { CustomAgentConfig } from "../../src/index.js";
78
import { createSdkTestContext } from "./harness/sdkTestContext.js";
89

@@ -25,7 +26,7 @@ describe("Agent Selection RPC", async () => {
2526
},
2627
];
2728

28-
const session = await client.createSession({ customAgents });
29+
const session = await client.createSession({ onPermissionRequest: approveAll, customAgents });
2930

3031
const result = await session.rpc.agent.list();
3132
expect(result.agents).toBeDefined();
@@ -49,7 +50,7 @@ describe("Agent Selection RPC", async () => {
4950
},
5051
];
5152

52-
const session = await client.createSession({ customAgents });
53+
const session = await client.createSession({ onPermissionRequest: approveAll, customAgents });
5354

5455
const result = await session.rpc.agent.getCurrent();
5556
expect(result.agent).toBeNull();
@@ -67,7 +68,7 @@ describe("Agent Selection RPC", async () => {
6768
},
6869
];
6970

70-
const session = await client.createSession({ customAgents });
71+
const session = await client.createSession({ onPermissionRequest: approveAll, customAgents });
7172

7273
// Select the agent
7374
const selectResult = await session.rpc.agent.select({ name: "test-agent" });
@@ -93,7 +94,7 @@ describe("Agent Selection RPC", async () => {
9394
},
9495
];
9596

96-
const session = await client.createSession({ customAgents });
97+
const session = await client.createSession({ onPermissionRequest: approveAll, customAgents });
9798

9899
// Select then deselect
99100
await session.rpc.agent.select({ name: "test-agent" });
@@ -107,7 +108,7 @@ describe("Agent Selection RPC", async () => {
107108
});
108109

109110
it("should return empty list when no custom agents configured", async () => {
110-
const session = await client.createSession();
111+
const session = await client.createSession({ onPermissionRequest: approveAll });
111112

112113
const result = await session.rpc.agent.list();
113114
expect(result.agents).toEqual([]);
@@ -120,7 +121,7 @@ describe("Session Compact RPC", async () => {
120121
const { copilotClient: client } = await createSdkTestContext();
121122

122123
it("should compact session history after messages", async () => {
123-
const session = await client.createSession();
124+
const session = await client.createSession({ onPermissionRequest: approveAll });
124125

125126
// Send a message to create some history
126127
await session.sendAndWait({ prompt: "What is 2+2?" });

python/e2e/test_agent_and_compact_rpc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from copilot import CopilotClient
5+
from copilot import CopilotClient, PermissionHandler
66
from copilot.generated.rpc import SessionAgentSelectParams
77

88
from .testharness import CLI_PATH, E2ETestContext
@@ -20,6 +20,7 @@ async def test_should_list_available_custom_agents(self):
2020
await client.start()
2121
session = await client.create_session(
2222
{
23+
"on_permission_request": PermissionHandler.approve_all,
2324
"custom_agents": [
2425
{
2526
"name": "test-agent",
@@ -59,6 +60,7 @@ async def test_should_return_null_when_no_agent_is_selected(self):
5960
await client.start()
6061
session = await client.create_session(
6162
{
63+
"on_permission_request": PermissionHandler.approve_all,
6264
"custom_agents": [
6365
{
6466
"name": "test-agent",
@@ -87,6 +89,7 @@ async def test_should_select_and_get_current_agent(self):
8789
await client.start()
8890
session = await client.create_session(
8991
{
92+
"on_permission_request": PermissionHandler.approve_all,
9093
"custom_agents": [
9194
{
9295
"name": "test-agent",
@@ -125,6 +128,7 @@ async def test_should_deselect_current_agent(self):
125128
await client.start()
126129
session = await client.create_session(
127130
{
131+
"on_permission_request": PermissionHandler.approve_all,
128132
"custom_agents": [
129133
{
130134
"name": "test-agent",
@@ -156,7 +160,7 @@ async def test_should_return_empty_list_when_no_custom_agents_configured(self):
156160

157161
try:
158162
await client.start()
159-
session = await client.create_session({})
163+
session = await client.create_session({"on_permission_request": PermissionHandler.approve_all})
160164

161165
result = await session.rpc.agent.list()
162166
assert result.agents == []
@@ -171,7 +175,7 @@ class TestSessionCompactionRpc:
171175
@pytest.mark.asyncio
172176
async def test_should_compact_session_history_after_messages(self, ctx: E2ETestContext):
173177
"""Test compacting session history via RPC."""
174-
session = await ctx.client.create_session({})
178+
session = await ctx.client.create_session({"on_permission_request": PermissionHandler.approve_all})
175179

176180
# Send a message to create some history
177181
await session.send_and_wait({"prompt": "What is 2+2?"})

0 commit comments

Comments
 (0)