Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions apps/server/src/mcp/McpHttpServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,34 @@ it.effect("decodes null optional arguments the way it decodes omitted ones", ()
}).pipe(Effect.provide(layerRecordingTools(calls)));
});

it.effect("decodes a JSON-stringified delegate target as the same object", () => {
const calls: Array<unknown> = [];
return Effect.gen(function* () {
const task = "Inspect";
const target = {
providerInstanceId: "codex",
model: "gpt-6.2-sol",
options: { reasoningEffort: "medium" },
};
yield* callTool("delegate_task", { task, target });
yield* callTool("delegate_task", { task, target: JSON.stringify(target) });

for (const invalidTarget of ["{model:", '{"model":42}']) {
const error = yield* Effect.flip(callTool("delegate_task", { task, target: invalidTarget }));
expect(error).toBeInstanceOf(McpSchema.InvalidParams);
}
expect(calls).toHaveLength(2);
expect(calls[0]).toEqual({
task,
target: {
...target,
options: [{ id: "reasoningEffort", value: "medium" }],
},
});
expect(calls[1]).toEqual(calls[0]);
}).pipe(Effect.provide(layerRecordingTools(calls)));
});

it.effect("rejects arguments a tool does not declare instead of dropping them", () => {
const calls: Array<unknown> = [];
return Effect.gen(function* () {
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts/src/orchestratorMcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ export type OrchestratorMcpTerminalDelegatedTaskStatus =

export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
task: OrchestratorMcpPrompt,
target: Schema.optional(OrchestratorMcpTarget),
// Some providers send the whole target object as JSON text.
target: Schema.optional(
Schema.Union([OrchestratorMcpTarget, Schema.fromJsonString(OrchestratorMcpTarget)]),
),
title: Schema.optional(OrchestratorMcpTitle),
role: Schema.optional(OrchestratorMcpTaskRole),
isolation: Schema.optional(
Expand Down
Loading