Allows external agent/CLI edits to be harnessed in our edit session
implementation. There is a callback API to make an external edit. While
the callback is running, we assume that all edits made were done by the
agent and update our internal models based on a before/after snapshot.
We want to prevent mistaken changes that do something like this:
```ts
foo.onEvent = () => { ... };
```
When they almost always mean:
```ts
foo.onEvent(() => { ... })
```
* Add the ability to clear a ChatResponseStream, passing in a reason which results in a warning being displayed
* Changing ChatResponseStream.clear to ChatResponseStream.clearToPreviousToolInvocation and only clearing up to the last tool invocation
* Remove unnecessary code block
Co-authored-by: James Wang <120431051+jwangxx@users.noreply.github.com>
For MCP I can already kind of get this from the tool name, but for
extension tools we previously had no way to know which extension
provided the tool.
This PR adds a `LanguageModelToolInformation.source` containing details
about where the tool came from. I also use this to include the MCP
server instructions which is needed for #250017.
cc @aeschli @roblourens
Makes the `userSelectedTools` passed into the chat agent service
observable such that the tools of the ongoing request update as new
tools come in. The benefit of this versus other (previous) approaches
is that it reflects the enablement/disablement state of the picker
(which is likely to get additional controls in the future) and works
without special tagging.
@roblourens / @DonJayamanne I think with this we can get rid of
0d6f5516d2/src/extension/tools/vscode-node/toolsService.ts (L118-L122)
which was added for Jupyter iirc.
Closes#254684
* Pass model to tools
When tools make requests, they should use the right model. So we
- save the model id on the request
- look it up when the tool is invoked
- resolve it to a LanguageModelChat in the EH
* Fix build
We need to distinguish between codeblocks that have URIs and should be rendered as codeblock pills, vs ones that should be rendered as normal codeblocks but get the "apply in foo.js" handling due to having URIs. Previously this was just based on the mode, but in order to render chat codeblocks and also edits codeblocks, we need this tracking of whether a codeblockuri represents an edited file, which comes from the intent invocation.
When we clean up codeblock-based edits in favor of tools all the time, we can clean up this crazy code...
* add `ChatRequest#tools`
* make select tools for all tools, not just MCP tools
* make the select tools work with all tools, group by MCP server, extension, and rest
* fill in the new ChatRequest#selectTools API with selected tools
* have the MCP server command be its own command with its own custom rendering
* remove old comment
* chat: add a pause button for agent mode
There is a new `ChatParticipant.onDidChangePauseState` event that allows
the editor to signal requests should be paused or unpaused.
In agentic mode, a "pause" button is visible in the editor that surfaces
to this event. It's up to the LM to respect it. When paused, actions go
to their "idle" state, so new messages can be written which implicitly
cancel the previous request, following PR earlier today.

This solves Kai's request of wanting to pause and see what the model is
doing before continuing, as well as my desire to be able to interrupt
and hint to the model when it gets off track, although that might
ideally evolve to some other 'hint' vs a cancelled and new request.
PR for copilot coming later this evening.
* allow taking input when paused
* support to signal "done with editing" via `ChatResponseStream#textEdit`
* remove `triggerEditComputation` and the response action because this happens automatically