Skip to content

Commit f5fe88b

Browse files
only21milclaudemaria-rcks
authored
perf(server): MCP calls skip the caller's message history (#28282)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent ede41df commit f5fe88b

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,6 @@ const make = Effect.gen(function* () {
11191119

11201120
const loadCaller = Effect.fn("OrchestratorMcpService.loadCaller")(function* (
11211121
scope: McpInvocationScope,
1122-
includeUserMessages = true,
11231122
) {
11241123
yield* requireCapability(scope);
11251124
if (scope.thread === undefined) {
@@ -1128,7 +1127,8 @@ const make = Effect.gen(function* () {
11281127
limits: clientModeCeiling(scope.client),
11291128
} as const;
11301129
}
1131-
const parent = yield* loadProjection(scope.thread.threadId, includeUserMessages);
1130+
// No loadCaller consumer reads the caller's own prompts.
1131+
const parent = yield* loadProjection(scope.thread.threadId, false);
11321132
return {
11331133
parent,
11341134
limits: {
@@ -1244,8 +1244,7 @@ const make = Effect.gen(function* () {
12441244
scope: McpInvocationScope,
12451245
threadId: ThreadId,
12461246
) {
1247-
// Caller prompts are not used to read a timeline or acknowledge a child result.
1248-
const { parent } = yield* loadCaller(scope, false);
1247+
const { parent } = yield* loadCaller(scope);
12491248
const shell = yield* threadManagement
12501249
.getThreadShell(threadId)
12511250
.pipe(Effect.mapError(threadManagementFailure));

‎apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,13 @@ describe("orchestrator MCP toolkit", () => {
606606
span.end = (endTime, exit) => {
607607
end(endTime, exit);
608608
const query = span.attributes.get("db.query.text");
609+
if (typeof query !== "string") return;
609610
if (
610-
typeof query === "string" &&
611611
/SELECT[\s\S]*FROM orchestration_v2_projection_context_transfers/i.test(query)
612612
) {
613613
transferReads.push(query);
614614
}
615615
if (
616-
typeof query === "string" &&
617616
/SELECT\s+payload_json\s+FROM orchestration_v2_projection_messages/i.test(query)
618617
) {
619618
messageReads.push(query);
@@ -689,6 +688,13 @@ describe("orchestrator MCP toolkit", () => {
689688
afterRead.subagents.find((task) => task.id === queuedFollowup.taskId)
690689
?.completionDelivery?.state,
691690
).toBe("acknowledged");
691+
692+
const messageReadsBeforeCapabilities = messageReads.length;
693+
const capabilities = yield* invoke("orchestrator_capabilities", {}).pipe(
694+
Effect.withTracer(tracer),
695+
);
696+
expect(capabilities.isError).not.toBe(true);
697+
expect(messageReads).toHaveLength(messageReadsBeforeCapabilities);
692698
}).pipe(Effect.provide(layerTest));
693699
}),
694700
),

0 commit comments

Comments
 (0)