Skip to content
TypeScript

perf(server): MCP calls skip the caller's message history (#28282)

Victor Vogelf5fe88bc4e02
diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts
index a8a74c3d9a3..910a1531aed 100644
--- a/apps/server/src/mcp/OrchestratorMcpService.ts
+++ b/apps/server/src/mcp/OrchestratorMcpService.ts
@@ -1119,7 +1119,6 @@ const make = Effect.gen(function* () {
const loadCaller = Effect.fn("OrchestratorMcpService.loadCaller")(function* (
scope: McpInvocationScope,
- includeUserMessages = true,
) {
yield* requireCapability(scope);
if (scope.thread === undefined) {
@@ -1128,7 +1127,8 @@ const make = Effect.gen(function* () {
limits: clientModeCeiling(scope.client),
} as const;
}
- const parent = yield* loadProjection(scope.thread.threadId, includeUserMessages);
+ // No loadCaller consumer reads the caller's own prompts.
+ const parent = yield* loadProjection(scope.thread.threadId, false);
return {
parent,
limits: {
@@ -1244,8 +1244,7 @@ const make = Effect.gen(function* () {
scope: McpInvocationScope,
threadId: ThreadId,
) {
- // Caller prompts are not used to read a timeline or acknowledge a child result.
- const { parent } = yield* loadCaller(scope, false);
+ const { parent } = yield* loadCaller(scope);
const shell = yield* threadManagement
.getThreadShell(threadId)
.pipe(Effect.mapError(threadManagementFailure));
diff --git a/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts b/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
index 2253c99f1ea..1861c3264d8 100644
--- a/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
+++ b/apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
@@ -606,14 +606,13 @@ describe("orchestrator MCP toolkit", () => {
span.end = (endTime, exit) => {
end(endTime, exit);
const query = span.attributes.get("db.query.text");
+ if (typeof query !== "string") return;
if (
- typeof query === "string" &&
/SELECT[\s\S]*FROM orchestration_v2_projection_context_transfers/i.test(query)
) {
transferReads.push(query);
}
if (
- typeof query === "string" &&
/SELECT\s+payload_json\s+FROM orchestration_v2_projection_messages/i.test(query)
) {
messageReads.push(query);
@@ -689,6 +688,13 @@ describe("orchestrator MCP toolkit", () => {
afterRead.subagents.find((task) => task.id === queuedFollowup.taskId)
?.completionDelivery?.state,
).toBe("acknowledged");
+
+ const messageReadsBeforeCapabilities = messageReads.length;
+ const capabilities = yield* invoke("orchestrator_capabilities", {}).pipe(
+ Effect.withTracer(tracer),
+ );
+ expect(capabilities.isError).not.toBe(true);
+ expect(messageReads).toHaveLength(messageReadsBeforeCapabilities);
}).pipe(Effect.provide(layerTest));
}),
),