-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathAgentAndCompactRpcTests.cs
More file actions
141 lines (120 loc) · 4.58 KB
/
AgentAndCompactRpcTests.cs
File metadata and controls
141 lines (120 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
using GitHub.Copilot.SDK.Rpc;
using GitHub.Copilot.SDK.Test.Harness;
using Xunit;
using Xunit.Abstractions;
namespace GitHub.Copilot.SDK.Test;
public class AgentAndCompactRpcTests(E2ETestFixture fixture, ITestOutputHelper output)
: E2ETestBase(fixture, "agent_and_compact_rpc", output)
{
[Fact]
public async Task Should_List_Available_Custom_Agents()
{
var customAgents = new List<CustomAgentConfig>
{
new()
{
Name = "test-agent",
DisplayName = "Test Agent",
Description = "A test agent",
Prompt = "You are a test agent."
},
new()
{
Name = "another-agent",
DisplayName = "Another Agent",
Description = "Another test agent",
Prompt = "You are another agent."
}
};
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
var result = await session.Rpc.Agent.ListAsync();
Assert.NotNull(result.Agents);
Assert.Equal(2, result.Agents.Count);
Assert.Equal("test-agent", result.Agents[0].Name);
Assert.Equal("Test Agent", result.Agents[0].DisplayName);
Assert.Equal("A test agent", result.Agents[0].Description);
Assert.Equal("another-agent", result.Agents[1].Name);
}
[Fact]
public async Task Should_Return_Null_When_No_Agent_Is_Selected()
{
var customAgents = new List<CustomAgentConfig>
{
new()
{
Name = "test-agent",
DisplayName = "Test Agent",
Description = "A test agent",
Prompt = "You are a test agent."
}
};
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
var result = await session.Rpc.Agent.GetCurrentAsync();
Assert.Null(result.Agent);
}
[Fact]
public async Task Should_Select_And_Get_Current_Agent()
{
var customAgents = new List<CustomAgentConfig>
{
new()
{
Name = "test-agent",
DisplayName = "Test Agent",
Description = "A test agent",
Prompt = "You are a test agent."
}
};
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
// Select the agent
var selectResult = await session.Rpc.Agent.SelectAsync("test-agent");
Assert.NotNull(selectResult.Agent);
Assert.Equal("test-agent", selectResult.Agent.Name);
Assert.Equal("Test Agent", selectResult.Agent.DisplayName);
// Verify getCurrent returns the selected agent
var currentResult = await session.Rpc.Agent.GetCurrentAsync();
Assert.NotNull(currentResult.Agent);
Assert.Equal("test-agent", currentResult.Agent.Name);
}
[Fact]
public async Task Should_Deselect_Current_Agent()
{
var customAgents = new List<CustomAgentConfig>
{
new()
{
Name = "test-agent",
DisplayName = "Test Agent",
Description = "A test agent",
Prompt = "You are a test agent."
}
};
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = customAgents });
// Select then deselect
await session.Rpc.Agent.SelectAsync("test-agent");
await session.Rpc.Agent.DeselectAsync();
// Verify no agent is selected
var currentResult = await session.Rpc.Agent.GetCurrentAsync();
Assert.Null(currentResult.Agent);
}
[Fact]
public async Task Should_Return_Empty_List_When_No_Custom_Agents_Configured()
{
var session = await CreateSessionAsync();
var result = await session.Rpc.Agent.ListAsync();
Assert.Empty(result.Agents);
}
[Fact]
public async Task Should_Compact_Session_History_After_Messages()
{
var session = await CreateSessionAsync();
// Send a message to create some history
await session.SendAndWaitAsync(new MessageOptions { Prompt = "What is 2+2?" });
// Compact the session
var result = await session.Rpc.History.CompactAsync();
Assert.NotNull(result);
}
}