Implicit context handling in Copilot Chat
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.101.0
- OS Version: Ubuntu 24.04.2 LTS
Improvements for the implicit context changes for the copilot chat.
- Current file selections are not included by default, there are many reasons when you would want the llm to only scope in the current function/block.
- Even by using the shortcut mentioned
Shift+Tab, Enterthe context cannot be fine tuned with including specific lines automatically. - When you change a file the previous context (added by
Shift+Tab, Enter) still remains in the list. Which also cannot be removed byShift+Tab, Enter(it just opens that file).
Implicitly adding the current context (fine grained till line number) is a very good feature, and any other context (even the current file) can be easily added with the shortcut ctrl + /.
Suggestion to bring this feature back.
cc @isidorn
We need this back. I tried with implicit context but doesn't do it.
Sorry for the confusion. First, in case this helps, you can easily set a keybinding to the "Add Selection to Chat" command by adding something like this your keybindings.json
{
"key": "cmd+l",
"command": "workbench.action.chat.attachSelection",
"when": "editorTextFocus"
}
Also, you can use #selection to attach the selection.
Second, I assume you're using Ask mode? The ideal for me is that all interactions will be agentic in that Copilot will be aware of your ui state and able to read the file into context if necessary, as Agent mode is able to do today. But in the meantime before we have that in Ask mode, help me understand, what sort of solution would best help you?
- Just bring back the eyeball toggle in Ask mode
- Always attach the selection/file, possibly wasting tokens
- The suggested attachment could be the current selection, instead of the whole file
- Something else
My workflow here has also been affected in a negative way.
An example is that I'm working in a file, it could be a relatively long file and I want to open chat in edit mode to help me make some changes to a specific part.
I used to simply open chat (which may already be open on a new chat) and start asking for my changes, the current cursor position is taken into context (no text selected) and changes are suggested based on where my cursor was.
This behaviour is very similar to inline chat, except with the added benefit of having a full chat context for continued iteration on other parts of the file.
"Add Selection to Chat" is useful but another step and does not react to cursor movements for continued iteration. I need to remove the old one and add a new one which slows things down and can break the thought process of the job at hand.
#selection is only available if there is an actual selection, not just taking the current cursor position and similarly would need to be re-applied on cursor position change.
Ideally it would be great if there was an option to always have the current cursor position added to the context like it previously worked.
Hey @roblourens, yes this workflow is in ask mode only. In my ideal workflow implicitly adding the current selection to chat by default is really helpful (what #selection does, but do it by default).
-
I can scope my problem to a specific function/block, allowing me to refer to the code using "this" and "here" in chat - which has become my habit now.
-
As @danwall mentioned, when I don't select anything and move directly to chat, having lines near my cursor automatically added feels intuitive
-
Unlike Agent mode, I use Ask mode for very specific questions (rudimentary e.g., in Go: "Are all errors handled correctly and returned in this function?")
-
Without any context many times the response is "Without seeing the specific code, I can provide a general explanation of how ....", because I forgot to add the context to chat.
-
When I add the whole file via
Shift+Tab, Enter, responses become more generic instead of focusing on my specific area of interest
All in all, request to bring back the previous workflow of, automatically adding the current selection in chat as context(basically #selection), if nothing was selected, the current cursor position is the context(not sure how this was calculated).
The eyeball toggle does not have much relevance to this, the dotted outline is quite good.
Sorry for the confusion. First, in case this helps, you can easily set a keybinding to the "Add Selection to Chat" command by adding something like this your keybindings.json
{ "key": "cmd+l", "command": "workbench.action.chat.attachSelection", "when": "editorTextFocus" }Also, you can use
#selectionto attach the selection.Second, I assume you're using Ask mode? The ideal for me is that all interactions will be agentic in that Copilot will be aware of your ui state and able to read the file into context if necessary, as Agent mode is able to do today. But in the meantime before we have that in Ask mode, help me understand, what sort of solution would best help you?
- Just bring back the eyeball toggle in Ask mode
- Always attach the selection/file, possibly wasting tokens
- The suggested attachment could be the current selection, instead of the whole file
- Something else
Thanks for the response.
@snehilshah and @danwall stated it perfectly: automatically add selection/cursor position to the Ask request, as it used to do.
It's very intuitive to talk to the AI based on what you're seeing in the screen at the moment.
I avoid using Agent mode cause it's slower and sometimes messes the code a bit. I use mostly focused help on single functions, and having it automatically consider my selection is very natural.
Sorry for the confusion. First, in case this helps, you can easily set a keybinding to the "Add Selection to Chat" command by adding something like this your keybindings.json
{ "key": "cmd+l", "command": "workbench.action.chat.attachSelection", "when": "editorTextFocus" }Also, you can use
#selectionto attach the selection.Second, I assume you're using Ask mode? The ideal for me is that all interactions will be agentic in that Copilot will be aware of your ui state and able to read the file into context if necessary, as Agent mode is able to do today. But in the meantime before we have that in Ask mode, help me understand, what sort of solution would best help you?
- Just bring back the eyeball toggle in Ask mode
- Always attach the selection/file, possibly wasting tokens
- The suggested attachment could be the current selection, instead of the whole file
- Something else
ALWAYS attach the selection file PLUS the entire file. This allows one to ask something like "I have an error in this line" and having the context for the whole file will make it easier for the CHAT to spot where the error is.
ALWAYS attach the selection file PLUS the entire file. This allows one to ask something like "I have an error in this line" and having the context for the whole file will make it easier for the CHAT to spot where the error is.
Adding selection + whole file might be a waste of tokens, if you really want the file also with the selection in context, then you can use Ctrl + / and select the file.
ALWAYS attach the selection file PLUS the entire file. This allows one to ask something like "I have an error in this line" and having the context for the whole file will make it easier for the CHAT to spot where the error is.
Adding selection + whole file might be a waste of tokens, if you really want the file also with the selection in context, then you can use
Ctrl + /and select the file.
That is the way that worked up to the latest release. It is also the way Cursor does it (just checked). And the waste of token thing?? I mean, why downgrade the experience of your users by broken everyone's workflow
Thank you all for the feedback. We will revert to the behavior from the previous release with our recovery release (going out on Tuesday / Wednesday).
I apologize for the regression. We should have polished this experience more before rolling it out for all users. This item will track the changes we plan in the next release https://github.com/microsoft/vscode/issues/251624 Any feedback is very much welcome.
An open call for users to use https://code.visualstudio.com/insiders/ more and provide feedback early. This really helps us shape the experience together with you 🙏
Thank you for considering the revert. I notice the asymmetry: it is MUCH easier to manually remove unwanted context items than to manually add wanted context items. I'd appreciate erring on the safe side by over collecting context rather than under collecting it.
@chuanqisun thank you. I would like if you try out VS Code Insiders once we do the improvements proposed in this one https://github.com/microsoft/vscode/issues/251624 and provide feedback in that issue.
The ideal for me is that all interactions will be agentic in that Copilot will be aware of your ui state and able to read the file into context if necessary, as Agent mode is able to do today. But in the meantime before we have that in Ask mode, help me understand, what sort of solution would best help you?
FWIW, I use Ask mode a lot because I want to understand and brainstorm before moving to agent (if I even need to). Agent is very eager to make changes, and while I've learn to tell it to wait until i say it's OK to make changes, it's a little cumbersome to always have to remember to tell it to wait when i just want to reason about a selection of file or set of files.
Maybe Ask becomes less needed if there's a way to always have Agent keep it's paws off until I've arrived at what I really want to do?
We made some prompt changes which might help with that issue @papakpmartin - I'd be interested to know if you still see that problem in the latest stable, and if so, an example of the prompt.
ugh, this has been a problem for me since the last update. Before the last update, I could ask the agent a question and it would automatically use the active editor as context. But now I have to manually add the context every time, since it gets deselected whenever I ask something. It used to work just fine before.
We made some prompt changes which might help with that issue @papakpmartin - I'd be interested to know if you still see that problem in the latest stable, and if so, an example of the prompt.
I have this version, and i see no improvement whatsoever:
Unique identifier: GitHub.copilot-chat
Version: 0.29.2025061701
Last updated: June 17, 2025 at 6:28:05 AM
Usecase:
- Open a file in the editor and highlight (aka select) a function
- Open copilot chat.
- In chat at the top the prompt field click on the greyed out name of the current file "suggested context" s.t it will be included in context
Prompt:
what is the name of the highlighted function.
Answer:
I can see the Solidity contract you've shared, but I don't see any specific function highlighted in the code. The contract contains three functions: ...
Issues:
- Copilot has lost awareness of the current selection in the open editor. This is important for a myriad of usecases.
- Constantly approving "suggested context" is tiring. The currently active open file should be in context per default. Or - if you are unsure about this, at least make a setting about the default behaviour it.
What did you change exactly @roblourens ? Is there any workaround to provide the current selection to chat ? #selection does not exist for me as a context command.
Please read this comment https://github.com/microsoft/vscode/issues/251453#issuecomment-2977199640 tl;dr - stable will have the fix today/tomorrow. https://code.visualstudio.com/insiders/ already has a fix
I will lock this issue to make sure this comment does not get lost in the noise.
If you need to comment feel free to open a new issue and ping me @isidorn
Closing down as fix has landed in release branch. And the release on Thursday will contain the fix. I apologize one more time for breaking the flows of some of you, and we will do better next time. Thank you for your understanding 🙏
This item will track the changes we plan in the next release https://github.com/microsoft/vscode/issues/251624 Any feedback is very much welcome.
VS Code stable version 1.101.1 with this fix has been released. So please update and the issue should be resolved. Thank you
hey all! just wanted to shout out that in the latest insiders, there is a new implicit context solution. feel free to try it out.
the tldr:
- selections are always included, regardless of mode. this was a major concern in what we changed in the past, so we're making sure this is always included.
- in ask mode, current editor is automatically included as context. nothing you have to press. if you remove the implicit context, they won't get automatically added for the rest of the session.
- in agent mode, current editor will not be automatically added as context. however, there are hints passed to the request that knows where you are in the editor. tool calling (searches/reads) will be done instead on the file which should save us tokens :)
this is all experimental and enabled by default, but please let us know if you have any feedback about this!
@justschen thanks! I really like the changes you made (though I am biased).
Would love to hear it from the community if there are still some scenarios that we could improve by handling the active file better? Though a new stable release is coming out this week and I expect to hear some feedback then 😊