Skip to content

Commit 34e3a2b

Browse files
authored
Add real Copilot SDK integration tests for agent host protocol (#310372)
* Add real Copilot SDK integration tests for agent host protocol Add integration tests that exercise the agent host protocol server against the real Copilot SDK (gated behind AGENT_HOST_REAL_SDK=1 env var). Tests cover: - Simple message round-trip - Tool call permission request flow - Turn abort - Working directory correctness via sessionAdded notification and subscribe snapshot - Worktree isolation: verifies the resolved worktree path survives a session refresh triggered by tool changes (activeClientChanged) Also adds a startRealServer() helper to testHelpers.ts for launching the server without a mock agent. (Written by Copilot) * Address Copilot review: fix URIs, timeouts, temp dir cleanup, git identity - Fix invalid file URIs: use URI.file() instead of string interpolation - Add 30s timeouts to authenticate/createSession calls in helper - Use real temp dirs for permission test instead of hard-coded path - Move temp dir cleanup to teardown via tempDirs tracking array - Configure git user.name/email in worktree test for portability - Remove forbidden 'path' import (ESLint layer restriction) - Fix JSDoc on startRealServer() removing incorrect GITHUB_TOKEN mention (Written by Copilot)
1 parent 1f63695 commit 34e3a2b

File tree

2 files changed

+419
-0
lines changed

2 files changed

+419
-0
lines changed

src/vs/platform/agentHost/test/node/protocol/testHelpers.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,48 @@ export async function startServer(options?: { readonly quiet?: boolean }): Promi
217217
});
218218
}
219219

220+
/**
221+
* Start the agent host server with the real Copilot SDK agent (no mock agent).
222+
* The server is started with logging enabled so the CopilotAgent is registered.
223+
*/
224+
export async function startRealServer(): Promise<IServerHandle> {
225+
return new Promise((resolve, reject) => {
226+
const serverPath = fileURLToPath(new URL('../../../node/agentHostServerMain.js', import.meta.url));
227+
const args = ['--port', '0', '--without-connection-token'];
228+
const child = fork(serverPath, args, {
229+
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
230+
});
231+
232+
const timer = setTimeout(() => {
233+
child.kill();
234+
reject(new Error('Real server startup timed out'));
235+
}, 30_000);
236+
237+
child.stdout!.on('data', (data: Buffer) => {
238+
const text = data.toString();
239+
const match = text.match(/READY:(\d+)/);
240+
if (match) {
241+
clearTimeout(timer);
242+
resolve({ process: child, port: parseInt(match[1], 10) });
243+
}
244+
});
245+
246+
child.stderr!.on('data', () => {
247+
// Intentionally swallowed - the test runner fails if console.error is used.
248+
});
249+
250+
child.on('error', err => {
251+
clearTimeout(timer);
252+
reject(err);
253+
});
254+
255+
child.on('exit', code => {
256+
clearTimeout(timer);
257+
reject(new Error(`Real server exited prematurely with code ${code}`));
258+
});
259+
});
260+
}
261+
220262
// ---- Helpers ----------------------------------------------------------------
221263

222264
let sessionCounter = 0;

0 commit comments

Comments
 (0)