Skip to content
Merged
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 extensions/positron-assistant/src/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,12 @@ function toAnthropicTools(tools: readonly vscode.LanguageModelChatTool[]): Anthr
}

function toAnthropicTool(tool: vscode.LanguageModelChatTool): Anthropic.ToolUnion {
// Anthropic requires a type for all tools; default to 'object' if not provided.
// See similar handling for the vercel SDK in AILanguageModel provideLanguageModelChatResponse in extensions/positron-assistant/src/models.ts
const input_schema = tool.inputSchema as Anthropic.Tool.InputSchema ?? {
type: 'object',
properties: {},
};
// Anthropic requires a type for all tools; default to 'object' if not provided.
if (!input_schema.type) {
log.warn(`[anthropic] Tool '${tool.name}' is missing input schema type; defaulting to 'object'`);
input_schema.type = 'object';
Expand Down
12 changes: 11 additions & 1 deletion extensions/positron-assistant/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,19 @@ abstract class AILanguageModel implements positron.ai.LanguageModelChatProvider

if (options.tools && options.tools.length > 0) {
tools = options.tools.reduce((acc: Record<string, ai.Tool>, tool: vscode.LanguageModelChatTool) => {
// Some providers like AWS Bedrock require a type for all tool input schemas; default to 'object' if not provided.
// See similar handling for Anthropic in toAnthropicTool in extensions/positron-assistant/src/anthropic.ts
const input_schema = tool.inputSchema as Record<string, any> ?? {
type: 'object',
properties: {},
};
if (!input_schema.type) {
log.warn(`Tool '${tool.name}' is missing input schema type; defaulting to 'object'`);
input_schema.type = 'object';
}
acc[tool.name] = ai.tool({
description: tool.description,
parameters: ai.jsonSchema(tool.inputSchema ?? { type: 'object', properties: {} }),
parameters: ai.jsonSchema(input_schema),
});
return acc;
}, {});
Expand Down