diff --git a/src/auto-reply/reply/followup-media.ts b/src/auto-reply/reply/followup-media.ts index d862a77875b..d9202554526 100644 --- a/src/auto-reply/reply/followup-media.ts +++ b/src/auto-reply/reply/followup-media.ts @@ -183,10 +183,18 @@ function hasOnlyFileLikeAttachments(mediaContext: FollowupMediaContext): boolean ); } +function hasAnyFileAttachments(mediaContext: FollowupMediaContext): boolean { + return normalizeAttachments(mediaContext as MsgContext).some((attachment) => { + const kind = resolveAttachmentKind(attachment); + return kind !== "audio" && kind !== "image" && kind !== "video"; + }); +} + function snapshotUpdatedMediaContext(params: { original: FollowupMediaContext; mediaCtx: MsgContext; updatedBody?: string; + appliedFile?: boolean; }): FollowupMediaContext { return { ...params.original, @@ -202,6 +210,8 @@ function snapshotUpdatedMediaContext(params: { ? [...params.mediaCtx.MediaUnderstandingDecisions] : params.original.MediaUnderstandingDecisions, DeferredMediaApplied: true, + DeferredFileBlocksExtracted: + params.original.DeferredFileBlocksExtracted || params.appliedFile || undefined, }; } @@ -227,13 +237,21 @@ export async function applyDeferredMediaUnderstandingToQueuedRun( const resolvedOriginalBody = mediaContext.CommandBody ?? mediaContext.RawBody ?? mediaContext.Body; - // Detect file extraction from the primary path by checking whether Body was - // mutated AND contains file blocks. This avoids false-positives when a user - // message literally contains "