fix(discord): add media dedup production code for messaging tool pipeline

Wire media URL tracking through the embedded agent pipeline so that
media already sent via messaging tools is not delivered again by the
reply dispatcher.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Yaroslav Boiko
2026-02-16 20:41:41 +01:00
committed by Peter Steinberger
parent c7681c3cff
commit 838259331f
14 changed files with 244 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ export function makeAttemptResult(
messagesSnapshot: [],
didSendViaMessagingTool: false,
messagingToolSentTexts: [],
messagingToolSentMediaUrls: [],
messagingToolSentTargets: [],
cloudCodeAssistFormatError: false,
...overrides,

View File

@@ -980,6 +980,7 @@ export async function runEmbeddedPiAgent(
},
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
messagingToolSentTexts: attempt.messagingToolSentTexts,
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
messagingToolSentTargets: attempt.messagingToolSentTargets,
successfulCronAdds: attempt.successfulCronAdds,
};
@@ -1022,6 +1023,7 @@ export async function runEmbeddedPiAgent(
},
didSendViaMessagingTool: attempt.didSendViaMessagingTool,
messagingToolSentTexts: attempt.messagingToolSentTexts,
messagingToolSentMediaUrls: attempt.messagingToolSentMediaUrls,
messagingToolSentTargets: attempt.messagingToolSentTargets,
successfulCronAdds: attempt.successfulCronAdds,
};

View File

@@ -758,6 +758,7 @@ export async function runEmbeddedAttempt(
unsubscribe,
waitForCompactionRetry,
getMessagingToolSentTexts,
getMessagingToolSentMediaUrls,
getMessagingToolSentTargets,
getSuccessfulCronAdds,
didSendViaMessagingTool,
@@ -1178,6 +1179,7 @@ export async function runEmbeddedAttempt(
lastToolError: getLastToolError?.(),
didSendViaMessagingTool: didSendViaMessagingTool(),
messagingToolSentTexts: getMessagingToolSentTexts(),
messagingToolSentMediaUrls: getMessagingToolSentMediaUrls(),
messagingToolSentTargets: getMessagingToolSentTargets(),
successfulCronAdds: getSuccessfulCronAdds(),
cloudCodeAssistFormatError: Boolean(

View File

@@ -45,6 +45,7 @@ export type EmbeddedRunAttemptResult = {
};
didSendViaMessagingTool: boolean;
messagingToolSentTexts: string[];
messagingToolSentMediaUrls: string[];
messagingToolSentTargets: MessagingToolSend[];
successfulCronAdds?: number;
cloudCodeAssistFormatError: boolean;

View File

@@ -63,6 +63,8 @@ export type EmbeddedPiRunResult = {
didSendViaMessagingTool?: boolean;
// Texts successfully sent via messaging tools during the run.
messagingToolSentTexts?: string[];
// Media URLs successfully sent via messaging tools during the run.
messagingToolSentMediaUrls?: string[];
// Messaging tool targets that successfully sent a message during the run.
messagingToolSentTargets?: MessagingToolSend[];
// Count of successful cron.add tool calls in this run.