no need to have extra tool for tool call repair

This commit is contained in:
dal 2025-08-06 16:57:06 -06:00
parent 2b5efe790e
commit 04ae594d3a
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
5 changed files with 2 additions and 34 deletions

View File

@ -9,7 +9,7 @@ import {
modifyMetrics,
} from '../../tools';
import { Sonnet4 } from '../../utils/models/sonnet-4';
import { repairToolCall } from '../../utils/tool-call-repair';
import { healToolWithLlm } from '../../utils/tool-call-repair';
import { getAnalystAgentSystemPrompt } from './get-analyst-agent-system-prompt';
const DEFAULT_CACHE_OPTIONS = {
@ -63,7 +63,7 @@ export function createAnalystAgent(analystAgentOptions: AnalystAgentOptions) {
maxOutputTokens: 10000,
temperature: 0,
experimental_context: analystAgentOptions,
experimental_repairToolCall: repairToolCall,
experimental_repairToolCall: healToolWithLlm,
}),
{
name: 'Analyst Agent',

View File

@ -1,7 +1,6 @@
import type { LanguageModelV2ToolCall } from '@ai-sdk/provider';
import { generateObject } from 'ai';
import type { ToolSet } from 'ai';
import type { z } from 'zod';
import { Haiku35 } from '../models/haiku-3-5';
interface ToolCallWithArgs extends LanguageModelV2ToolCall {

View File

@ -1,2 +1 @@
export { healToolWithLlm } from './heal-tool-with-llm';
export { repairToolCall } from './repair-tool';

View File

@ -1,30 +0,0 @@
import type { LanguageModelV2ToolCall } from '@ai-sdk/provider';
import { InvalidToolInputError, NoSuchToolError, type ToolSet } from 'ai';
import type { z } from 'zod';
import { healToolWithLlm } from './heal-tool-with-llm';
export const repairToolCall = async ({
toolCall,
tools,
error,
}: {
toolCall: LanguageModelV2ToolCall;
tools: ToolSet;
error: NoSuchToolError | InvalidToolInputError;
}) => {
try {
if (error instanceof NoSuchToolError) {
return null; // TODO: Implement repair tool response for unknown tools
}
if (error instanceof InvalidToolInputError) {
return healToolWithLlm({ toolCall, tools });
}
return null; // TODO: Generic error handling try again?
} catch (healError) {
console.error('Failed to repair tool call:', healError);
// Return null to indicate repair failed
return null;
}
};