diff --git a/packages/ai/src/agents/analyst-agent/analyst-agent.ts b/packages/ai/src/agents/analyst-agent/analyst-agent.ts index 56859e974..49caa7e04 100644 --- a/packages/ai/src/agents/analyst-agent/analyst-agent.ts +++ b/packages/ai/src/agents/analyst-agent/analyst-agent.ts @@ -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', diff --git a/packages/ai/src/utils/tool-call-repair/heal-no-such-tool-error.ts b/packages/ai/src/utils/tool-call-repair/heal-no-such-tool-error.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/ai/src/utils/tool-call-repair/heal-tool-with-llm.ts b/packages/ai/src/utils/tool-call-repair/heal-tool-with-llm.ts index 486c64e14..6f63f99a9 100644 --- a/packages/ai/src/utils/tool-call-repair/heal-tool-with-llm.ts +++ b/packages/ai/src/utils/tool-call-repair/heal-tool-with-llm.ts @@ -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 { diff --git a/packages/ai/src/utils/tool-call-repair/index.ts b/packages/ai/src/utils/tool-call-repair/index.ts index 6d5c82d86..7926ed262 100644 --- a/packages/ai/src/utils/tool-call-repair/index.ts +++ b/packages/ai/src/utils/tool-call-repair/index.ts @@ -1,2 +1 @@ export { healToolWithLlm } from './heal-tool-with-llm'; -export { repairToolCall } from './repair-tool'; diff --git a/packages/ai/src/utils/tool-call-repair/repair-tool.ts b/packages/ai/src/utils/tool-call-repair/repair-tool.ts deleted file mode 100644 index d8099ab0b..000000000 --- a/packages/ai/src/utils/tool-call-repair/repair-tool.ts +++ /dev/null @@ -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; - } -};