The best way to control Claude Code, Codex and more from any computer or phone
fix(mcp): t3_thread_read tells agents which thread sent a message (#18194)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Igor Makowski committed
Oct 20, 2026 at 02:15 UTC
934f91777c45e6ab94ef3d85e42c391c757176cc
3 files changed
+61
-1
apps/server/src/mcp/OrchestratorMcpService.activity.test.ts
+59
-1
@@ -28,7 +28,7 @@ import { OrchestratorDispatchError } from "../orchestration-v2/Orchestrator.ts";
28
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
29
import type * as McpInvocationContext from "./McpInvocationContext.ts";
30
import * as OrchestratorMcpService from "./OrchestratorMcpService.ts";
31
-import { liveThreadShell } from "./McpToolAccess.testkit.ts";
31
+import { idleThreadProjection, liveThreadShell } from "./McpToolAccess.testkit.ts";
32
33
const layerOrchestratorService = OrchestratorMcpService.layer.pipe(
34
Layer.provide(Layer.mock(ThreadLaunchService.ThreadLaunchService)({})),
@@ -686,3 +686,61 @@ it("sendToThread reports why the orchestrator refused the message", async () =>
686
);
687
}).pipe(Effect.provide(layer), Effect.runPromise);
688
});
689
+
690
+it("readThread exposes the stored sender thread only for thread-sent messages", async () => {
691
+ const shell = liveThreadShell(parentThreadId);
692
+ const messages = [
693
+ { id: "message-from-child", text: "Child reporting in", senderThreadId: childThreadId },
694
+ { id: "message-from-user", text: "Thanks" },
695
+ ];
696
+ const projection = {
697
+ ...idleThreadProjection(shell),
698
+ messages,
699
+ visibleTurnItems: messages.map((message, position) => ({
700
+ position,
701
+ visibility: "local",
702
+ sourceThreadId: parentThreadId,
703
+ sourceItemId: `item-${message.id}`,
704
+ item: {
705
+ id: `item-${message.id}`,
706
+ type: "user_message",
707
+ messageId: message.id,
708
+ runId: activeRunId,
709
+ status: "completed",
710
+ title: null,
711
+ text: message.text,
712
+ updatedAt: now,
713
+ },
714
+ })),
715
+ } as unknown as OrchestrationV2ThreadProjection;
716
+ const layer = layerOrchestratorService.pipe(
717
+ Layer.provide(
718
+ Layer.mergeAll(
719
+ Layer.mock(ThreadManagementService.ThreadManagementService)({
720
+ getThreadShell: () => Effect.succeed(shell),
721
+ getThreadRecords: () => Effect.succeed(projection),
722
+ getProjectThreadRecords: () => Effect.succeed(projection),
723
+ getTimelinePage: () =>
724
+ Effect.succeed({ items: projection.visibleTurnItems, totalItems: 2, hasMore: false }),
725
+ }),
726
+ ServerSettings.layerTest(),
727
+ Layer.mock(ProviderRegistry.ProviderRegistry)({ getProviders: Effect.succeed([]) }),
728
+ Layer.mock(ProjectService.ProjectService)({}),
729
+ Layer.mock(SecretRequests.SecretRequests)({}),
730
+ Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
731
+ Layer.mock(ProviderAdapterRegistry.ProviderAdapterRegistryV2)({}),
732
+ NodeCrypto.layer,
733
+ ),
734
+ ),
735
+ );
736
+
737
+ await Effect.gen(function* () {
738
+ const service = yield* OrchestratorMcpService.OrchestratorMcpService;
739
+ const result = yield* service.readThread(makeScope(), { threadId: parentThreadId });
740
+ expect(result.items).toMatchObject([
741
+ { messageId: "message-from-child", senderThreadId: childThreadId },
742
+ { messageId: "message-from-user" },
743
+ ]);
744
+ expect(result.items[1]).not.toHaveProperty("senderThreadId");
745
+ }).pipe(Effect.provide(layer), Effect.runPromise);
746
+});
apps/server/src/mcp/OrchestratorMcpService.ts
+1
@@ -915,6 +915,7 @@ function timelineItem(input: {
915
messageId,
916
createdBy: message?.createdBy ?? null,
917
creationSource: message?.creationSource ?? null,
918
+ ...(message?.senderThreadId === undefined ? {} : { senderThreadId: message.senderThreadId }),
919
type: input.row.item.type,
920
status: input.row.item.status,
921
title: input.row.item.title,
packages/contracts/src/orchestratorMcp.ts
+1
@@ -421,6 +421,7 @@ export const OrchestratorMcpThreadTimelineItem = Schema.Struct({
421
messageId: Schema.NullOr(MessageId),
422
createdBy: Schema.NullOr(OrchestrationV2Actor),
423
creationSource: Schema.NullOr(OrchestrationV2CreationSource),
424
+ senderThreadId: Schema.optional(ThreadId),
425
type: Schema.String,
426
status: OrchestrationV2TurnItemStatus,
427
title: Schema.NullOr(Schema.String),