feat(agent): enable read_asset tool for autofill agent (#396)

* feat(agent): enable read_asset tool for autofill agent

* fix(transcode): trigger autofill task for pdf assets

* fix(transcode): allow autofill task creation on all file assets

* fix(agent): require targetAssetId and teamId for autofill read_asset authorization

* feat(agent): instruct autofill agent to report failure directly if read_asset fails
This commit is contained in:
Yiling-J
2026-09-08 14:19:03 +08:00
committed by GitHub
parent 3a05332cd6
commit 04fd571bd9
10 changed files with 548 additions and 144 deletions
+15 -5
View File
@@ -112,6 +112,7 @@ export interface CreateAgentSessionParams {
sessionId?: string
userId?: string
projectId?: string
assetId?: string
userCommentId?: string | null
customTools?: AgentTool[]
thinkingLevel?: string
@@ -149,6 +150,7 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
sessionId,
userId,
projectId,
assetId,
userCommentId: passedUserCommentId,
customTools = [],
thinkingLevel,
@@ -316,17 +318,25 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
}
}
const mediaTools: AgentTool[] = []
if (userId) {
mediaTools.push(createReadAssetTool(userId))
}
const agent = await prisma.agent.findUnique({
where: { id: agentId },
})
const agentConfig = agent?.config as PrismaJson.AgentConfig | null | undefined
const deniedTools = agentConfig?.deniedTools ?? [...DEFAULT_DENIED_TOOLS]
const mediaTools: AgentTool[] = []
if (userId) {
mediaTools.push(createReadAssetTool(userId))
} else if (agent?.type === 'autofill' && assetId) {
mediaTools.push(
createReadAssetTool({
teamId,
agentType: 'autofill',
targetAssetId: assetId,
}),
)
}
if (!deniedTools.includes('generate_image') || !deniedTools.includes('generate_video')) {
try {
const { imageModels, videoModels, providerKeys } =