fix(agent): allow media retry after blocked delivery

This commit is contained in:
Ayaan Zaidi
2026-05-30 00:02:06 +05:30
parent c88178d9b6
commit 1659b26151
2 changed files with 44 additions and 0 deletions

View File

@@ -227,6 +227,49 @@ describe("image generation task status", () => {
);
});
it("does not use a delivery-blocked image task as a succeeded duplicate guard", () => {
const now = Date.now();
recordRecentMediaGenerationTaskStartForSession({
sessionKey: "agent:main",
taskKind: IMAGE_GENERATION_TASK_KIND,
sourcePrefix: "image_generate",
taskId: "task-blocked-delivery",
runId: "run-blocked-delivery",
taskLabel: "recent prompt",
requestKey: "image-request:blocked",
providerId: "xai",
progressSummary: "Generating image",
nowMs: now - 20_000,
});
taskRuntimeInternalMocks.listTasksForOwnerKey.mockReturnValue([
{
taskId: "task-blocked-delivery",
runId: "run-blocked-delivery",
runtime: "cli",
taskKind: IMAGE_GENERATION_TASK_KIND,
sourceId: "image_generate:xai",
requesterSessionKey: "agent:main",
ownerKey: "agent:main",
scopeKind: "session",
task: "recent prompt",
status: "succeeded",
terminalOutcome: "blocked",
terminalSummary: "Required completion delivery failed before reaching the requester.",
deliveryStatus: "not_applicable",
notifyPolicy: "silent",
createdAt: now - 20_000,
endedAt: now - 10_000,
progressSummary: "Generated 1 image",
},
]);
expect(
findDuplicateGuardImageGenerationTaskForSession("agent:main", {
requestKey: "image-request:blocked",
}),
).toBeUndefined();
});
it("does not use a recent succeeded image task without a matching request key", () => {
const now = Date.now();
recordRecentMediaGenerationTaskStartForSession({

View File

@@ -89,6 +89,7 @@ function isTaskRecentSuccessfulDuplicate(params: {
}): boolean {
return (
params.task.status === "succeeded" &&
params.task.terminalOutcome !== "blocked" &&
Boolean(params.requestKey && params.cachedRequestKey === params.requestKey) &&
isRecentMediaGenerationTaskRecord({
task: params.task,