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
+23 -1
View File
@@ -35,12 +35,34 @@ describe.each(['local', 'temporal'] as const)(
// Spy on the harness prompt method to intercept the LLM call while running real activities & tools
vi.spyOn(AgentHarness.prototype, 'prompt').mockImplementation(async function (
this: AgentHarness,
...args: unknown[]
) {
// Find the real autofill_metadata tool configured on the harness
// Find the real tools configured on the harness
const tools = this.getTools()
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Tool execution mock for E2E harness test
const readAssetTool = tools.find((t) => t.name === 'read_asset') as any
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Tool execution mock for E2E harness test
const autofillTool = tools.find((t) => t.name === 'autofill_metadata') as any
expect(readAssetTool).toBeDefined()
expect(autofillTool).toBeDefined()
const promptText = typeof args[0] === 'string' ? args[0] : ''
const assetIdMatch = promptText.match(/ID:\s*"([^"]+)"/)
if (readAssetTool && assetIdMatch) {
const assetId = assetIdMatch[1]
const readResult = await readAssetTool.execute(
'call-read-1',
{ assetId },
undefined,
undefined,
undefined,
)
expect(readResult).toBeDefined()
expect(readResult.content).toBeDefined()
}
if (autofillTool) {
// Execute the real tool callback to perform the actual DB updates
await autofillTool.execute(