You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Python SDK (v0.2.2) to create multiple sessions on a single CopilotClient, each create_session(mcp_servers={...}) call spawns new stdio MCP server child processes under copilot.exe. When session.disconnect() is called (which sends session.destroy RPC), these MCP server processes are not terminated. Over many sessions, this causes hundreds of orphaned processes.
The SDK is used by Conductor to orchestrate multi-agent workflows. Each agent gets its own session with the same MCP server configuration:
client=CopilotClient()
awaitclient.start()
# Agent 1session1=awaitclient.create_session(
on_permission_request=PermissionHandler.approve_all,
mcp_servers={
"my-server": {
"command": "my-mcp-server",
"tools": ["*"],
}
}
)
response1=awaitsession1.send_and_wait("Do task 1")
awaitsession1.disconnect() # sends session.destroy RPC# Agent 2 - creates NEW mcp server processes, old ones still alivesession2=awaitclient.create_session(
on_permission_request=PermissionHandler.approve_all,
mcp_servers={
"my-server": {
"command": "my-mcp-server",
"tools": ["*"],
}
}
)
response2=awaitsession2.send_and_wait("Do task 2")
awaitsession2.disconnect() # old processes STILL alive# After N sessions: N instances of my-mcp-server running, none killedawaitclient.stop() # terminate() on copilot.exe, but children survive on Windows
Observed behavior
Using Windows process monitoring (Get-CimInstance Win32_Process):
After create_session #1: 1x my-mcp-server.exe child of copilot.exe
After session.disconnect() #1: still 1x (not killed)
One new MCP server spawned per session creation (~2 min apart matching agent turn cadence), none killed on session.destroy.
Expected behavior
When session.disconnect() / session.destroy RPC is processed by copilot.exe, all stdio MCP server child processes that were spawned for that session should be terminated.
Additionally, client.stop() → self._process.terminate() on copilot.exe should also kill all descendant processes. On Windows, Popen.terminate() calls TerminateProcess() which only kills the target process, not its children.
Summary
When using the Python SDK (v0.2.2) to create multiple sessions on a single
CopilotClient, eachcreate_session(mcp_servers={...})call spawns new stdio MCP server child processes undercopilot.exe. Whensession.disconnect()is called (which sendssession.destroyRPC), these MCP server processes are not terminated. Over many sessions, this causes hundreds of orphaned processes.Environment
github-copilot-sdk: 0.2.2copilot.exe: bundled with SDKReproduction
The SDK is used by Conductor to orchestrate multi-agent workflows. Each agent gets its own session with the same MCP server configuration:
Observed behavior
Using Windows process monitoring (
Get-CimInstance Win32_Process):create_session#1: 1xmy-mcp-server.exechild of copilot.exesession.disconnect()#1: still 1x (not killed)create_sessionFix snapshot filename collisions on case-insensitive filesystems #2: 2xmy-mcp-server.exe(new one spawned)my-mcp-server.exeunder one copilot.exeReal-world impact from a conductor workflow with 3 stdio MCP servers declared:
Timeline of child process creation under copilot.exe PID 33872:
One new MCP server spawned per session creation (~2 min apart matching agent turn cadence), none killed on session.destroy.
Expected behavior
When
session.disconnect()/session.destroyRPC is processed by copilot.exe, all stdio MCP server child processes that were spawned for that session should be terminated.Additionally,
client.stop()→self._process.terminate()on copilot.exe should also kill all descendant processes. On Windows,Popen.terminate()callsTerminateProcess()which only kills the target process, not its children.SDK source references
copilot/client.py:1183—create_session()acceptsmcp_serversparametercopilot/client.py:1355— MCP servers sent asmcpServersin JSON-RPC payloadcopilot/session.py:1835—disconnect()sendssession.destroyRPCcopilot/client.py:1117-1123—stop()callsterminate()thenwait(5)thenkill()Suggested fix
session.destroyRPC, copilot.exe should terminate all stdio MCP server processes spawned for that sessionclient.stop()should use a Job Object or enumerate+kill descendant processes rather than justterminate()on copilot.exeWorkaround
Currently using a periodic cleanup watchdog script that kills accumulated MCP server children.