Skip to content

Commit 4a5d56a

Browse files
fix(server): retain task status in deferred result messages
1 parent 26cf033 commit 4a5d56a

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,16 +714,16 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
714714
const task = parent.subagents[0]!;
715715
yield* sink.write({
716716
events: [
717-
{ id: firstTaskId, result: testCase.first },
718-
{ id: secondTaskId, result: testCase.second },
719-
].map(({ id, result }) => ({
717+
{ id: firstTaskId, result: testCase.first, status: "failed" as const },
718+
{ id: secondTaskId, result: testCase.second, status: "cancelled" as const },
719+
].map(({ id, result, status }) => ({
720720
id: EventId.make(`event:inline-budget:${id}`),
721721
type: "subagent.updated" as const,
722722
threadId,
723723
runId,
724724
nodeId: id,
725725
occurredAt: now,
726-
payload: { ...task, id, result },
726+
payload: { ...task, id, result, status, title: "Inspect regression" },
727727
})),
728728
});
729729
yield* orchestrator.dispatch({
@@ -747,6 +747,10 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
747747
assert.equal(message.text.includes(testCase.first), testCase.inlineFirst);
748748
assert.equal(message.text.includes(testCase.second), testCase.inlineSecond);
749749
const deferredTaskId = testCase.inlineFirst ? secondTaskId : firstTaskId;
750+
assert.include(
751+
message.text,
752+
`Delegated task ${deferredTaskId} (Inspect regression) [${testCase.inlineFirst ? "cancelled" : "failed"}]`,
753+
);
750754
assert.include(message.text, `Use task_status with taskId ${deferredTaskId}`);
751755
assert.deepEqual(message.delegatedCompletion?.taskIds, [firstTaskId, secondTaskId]);
752756
assert.equal(

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,15 +600,16 @@ function delegatedCompletionWakeDetail(
600600
return taskIds
601601
.map((taskId) => {
602602
const task = tasks.find((candidate) => candidate.id === taskId);
603+
const label = `Delegated task ${taskId}${task?.title == null ? "" : ` (${task.title})`}${task === undefined ? " reached a terminal state" : ` [${task.status}]`}`;
603604
if (task?.result != null) {
604-
const detail = `Delegated task ${taskId}${task.title === null ? "" : ` (${task.title})`} [${task.status}]:\n${task.result}`;
605+
const detail = `${label}:\n${task.result}`;
605606
const bytes = Buffer.byteLength(detail);
606607
if (bytes <= remainingBytes) {
607608
remainingBytes -= bytes;
608609
return detail;
609610
}
610611
}
611-
return `Delegated task ${taskId} reached a terminal state. Use task_status with taskId ${taskId} to read the result.`;
612+
return `${label}. Use task_status with taskId ${taskId} to read the result.`;
612613
})
613614
.join("\n\n");
614615
}

0 commit comments

Comments
 (0)