The best way to control Claude Code, Codex and more from any computer or phone
fix(server): Copilot MCP calls and glob searches keep their identity (#38349)
Julius Marminge committed
Nov 17, 2026 at 14:23 UTC
73e62fcecc5e07de840e2b03a8efd9c45cbe52cf
2 files changed
+153
-3
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
+103
@@ -1997,6 +1997,109 @@ describe("AcpRegistryAdapterV2", () => {
1997
}).pipe(Effect.provide(layerTest)),
1998
);
1999
2000
+ // Copilot flattens MCP titles and reports kind "read" for MCP calls and glob; its native
2001
+ // tool.execution_start event carries the real identity.
2002
+ it.effect("keeps Copilot's MCP and search tool identity instead of calling them file reads", () =>
2003
+ Effect.gen(function* () {
2004
+ const sessionId = "copilot-session";
2005
+ const executionStart = (data: Record<string, unknown>) => ({
2006
+ type: "emit_inbound",
2007
+ frame: {
2008
+ kind: "notification",
2009
+ method: "github.com/copilot/sessionEvent",
2010
+ params: { sessionId, type: "tool.execution_start", data },
2011
+ },
2012
+ });
2013
+ const update = (sessionUpdate: Record<string, unknown>) =>
2014
+ claudeFrames.update(sessionId, sessionUpdate);
2015
+ const session = yield* openClaudeReplaySession(
2016
+ [
2017
+ {
2018
+ type: "expect_outbound",
2019
+ frame: { kind: "request", method: "initialize", params: "<any>" },
2020
+ },
2021
+ {
2022
+ type: "emit_inbound",
2023
+ frame: {
2024
+ kind: "response",
2025
+ method: "initialize",
2026
+ result: {
2027
+ protocolVersion: 1,
2028
+ agentInfo: { name: "Copilot", version: "1.0.112" },
2029
+ agentCapabilities: { loadSession: true },
2030
+ authMethods: [],
2031
+ },
2032
+ },
2033
+ },
2034
+ {
2035
+ type: "expect_outbound",
2036
+ frame: { kind: "request", method: "session/new", params: "<any>" },
2037
+ },
2038
+ {
2039
+ type: "emit_inbound",
2040
+ frame: { kind: "response", method: "session/new", result: { sessionId } },
2041
+ },
2042
+ {
2043
+ type: "expect_outbound",
2044
+ frame: { kind: "request", method: "session/prompt", params: "<any>" },
2045
+ },
2046
+ executionStart({
2047
+ toolCallId: "mcp-call",
2048
+ mcpServerName: "demo-library",
2049
+ mcpToolName: "search_books",
2050
+ }),
2051
+ update({
2052
+ sessionUpdate: "tool_call",
2053
+ toolCallId: "mcp-call",
2054
+ title: "demo-library-search_books",
2055
+ kind: "read",
2056
+ status: "completed",
2057
+ rawInput: { arguments: { query: "paper airplanes" }, limit: 2 },
2058
+ }),
2059
+ executionStart({
2060
+ toolCallId: "native-search",
2061
+ toolName: "glob",
2062
+ toolTitle: "Finding files",
2063
+ arguments: { pattern: "*.ts", paths: ["/workspace"] },
2064
+ }),
2065
+ update({
2066
+ sessionUpdate: "tool_call",
2067
+ toolCallId: "native-search",
2068
+ title: "Finding files matching *.ts",
2069
+ kind: "read",
2070
+ status: "completed",
2071
+ rawInput: { pattern: "*.ts", paths: ["/workspace"] },
2072
+ locations: [{ path: "/workspace" }],
2073
+ }),
2074
+ update({ sessionUpdate: "session_info_update", title: "after tools" }),
2075
+ ],
2076
+ undefined,
2077
+ false,
2078
+ "github-copilot-cli",
2079
+ );
2080
+ yield* session.runtime.startTurn(session.turnInput(1));
2081
+ const events = yield* session.throughMarker("after tools");
2082
+ const lastItem = (nativeId: string) =>
2083
+ events
2084
+ .flatMap((event) =>
2085
+ event.type === "turn_item.updated" &&
2086
+ event.turnItem.nativeItemRef?.nativeId === nativeId
2087
+ ? [event.turnItem]
2088
+ : [],
2089
+ )
2090
+ .at(-1);
2091
+ const mcp = lastItem("mcp-call");
2092
+ const search = lastItem("native-search");
2093
+ assert.deepEqual(
2094
+ {
2095
+ mcp: mcp?.type === "dynamic_tool" ? mcp.toolName : mcp?.type,
2096
+ search: search?.type === "dynamic_tool" ? search.toolName : search?.type,
2097
+ },
2098
+ { mcp: "demo-library.search_books", search: "file_search" },
2099
+ );
2100
+ }).pipe(Effect.provide(layerTest)),
2101
+ );
2102
+
2103
it.effect.each([
2104
{ kind: "approval", stopReason: "end_turn", status: "completed" },
2105
{ kind: "question", stopReason: "error", status: "failed" },
packages/provider-acp-registry/src/server/copilotAcp.ts
+50
-3
@@ -24,6 +24,7 @@ export const copilotClientCapabilitiesMeta = {
24
"session.compaction_complete",
25
"assistant.turn_start",
26
"assistant.idle",
27
+ "tool.execution_start",
28
],
29
},
30
};
@@ -63,9 +64,26 @@ function record(value: unknown): Record<string, unknown> | undefined {
64
65
const childSessionId = (taskToolCallId: string) => `copilot-task:${taskToolCallId}`;
66
67
+// Copilot's tool_call reports MCP calls and glob/grep as kind "read" under a flattened title.
68
+type CopilotToolIdentity =
69
+ | { readonly kind: "mcp"; readonly server: string; readonly tool: string }
70
+ | { readonly kind: "search" };
71
+
72
+const COPILOT_SEARCH_TOOLS = new Set(["glob", "grep"]);
73
+
74
interface CopilotSessionAttribution {
75
delta: { readonly kind: string; readonly text: string; readonly task?: string } | undefined;
76
readonly taskByAgentId: Map<string, string>;
77
+ readonly toolIdentityByCallId: Map<string, CopilotToolIdentity>;
78
+}
79
+
80
+function copilotToolIdentity(data: Record<string, unknown>): CopilotToolIdentity | undefined {
81
+ const server = typeof data.mcpServerName === "string" ? data.mcpServerName.trim() : "";
82
+ const tool = typeof data.mcpToolName === "string" ? data.mcpToolName.trim() : "";
83
+ if (server.length > 0 && tool.length > 0) return { kind: "mcp", server, tool };
84
+ return typeof data.toolName === "string" && COPILOT_SEARCH_TOOLS.has(data.toolName)
85
+ ? { kind: "search" }
86
+ : undefined;
87
}
88
89
export function makeCopilotSubagentRouting() {
@@ -73,13 +91,17 @@ export function makeCopilotSubagentRouting() {
91
const session = (sessionId: string) => {
92
let current = sessions.get(sessionId);
93
if (current === undefined) {
76
- current = { delta: undefined, taskByAgentId: new Map() };
94
+ current = { delta: undefined, taskByAgentId: new Map(), toolIdentityByCallId: new Map() };
95
sessions.set(sessionId, current);
96
}
97
return current;
98
};
99
const release = (sessionId: string, current: CopilotSessionAttribution) => {
82
- if (current.delta === undefined && current.taskByAgentId.size === 0) {
100
+ if (
101
+ current.delta === undefined &&
102
+ current.taskByAgentId.size === 0 &&
103
+ current.toolIdentityByCallId.size === 0
104
+ ) {
105
sessions.delete(sessionId);
106
}
107
};
@@ -105,6 +127,13 @@ export function makeCopilotSubagentRouting() {
127
}
128
return Effect.void;
129
}
130
+ case "tool.execution_start": {
131
+ const identity = copilotToolIdentity(data);
132
+ if (identity !== undefined && typeof data.toolCallId === "string") {
133
+ session(event.sessionId).toolIdentityByCallId.set(data.toolCallId, identity);
134
+ }
135
+ return Effect.void;
136
+ }
137
case "subagent.completed":
138
case "subagent.failed": {
139
const current = sessions.get(event.sessionId);
@@ -154,6 +183,7 @@ export function makeCopilotSubagentRouting() {
183
const current = sessions.get(notification.sessionId);
184
if (current === undefined) return notification;
185
let task: string | undefined;
186
+ let normalized = notification;
187
if (
188
update.sessionUpdate === "agent_message_chunk" ||
189
update.sessionUpdate === "agent_thought_chunk"
@@ -178,8 +208,25 @@ export function makeCopilotSubagentRouting() {
208
) {
209
const agentId = record(record(update._meta)?.[COPILOT_META_KEY])?.agentId;
210
task = typeof agentId === "string" ? current.taskByAgentId.get(agentId) : undefined;
211
+ const identity = current.toolIdentityByCallId.get(update.toolCallId);
212
+ if (identity !== undefined) {
213
+ if (update.status === "completed" || update.status === "failed") {
214
+ current.toolIdentityByCallId.delete(update.toolCallId);
215
+ release(notification.sessionId, current);
216
+ }
217
+ normalized = {
218
+ ...notification,
219
+ update:
220
+ identity.kind === "search"
221
+ ? { ...update, kind: "search" }
222
+ : {
223
+ ...update,
224
+ _meta: { ...update._meta, serverId: identity.server, toolName: identity.tool },
225
+ },
226
+ };
227
+ }
228
}
182
- return task === undefined ? notification : { ...notification, sessionId: childSessionId(task) };
229
+ return task === undefined ? normalized : { ...normalized, sessionId: childSessionId(task) };
230
};
231
232
return { registerExtensions, normalizeSessionUpdate };