Skip to content

Commit 812d8e0

Browse files
TonybynMp4claude
andcommitted
fix(server): read a subagent-created task's subject from its result
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bcacbaa commit 812d8e0

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4457,7 +4457,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
44574457
assert.equal(new Set(plans.map((plan) => plan.id)).size, 1);
44584458
assert.deepEqual(plans.at(-1)?.steps, [
44594459
{ id: "task-1", text: "Main task", status: "completed" },
4460-
{ id: "task-2", text: "Requested Child task", status: "pending" },
4460+
{ id: "task-2", text: "Child task", status: "pending" },
44614461
]);
44624462
}).pipe(
44634463
Effect.scoped,

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,8 +3293,12 @@ function applyClaudeTaskTool(
32933293
}
32943294
if (toolName === "TaskCreate") {
32953295
const created = claudeTaskField(result, "task");
3296-
const id = claudeTaskString(created, "id") ?? claudeCreatedTaskIdFromText(result);
3297-
const text = claudeTaskString(created, "subject") ?? claudeTaskString(input, "subject");
3296+
const fromText = claudeCreatedTaskFromText(result);
3297+
const id = claudeTaskString(created, "id") ?? fromText?.id;
3298+
const text =
3299+
claudeTaskString(created, "subject") ??
3300+
fromText?.subject ??
3301+
claudeTaskString(input, "subject");
32983302
if (id === undefined || text === undefined) return undefined;
32993303
return new Map(tasks).set(id, { text, status: "pending" });
33003304
}
@@ -3318,10 +3322,12 @@ function applyClaudeTaskTool(
33183322

33193323
// Subagent results carry no structured `tool_use_result`, only the text
33203324
// "Task #3 created successfully: <subject>".
3321-
function claudeCreatedTaskIdFromText(result: unknown): string | undefined {
3322-
return typeof result === "string"
3323-
? /^Task #(\S+) created successfully/.exec(result)?.[1]
3324-
: undefined;
3325+
function claudeCreatedTaskFromText(
3326+
result: unknown,
3327+
): { readonly id: string; readonly subject: string } | undefined {
3328+
const match =
3329+
typeof result === "string" ? /^Task #(\S+) created successfully: (.+)$/s.exec(result) : null;
3330+
return match === null ? undefined : { id: match[1]!, subject: match[2]!.trim() };
33253331
}
33263332

33273333
function claudeTaskSteps(tasks: ClaudeTaskList): ReadonlyArray<OrchestrationV2PlanStep> {

0 commit comments

Comments
 (0)