Skip to content

Commit a6b14f2

Browse files
committed
Fix Anthropic provider tool format
1 parent 185b3b2 commit a6b14f2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/agent/src/core/llm/providers/anthropic.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ export class AnthropicProvider implements LLMProvider {
8080
// Add tools if provided
8181
if (functions && functions.length > 0) {
8282
(requestOptions as any).tools = functions.map(fn => ({
83-
name: fn.name,
84-
description: fn.description,
85-
input_schema: fn.parameters,
83+
type: 'function',
84+
function: {
85+
name: fn.name,
86+
description: fn.description,
87+
parameters: fn.parameters,
88+
}
8689
}));
8790
}
8891

@@ -91,9 +94,12 @@ export class AnthropicProvider implements LLMProvider {
9194
// Extract content and tool calls
9295
const content = response.content.find(c => c.type === 'text')?.text || '';
9396
const toolCalls = response.content
94-
.filter(c => (c as any).type === 'tool_use')
97+
.filter(c => {
98+
const contentType = (c as any).type;
99+
return contentType === 'tool_use';
100+
})
95101
.map(c => {
96-
const toolUse = c as any; // Type assertion for tool_use content
102+
const toolUse = c as any;
97103
return {
98104
id: toolUse.id || `tool-${Math.random().toString(36).substring(2, 11)}`,
99105
name: toolUse.name,

0 commit comments

Comments
 (0)