feat(agent): propagate autofill context from chat to autofill workflow

Add an optional 'context' parameter to the create_file and create_version
agent tools so the chat agent can pass generation/source context (e.g.
'Generated using gemini') to the AI metadata autofill workflow.

- Add Asset.autofillContext column, persisted in the same transaction as
  asset creation when context is provided
- Add new list_autofill_fields agent tool exposing autofillable metadata
  fields (name, type, description, options) per project
- Autofill workflow reads the stored context and includes it in the
  autofill AI prompt
- Add short chat system-prompt guidance to use list_autofill_fields and
  pass <=50 word context when creating files/versions
This commit is contained in:
yiling
2026-08-05 10:33:02 +08:00
parent 30021b07d0
commit 033652cde3
18 changed files with 905 additions and 7 deletions
+9
View File
@@ -30,6 +30,14 @@ const createFileSchema = Type.Object({
}),
}),
),
context: Type.Optional(
Type.String({
description:
'Optional short context about this file and how it was generated (max 50 words, e.g. "Generated using gemini"). ' +
'Passed to the AI metadata autofill workflow to fill fields that cannot be determined from file content alone. ' +
'Check autofillable fields with list_autofill_fields first.',
}),
),
})
function assertExactlyOneSource(params: {
@@ -92,6 +100,7 @@ export function createCreateFileTool(userId: string): AgentTool<typeof createFil
name,
size,
contentType: mimeType,
...(params.context ? { context: params.context } : {}),
},
userId,
assetId: params.parent,