Skip to content

Invalid input error when invoking copilot_replaceString toolΒ #1217

@jiasonwang

Description

@jiasonwang

Invalid input error when invoking copilot_replaceString tool

Description

When using the vscode.lm.invokeTool API to call the copilot_replaceString tool, an "Invalid input" error is thrown from the Copilot extension.

Note: I am running the chat-sample project as the test environment.

I ran the command: @tools /all edit some file in the chat-sample project, and the model I used was Claude Sonnet 4.

Environment

  • VS Code version: [1.103.2 (Universal)]
  • GitHub Copilot Chat extension version: 0.30.3
  • Extension context: chat-sample project using @vscode/prompt-tsx

Error Details

Error: Invalid input
    at Xj.invoke (/Users/stark/.vscode/extensions/github.copilot-chat-0.30.3/dist/extension.js:3713:82)
    at sq.$invokeTool (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:178:3046)

Code Context

The error occurs when calling vscode.lm.invokeTool with the tool name copilot_replaceString:

const toolResult = await vscode.lm.invokeTool(this.props.toolCall.name, {
    input: this.props.toolCall.input,
    toolInvocationToken: this.props.toolInvocationToken,
    tokenizationOptions
}, dummyCancellationToken);

Where this.props.toolCall.name resolves to "copilot_replaceString".

Additional Context

This occurs in the official chat-sample project that uses @vscode/prompt-tsx for prompt rendering and tool orchestration. The tool appears in the vscode.lm.tools list but fails when invoked programmatically.

I checked the possible source of the exception, which appears to be here:
https://github.com/microsoft/vscode-copilot-chat/blob/6c1cb4ba92e326a68ac5be26218b79c71b03b4f1/src/extension/tools/node/abstractReplaceStringTool.tsx#L93
Additionally, I found that this._promptContext is undefined at the time of the exception, which may be related to the error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions