Skip to content

Commit cbf32de

Browse files
committed
fix(media): preserve prompt-aware duplicate guards
1 parent 48ffd78 commit cbf32de

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { TaskRecord } from "../tasks/task-registry.types.js";
33
import {
44
buildActiveMediaGenerationTaskPromptContextForSession,
55
findActiveMediaGenerationTaskForSession,
6+
findDuplicateGuardMediaGenerationTaskForSession,
67
listActiveMediaGenerationTasksForSession,
78
MEDIA_GENERATION_DELIVERING_COMPLETION_PROGRESS,
89
resetRecentMediaGenerationDuplicateGuardsForTests,
@@ -95,4 +96,31 @@ describe("media generation delivery-phase prompt guard", () => {
9596
}),
9697
).toEqual(task);
9798
});
99+
100+
it("blocks the same prompt while allowing a distinct prompt", () => {
101+
const task = makeTask({
102+
task: "generate clip 01",
103+
progressSummary: MEDIA_GENERATION_DELIVERING_COMPLETION_PROGRESS,
104+
});
105+
taskRuntimeInternalMocks.listFreshTasksForOwnerKey.mockReturnValue([task]);
106+
107+
expect(
108+
findDuplicateGuardMediaGenerationTaskForSession({
109+
sessionKey: "session/A",
110+
taskKind: "video-generate",
111+
sourcePrefix: "video-generate",
112+
taskLabel: "generate clip 01",
113+
maxAgeMs: 120_000,
114+
}),
115+
).toEqual(task);
116+
expect(
117+
findDuplicateGuardMediaGenerationTaskForSession({
118+
sessionKey: "session/A",
119+
taskKind: "video-generate",
120+
sourcePrefix: "video-generate",
121+
taskLabel: "generate clip 02",
122+
maxAgeMs: 120_000,
123+
}),
124+
).toBeUndefined();
125+
});
98126
});

src/agents/tools/music-generate-tool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ export function createMusicGenerateTool(options?: {
646646

647647
const activeDuplicateGuardResult = createMusicGenerateDuplicateGuardResult(
648648
options?.agentSessionKey,
649+
{ prompt },
649650
);
650651
if (activeDuplicateGuardResult) {
651652
return activeDuplicateGuardResult;
@@ -703,7 +704,7 @@ export function createMusicGenerateTool(options?: {
703704
});
704705
const duplicateGuardResult = createMusicGenerateDuplicateGuardResult(
705706
options?.agentSessionKey,
706-
{ requestKey },
707+
{ prompt, requestKey },
707708
);
708709
if (duplicateGuardResult) {
709710
return duplicateGuardResult;

src/agents/tools/video-generate-tool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ export function createVideoGenerateTool(options?: {
10051005

10061006
const activeDuplicateGuardResult = createVideoGenerateDuplicateGuardResult(
10071007
options?.agentSessionKey,
1008+
{ prompt },
10081009
);
10091010
if (activeDuplicateGuardResult) {
10101011
return activeDuplicateGuardResult;
@@ -1113,7 +1114,7 @@ export function createVideoGenerateTool(options?: {
11131114
});
11141115
const duplicateGuardResult = createVideoGenerateDuplicateGuardResult(
11151116
options?.agentSessionKey,
1116-
{ requestKey },
1117+
{ prompt, requestKey },
11171118
);
11181119
if (duplicateGuardResult) {
11191120
return duplicateGuardResult;

0 commit comments

Comments
 (0)