Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/anthropic/src/anthropic-messages-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ export type AnthropicTool =

export type AnthropicToolChoice =
| { type: 'auto' | 'any'; disable_parallel_tool_use?: boolean }
| { type: 'tool'; name: string; disable_parallel_tool_use?: boolean };
| { type: 'tool'; name: string; disable_parallel_tool_use?: boolean }
| { type: 'none' };

export type AnthropicContainer = {
id?: string | null;
Expand Down
11 changes: 9 additions & 2 deletions packages/anthropic/src/anthropic-prepare-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,15 @@ describe('prepareTools', () => {
toolChoice: { type: 'none' },
supportsStructuredOutput: true,
});
expect(result.tools).toBeUndefined();
expect(result.toolChoice).toBeUndefined();
expect(result.tools).toEqual([
{
cache_control: undefined,
name: 'testFunction',
description: 'Test',
input_schema: {},
},
]);
expect(result.toolChoice).toEqual({ type: 'none' });
});

it('should handle tool choice "tool"', async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/anthropic/src/anthropic-prepare-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,12 @@ export async function prepareTools({
betas,
};
case 'none':
// Anthropic does not support 'none' tool choice, so we remove the tools:
return { tools: undefined, toolChoice: undefined, toolWarnings, betas };
return {
tools: anthropicTools,
toolChoice: { type: 'none' as const },
toolWarnings,
betas,
};
case 'tool':
return {
tools: anthropicTools,
Expand Down