Skip to content

Commit 852ea51

Browse files
stephentoubCopilot
andcommitted
Add Node agent reload E2E coverage
Add the Node.js counterpart for the runtime-compatible agent reload RPC test, including a unique agent name and reload/list consistency assertion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bfcef14 commit 852ea51

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

nodejs/test/e2e/agent_and_compact_rpc.e2e.test.ts

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

5+
import { randomUUID } from "node:crypto";
56
import { describe, expect, it } from "vitest";
67
import { approveAll } from "../../src/index.js";
78
import type { CustomAgentConfig } from "../../src/index.js";
@@ -127,6 +128,34 @@ describe("Agent Selection RPC", async () => {
127128

128129
await session.disconnect();
129130
});
131+
132+
it("should call agent reload", async () => {
133+
const reloadAgent: CustomAgentConfig = {
134+
name: `reload-test-agent-${randomUUID().replaceAll("-", "")}`,
135+
displayName: "Reload Test Agent",
136+
description: "Used by the agent reload RPC test.",
137+
prompt: "You are a reload test agent.",
138+
};
139+
140+
const session = await client.createSession({
141+
onPermissionRequest: approveAll,
142+
customAgents: [reloadAgent],
143+
});
144+
145+
const before = await session.rpc.agent.list();
146+
const match = before.agents.find((agent) => agent.name === reloadAgent.name);
147+
expect(match).toBeDefined();
148+
expect(match!.displayName).toBe(reloadAgent.displayName);
149+
expect(match!.description).toBe(reloadAgent.description);
150+
151+
const result = await session.rpc.agent.reload();
152+
expect(result.agents).toBeDefined();
153+
154+
const current = await session.rpc.agent.list();
155+
expect(summarizeAgents(result.agents)).toEqual(summarizeAgents(current.agents));
156+
157+
await session.disconnect();
158+
});
130159
});
131160

132161
describe("Session Compact RPC", async () => {
@@ -147,3 +176,7 @@ describe("Session Compact RPC", async () => {
147176
await session.disconnect();
148177
}, 60000);
149178
});
179+
180+
function summarizeAgents(agents: { name: string; displayName: string }[]) {
181+
return agents.map((agent) => `${agent.name}\x00${agent.displayName}`).sort();
182+
}

0 commit comments

Comments
 (0)