Skip to content

Commit 9df7de0

Browse files
committed
fix(agent): allow media retry after blocked delivery
1 parent 54baa65 commit 9df7de0

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,49 @@ describe("image generation task status", () => {
227227
);
228228
});
229229

230+
it("does not use a delivery-blocked image task as a succeeded duplicate guard", () => {
231+
const now = Date.now();
232+
recordRecentMediaGenerationTaskStartForSession({
233+
sessionKey: "agent:main",
234+
taskKind: IMAGE_GENERATION_TASK_KIND,
235+
sourcePrefix: "image_generate",
236+
taskId: "task-blocked-delivery",
237+
runId: "run-blocked-delivery",
238+
taskLabel: "recent prompt",
239+
requestKey: "image-request:blocked",
240+
providerId: "xai",
241+
progressSummary: "Generating image",
242+
nowMs: now - 20_000,
243+
});
244+
taskRuntimeInternalMocks.listTasksForOwnerKey.mockReturnValue([
245+
{
246+
taskId: "task-blocked-delivery",
247+
runId: "run-blocked-delivery",
248+
runtime: "cli",
249+
taskKind: IMAGE_GENERATION_TASK_KIND,
250+
sourceId: "image_generate:xai",
251+
requesterSessionKey: "agent:main",
252+
ownerKey: "agent:main",
253+
scopeKind: "session",
254+
task: "recent prompt",
255+
status: "succeeded",
256+
terminalOutcome: "blocked",
257+
terminalSummary: "Required completion delivery failed before reaching the requester.",
258+
deliveryStatus: "not_applicable",
259+
notifyPolicy: "silent",
260+
createdAt: now - 20_000,
261+
endedAt: now - 10_000,
262+
progressSummary: "Generated 1 image",
263+
},
264+
]);
265+
266+
expect(
267+
findDuplicateGuardImageGenerationTaskForSession("agent:main", {
268+
requestKey: "image-request:blocked",
269+
}),
270+
).toBeUndefined();
271+
});
272+
230273
it("does not use a recent succeeded image task without a matching request key", () => {
231274
const now = Date.now();
232275
recordRecentMediaGenerationTaskStartForSession({

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function isTaskRecentSuccessfulDuplicate(params: {
8989
}): boolean {
9090
return (
9191
params.task.status === "succeeded" &&
92+
params.task.terminalOutcome !== "blocked" &&
9293
Boolean(params.requestKey && params.cachedRequestKey === params.requestKey) &&
9394
isRecentMediaGenerationTaskRecord({
9495
task: params.task,

0 commit comments

Comments
 (0)