fix(executor): pass execution context with abortSignal to tool execute()

Some AI SDK tools (like @parallel-web/ai-sdk-tools) expect execute(params, context)
where context contains { abortSignal, messages, toolCallId }. Previously we only
passed params which caused 'Cannot destructure abortSignal' errors.

Also:
- Improved playground system prompt for better tool execution
- Playground /api/tools now proxies to web app with response transformation
- Added broken-tools.md documenting tool failure categories

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ajax Davis 2025-12-12 04:43:20 +10:00
parent 04e7315185
commit e09596a7fa
4 changed files with 127 additions and 20 deletions

View file

@ -530,9 +530,18 @@ async function executeTool(req: Request): Promise<Response> {
console.log('⚠️ No env object in request body');
}
// Execute the tool
// Execute the tool with AI SDK execution context
// Some tools expect a second argument with { abortSignal, ... }
const abortController = new AbortController();
const executionContext = {
abortSignal: abortController.signal,
// Add other context properties that AI SDK tools might expect
messages: [],
toolCallId: `exec_${Date.now()}`,
};
console.log(`🚀 Executing ${cacheKey} with params:`, params);
const result = await toolModule.execute(params || {});
const result = await toolModule.execute(params || {}, executionContext);
const executionTimeMs = Date.now() - startTime;
console.log(`✅ Execution complete in ${executionTimeMs}ms`);