diff --git a/packages/ai-core/src/common/language-model.ts b/packages/ai-core/src/common/language-model.ts index 067e915bba4e4..7cfebc5519cb1 100644 --- a/packages/ai-core/src/common/language-model.ts +++ b/packages/ai-core/src/common/language-model.ts @@ -35,7 +35,8 @@ export const isLanguageModelRequestMessage = (obj: unknown): obj is LanguageMode export type ToolRequestParametersProperties = Record; export interface ToolRequestParameters { type?: 'object'; - properties: ToolRequestParametersProperties + properties: ToolRequestParametersProperties; + required?: string[]; } export interface ToolRequest { id: string; @@ -62,7 +63,8 @@ export namespace ToolRequest { export function isToolRequestParameters(obj: unknown): obj is ToolRequestParameters { return !!obj && typeof obj === 'object' && (!('type' in obj) || obj.type === 'object') && - 'properties' in obj && isToolRequestParametersProperties(obj.properties); + 'properties' in obj && isToolRequestParametersProperties(obj.properties) && + (!('required' in obj) || (Array.isArray(obj.required) && obj.required.every(prop => typeof prop === 'string'))); } } diff --git a/packages/ai-mcp/src/browser/mcp-command-contribution.ts b/packages/ai-mcp/src/browser/mcp-command-contribution.ts index ae1921d35b4bd..fc8c971e04a3e 100644 --- a/packages/ai-mcp/src/browser/mcp-command-contribution.ts +++ b/packages/ai-mcp/src/browser/mcp-command-contribution.ts @@ -126,6 +126,7 @@ export class MCPCommandContribution implements CommandContribution { parameters: ToolRequest.isToolRequestParameters(tool.inputSchema) ? { type: tool.inputSchema.type, properties: tool.inputSchema.properties, + required: tool.inputSchema.required } : undefined, description: tool.description, handler: async (arg_string: string) => { diff --git a/packages/ai-workspace-agent/src/browser/functions.ts b/packages/ai-workspace-agent/src/browser/functions.ts index bf38d6ba207c0..a4cda9908e8f8 100644 --- a/packages/ai-workspace-agent/src/browser/functions.ts +++ b/packages/ai-workspace-agent/src/browser/functions.ts @@ -186,7 +186,8 @@ export class FileContentFunction implements ToolProvider { description: `Return the content of a specified file within the workspace. The file path must be provided relative to the workspace root. Only files within workspace boundaries are accessible; attempting to access files outside the workspace will return an error.`, } - } + }, + required: ['file'] }, handler: (arg_string: string) => { const file = this.parseArg(arg_string); @@ -249,7 +250,8 @@ export class GetWorkspaceFileList implements ToolProvider { description: `Optional relative path to a directory within the workspace. If no path is specified, the function lists contents directly in the workspace root. Paths are resolved within workspace boundaries only; paths outside the workspace or unvalidated paths will result in an error.` } - } + }, + required: ['path'] }, description: `List files and directories within a specified workspace directory. Paths are relative to the workspace root, and only workspace-contained paths are allowed. If no path is provided, the root contents are listed. Paths outside the workspace will result in an error.`,