The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 08:30 UTC
fix(server): recover JSON-stringified delegate targets (#38436)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
MINIlaolao committed
Nov 18, 2026 at 12:49 UTC
5b6f7c81ce5de290a9cd586cb568f0c9fe57d26a
2 files changed
+32
-1
apps/server/src/mcp/McpHttpServer.test.ts
+28
@@ -680,6 +680,34 @@ it.effect("decodes null optional arguments the way it decodes omitted ones", ()
680
}).pipe(Effect.provide(layerRecordingTools(calls)));
681
});
682
683
+it.effect("decodes a JSON-stringified delegate target as the same object", () => {
684
+ const calls: Array<unknown> = [];
685
+ return Effect.gen(function* () {
686
+ const task = "Inspect";
687
+ const target = {
688
+ providerInstanceId: "codex",
689
+ model: "gpt-6.2-sol",
690
+ options: { reasoningEffort: "medium" },
691
+ };
692
+ yield* callTool("delegate_task", { task, target });
693
+ yield* callTool("delegate_task", { task, target: JSON.stringify(target) });
694
+
695
+ for (const invalidTarget of ["{model:", '{"model":42}']) {
696
+ const error = yield* Effect.flip(callTool("delegate_task", { task, target: invalidTarget }));
697
+ expect(error).toBeInstanceOf(McpSchema.InvalidParams);
698
+ }
699
+ expect(calls).toHaveLength(2);
700
+ expect(calls[0]).toEqual({
701
+ task,
702
+ target: {
703
+ ...target,
704
+ options: [{ id: "reasoningEffort", value: "medium" }],
705
+ },
706
+ });
707
+ expect(calls[1]).toEqual(calls[0]);
708
+ }).pipe(Effect.provide(layerRecordingTools(calls)));
709
+});
710
+
711
it.effect("rejects arguments a tool does not declare instead of dropping them", () => {
712
const calls: Array<unknown> = [];
713
return Effect.gen(function* () {
packages/contracts/src/orchestratorMcp.ts
+4
-1
@@ -170,7 +170,10 @@ export type OrchestratorMcpTerminalDelegatedTaskStatus =
170
171
export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
172
task: OrchestratorMcpPrompt,
173
- target: Schema.optional(OrchestratorMcpTarget),
173
+ // Some providers send the whole target object as JSON text.
174
+ target: Schema.optional(
175
+ Schema.Union([OrchestratorMcpTarget, Schema.fromJsonString(OrchestratorMcpTarget)]),
176
+ ),
177
title: Schema.optional(OrchestratorMcpTitle),
178
role: Schema.optional(OrchestratorMcpTaskRole),
179
isolation: Schema.optional(