Commit Graph

9 Commits

Author SHA1 Message Date
Connor Peet ba56721dfa tools: add support for model-specific tool registration (#2857)
* tools: add support for model-specific tool registration

This PR goes with https://github.com/microsoft/vscode/pull/287666

This allows the registration of tools that are scoped to specific
language models. These tools can be registered at runtime with
definitions derived from e.g. the server.

I think we should adopt this and go away from the current
`alternativeDefinitions` pattern which we have used previously.

Example of having tools specific for GPT 4.1 vs 4o:

```ts
ToolRegistry.registerModelSpecificTool(
	{
		name: 'gpt41_get_time',
		inputSchema: {},
		description: 'Get the current date and time (4.1)',
		displayName: 'Get Time (GPT 4.1)',
		toolReferenceName: 'get_time',
		source: undefined,
		tags: [],
		models: [{ id: 'gpt-4.1' }],
	},
	class implements ICopilotTool<unknown> {
		invoke() {
			return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart('Current year is 2041 (GPT 4.1)')]);
		}
	}
);

ToolRegistry.registerModelSpecificTool(
	{
		name: 'gpt4o_get_time',
		inputSchema: {},
		description: 'Get the current date and time (4o)',
		displayName: 'Get Time (GPT 4o)',
		toolReferenceName: 'get_time',
		source: undefined,
		tags: [],
		models: [{ id: 'gpt-4o' }],
	},
	class implements ICopilotTool<unknown> {
		invoke() {
			return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart('Current year is 2040 (GPT 4o)')]);
		}
	}
);
```

* demo

* fix

* overrides

* add overridesTool

* fix inverted logic

* test fixes and back compat

* make memory tool model specific

* fix tests and contribute memory to the vscode toolset

* verison

* fix unit tests

* rm config

* fix missing askquestions

---------

Co-authored-by: bhavyaus <bhavyau@microsoft.com>
2026-01-22 18:34:05 +00:00
Connor Peet 27f68cda6d edits: show stream progress in edit tools (#2863)
* edits: show stream progress in edit tools

* flush markdown before starting a tool call
2026-01-15 01:50:13 +00:00
Connor Peet ad9116d2af edits: show diffs for files being approved during edits (#1905)
* edits: show diffs for files being approved during edits

Requires a PR in core as well to adopt this nicely.

* cleanup
2025-11-11 01:36:17 +00:00
Connor Peet 3de6af5556 edits: implement file edit guards using standard confirmations (#646)
After talking to Kai, we decided that the rare case of sensitive files edits should just use our standard confirmation UI instead of adding more variances to the base chat experience.
2025-08-18 19:35:40 +00:00
Connor Peet 83803f9192 tools: add multi-replace-string tool (#593)
* add multi edit tool

* comment out reminder

* comment out reminder

* fix multi_replace_string_in_file issue in intents

* add multi_replace_string_in_file related instructions

* add more instructions

* remove next tool prediction parsing

* remove next_tool_prediction from toolSchemaNormalizer.ts

* add initial user reminder

* add hasMultiReplaceString

* add hasMultiReplaceString

* add references to MultiReplaceStringTool

* Delete test_implementation.js

* Delete test_dummy_parameter.js

* Delete test_required_dummy.js

* Delete verify_implementation.js

* Delete src/extension/tools/test/common/addNextToolPredictionParameter.spec.ts

* Fix formatting of multi-replace string reminder

* tidy up and exp

* eng: refactor multi and single edit tools

---------

Co-authored-by: Yevhen Mohylevskyy <yevhenmohylevskyy@Yevhens-MacBook-Pro.local>
Co-authored-by: Ubuntu <yevhen@ubuntu22-vm.1kpbk2tnedsetibfv2d2keui5d.xx.internal.cloudapp.net>
Co-authored-by: yemohyleyemohyle <127880594+yemohyleyemohyle@users.noreply.github.com>
2025-08-13 23:39:09 +00:00
Rob Lourens 3bd01fab1d Use lineNumberStyle for FileVariable (#227)
* Use lineNumberStyle for FileVariable

* vitest

* update test files with no baseline...

* Update baseline scores for toolCalling tests to reflect recent changes

* tests

* Update baseline

---------

Co-authored-by: Ulugbek Abdullaev <ulugbekna@gmail.com>
2025-08-07 06:04:26 +00:00
Connor Peet 0758536da7 edits: try fix for no-op edits (#495)
Refs https://github.com/microsoft/vscode/issues/257379

I hypothesize that what's happening is the model tries to make an edit
with an invalid `oldString`. We then go to healing and the healing
process incorrectly causes the `newString` to no-op. This makes a
couple changes:

- Explicitly throw if oldString===newString, which we will get in telemetry
- Only do the `unescapeStringForGeminiBug` for Gemini, not Claude. Claude
  may not have this issue and is generally really good at self-correcting,
  I strongly suspect this code path is where things go awry.
2025-08-06 23:37:44 +00:00
Connor Peet 582b0bf837 tools: improve string_replace and add healing (ft. Gemini) (#251)
* test implementation of gemini-inspired model based healing

* rationalize types in string replace tools

* cleanup and add telemetry for string_replace healing

* prompting improvements

* add failsafe for string-replace healing

* update snapshot
2025-07-15 19:31:23 +00:00
kieferrm 333d9a4053 Hello Copilot
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2025-06-27 11:35:20 +02:00