Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions apps/server/src/mcp/OrchestratorMcpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,13 +1201,19 @@ const make = Effect.gen(function* () {
`Thread ${threadId} is no longer available.`,
);
}
const target = yield* threadManagement
.getProjectThreadRecords({ projectId: shell.projectId, threadId }, [
"runs",
"runtimeRequests",
"contextTransfers",
])
.pipe(Effect.mapError(threadManagementFailure));
const input = { projectId: shell.projectId, threadId };
// Transfers are needed only to acknowledge a caller's child-task result.
const records =
parent === undefined
? threadManagement
.getProjectThreadRecords(input, ["runs", "runtimeRequests"])
.pipe(Effect.map((target) => ({ ...target, contextTransfers: [] })))
: threadManagement.getProjectThreadRecords(input, [
"runs",
"runtimeRequests",
"contextTransfers",
]);
const target = yield* records.pipe(Effect.mapError(threadManagementFailure));
return { parent, target, shell } as const;
});

Expand Down
22 changes: 17 additions & 5 deletions apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as NodeURL from "node:url";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { describe, expect, it } from "@effect/vitest";
import {
Expand Down Expand Up @@ -96,9 +97,7 @@ const readDelegatedTaskStatusTranscript = Effect.fn("readDelegatedTaskStatusTran
followupResult: string,
) {
const fs = yield* FileSystem.FileSystem;
const text = yield* fs.readFileString(
decodeURIComponent(delegatedTaskStatusTranscriptFile.pathname),
);
const text = yield* fs.readFileString(NodeURL.fileURLToPath(delegatedTaskStatusTranscriptFile));
const transcript = yield* decodeProviderReplayNdjson(
text.replaceAll(queuedFollowupResult, followupResult),
);
Expand Down Expand Up @@ -315,11 +314,11 @@ describe("orchestrator MCP toolkit", () => {
capabilities: new Set(["orchestration"]),
issuedAt: 1,
};
const invoke = (name: string, args: Record<string, unknown>) =>
const invoke = (name: string, args: Record<string, unknown>, scope = invocation) =>
server
.callTool({ name, arguments: args })
.pipe(
Effect.provideService(McpInvocationContext.McpInvocationContext, invocation),
Effect.provideService(McpInvocationContext.McpInvocationContext, scope),
Effect.provideService(McpSchema.McpServerClient, client),
);

Expand Down Expand Up @@ -596,11 +595,24 @@ describe("orchestrator MCP toolkit", () => {
expect(finalStatus.latestTerminalResultContextTransferId).not.toBe(
delegated.resultContextTransferId,
);
const parentlessRead = yield* invoke(
"t3_thread_read",
{ threadId: delegated.childThreadId, limit: 100 },
{ ...invocation, thread: undefined },
);
expect(parentlessRead.isError).not.toBe(true);
const afterParentlessRead = yield* orchestrator.getThreadProjection(parentThreadId);
expect(
afterParentlessRead.subagents.find((task) => task.id === queuedFollowup.taskId)
?.completionDelivery?.state,
).toBe("claimed");

const read = yield* invoke("t3_thread_read", {
threadId: delegated.childThreadId,
limit: 100,
});
expect(read.isError).not.toBe(true);
expect(read.structuredContent).toEqual(parentlessRead.structuredContent);
const afterRead = yield* orchestrator.getThreadProjection(parentThreadId);
expect(
afterRead.subagents.find((task) => task.id === queuedFollowup.taskId)
Expand Down
Loading