Skip to content

Commit 49063b7

Browse files
stephentoubCopilot
andcommitted
Make agent reload test runtime-compatible
Use a unique reload agent name and assert reload results match the subsequent list result instead of depending on whether the runtime preserves session-configured agents after reload. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ad0a9aa commit 49063b7

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

dotnet/test/E2E/RpcAgentE2ETests.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------------------------------------------*/
44

5+
using GitHub.Copilot.SDK.Rpc;
56
using GitHub.Copilot.SDK.Test.Harness;
67
using Xunit;
78
using Xunit.Abstractions;
@@ -104,10 +105,11 @@ public async Task Should_Return_Empty_List_When_No_Custom_Agents_Configured()
104105
[Fact]
105106
public async Task Should_Call_Agent_Reload()
106107
{
107-
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = [CreateReloadAgent()] });
108+
var reloadAgent = CreateReloadAgent($"reload-test-agent-{Guid.NewGuid():N}");
109+
var session = await CreateSessionAsync(new SessionConfig { CustomAgents = [reloadAgent] });
108110

109111
var before = await session.Rpc.Agent.ListAsync();
110-
Assert.Single(before.Agents, agent => string.Equals(agent.Name, "reload-test-agent", StringComparison.Ordinal));
112+
AssertReloadAgent(before.Agents, reloadAgent);
111113

112114
var result = await session.Rpc.Agent.ReloadAsync();
113115
var current = await session.Rpc.Agent.ListAsync();
@@ -120,6 +122,13 @@ public async Task Should_Call_Agent_Reload()
120122
current.Agents.Select(agent => agent.DisplayName).OrderBy(name => name, StringComparer.Ordinal));
121123
}
122124

125+
private static void AssertReloadAgent(IEnumerable<AgentInfo> agents, CustomAgentConfig expected)
126+
{
127+
var agent = Assert.Single(agents, agent => string.Equals(agent.Name, expected.Name, StringComparison.Ordinal));
128+
Assert.Equal(expected.DisplayName, agent.DisplayName);
129+
Assert.Equal(expected.Description, agent.Description);
130+
}
131+
123132
private static List<CustomAgentConfig> CreateCustomAgents() =>
124133
[
125134
new()
@@ -138,10 +147,10 @@ private static List<CustomAgentConfig> CreateCustomAgents() =>
138147
}
139148
];
140149

141-
private static CustomAgentConfig CreateReloadAgent() =>
150+
private static CustomAgentConfig CreateReloadAgent(string name) =>
142151
new()
143152
{
144-
Name = "reload-test-agent",
153+
Name = name,
145154
DisplayName = "Reload Test Agent",
146155
Description = "Used by the agent reload RPC test.",
147156
Prompt = "You are a reload test agent.",

0 commit comments

Comments
 (0)