Skip to content

Commit f83e3bf

Browse files
Fix media completion duplicate delivery
1 parent 903f5cb commit f83e3bf

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎src/agents/image-generation-task-status.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ describe("image generation task status", () => {
218218
});
219219

220220
expect(task?.taskId).toBe("task-completed");
221-
expect(buildImageGenerationTaskStatusText(task!, { duplicateGuard: true })).toContain(
221+
const statusText = buildImageGenerationTaskStatusText(task!, { duplicateGuard: true });
222+
expect(statusText).toContain(
222223
"Image generation task task-completed recently succeeded with xai.",
223224
);
225+
expect(statusText).toContain(
226+
"Do not call image_generate again for the same request; this recent image generation already completed.",
227+
);
224228
});
225229

226230
it("does not use a recent succeeded image task without a matching request key", () => {

‎src/agents/media-generation-task-status-shared.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ export function buildMediaGenerationTaskStatusText(params: {
403403
: `${params.nounLabel} task ${params.task.taskId} recently ${params.task.status}${provider ? ` with ${provider}` : ""}.`,
404404
params.task.progressSummary ? `Progress: ${params.task.progressSummary}.` : null,
405405
params.duplicateGuard
406-
? `Do not call ${params.toolName} again for this request. Wait for the completion event; the completion agent will send the finished ${params.completionLabel} here.`
406+
? active
407+
? `Do not call ${params.toolName} again for this request. Wait for the completion event; the completion agent will send the finished ${params.completionLabel} here.`
408+
: `Do not call ${params.toolName} again for the same request; this recent ${params.completionLabel} generation already completed.`
407409
: `Wait for the completion event; the completion agent will send the finished ${params.completionLabel} here when it's ready.`,
408410
].filter((entry): entry is string => Boolean(entry));
409411
return lines.join("\n");

‎src/agents/tools/music-generate-tool.status.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ describe("createMusicGenerateTool status actions", () => {
187187
const text = (result?.content?.[0] as { text: string } | undefined)?.text ?? "";
188188

189189
expect(text).toContain("Music generation task task-recent-music recently succeeded");
190+
expect(text).toContain(
191+
"Do not call music_generate again for the same request; this recent music generation already completed.",
192+
);
190193
expect(result?.details?.duplicateGuard).toBe(true);
191194
expect(result?.details?.active).toBe(false);
192195
});

‎src/agents/tools/video-generate-tool.status.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ describe("createVideoGenerateTool status actions", () => {
187187
const text = (result?.content?.[0] as { text: string } | undefined)?.text ?? "";
188188

189189
expect(text).toContain("Video generation task task-recent-video recently succeeded");
190+
expect(text).toContain(
191+
"Do not call video_generate again for the same request; this recent video generation already completed.",
192+
);
190193
expect(result?.details?.duplicateGuard).toBe(true);
191194
expect(result?.details?.active).toBe(false);
192195
});

0 commit comments

Comments
 (0)