mirror of https://github.com/buster-so/buster.git
no need to have extra tool for tool call repair
This commit is contained in:
parent
2b5efe790e
commit
04ae594d3a
|
@ -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',
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
export { healToolWithLlm } from './heal-tool-with-llm';
|
||||
export { repairToolCall } from './repair-tool';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue