fix(agent): restrict pageCount and duration recommendations to matching media types (#397)

This commit is contained in:
Yiling-J
2026-09-08 14:52:37 +08:00
committed by GitHub
parent 04fd571bd9
commit 4a61e87a27
5 changed files with 183 additions and 10 deletions
+15 -6
View File
@@ -1,6 +1,7 @@
import type { WorkflowTask } from '@shumai/db'
import { executeActivity, getActivities, TaskQueueAgent } from '@shumai/workflow-core'
import { ApplicationFailure } from '@temporalio/workflow'
import { getProxyType } from '@shumai/core/src/utils/mime'
export async function agentAutofillMedia(task: WorkflowTask): Promise<void> {
const {
@@ -74,13 +75,21 @@ export async function agentAutofillMedia(task: WorkflowTask): Promise<void> {
// 4. Call AI Service (inspects asset on demand via read_asset)
const mediaInfo = asset.media as PrismaJson.MediaInfo | null
const duration = typeof mediaInfo?.duration === 'number' ? mediaInfo.duration : undefined
const proxyType = mediaInfo?.proxyType || getProxyType(asset.mediaType, asset.name) || undefined
const duration =
(proxyType === 'video' || proxyType === 'audio') && typeof mediaInfo?.duration === 'number'
? mediaInfo.duration
: undefined
const pageCount =
typeof mediaInfo?.metadata?.totalFrames === 'number'
? mediaInfo.metadata.totalFrames
: typeof mediaInfo?.frames === 'number'
? mediaInfo.frames
: undefined
proxyType === 'pdf'
? typeof mediaInfo?.metadata?.totalFrames === 'number'
? mediaInfo.metadata.totalFrames
: typeof mediaInfo?.frames === 'number'
? mediaInfo.frames
: undefined
: undefined
const aiResult = await executeActivity(agentWorkerQueue, autofillAiActivity, {
teamId,