vscode-copilot-release icon indicating copy to clipboard operation
vscode-copilot-release copied to clipboard

`.instructions.md` Files Not Respected in VS Code Chat/Agent Mode

Open beingminimal opened this issue 6 months ago • 14 comments

Problem

.instructions.md files, designed to provide custom instructions for AI chat and agent functionalities, are not being respected or applied in both VS Code stable and insider builds. This issue prevents users from leveraging predefined instructions for specific tasks, programming languages, frameworks, or project types, leading to repetitive manual instruction input and a degraded user experience for AI-assisted development.

I am trying below example but it's not working.

---
applyTo: "**/*.md"
---

## Follow below things for Markdown Files

1. Do not use markdown bold (**) and italic (_) formatting in the markdown file. Use only headings, lists, and code blocks.
2. Also add markdown divider --- after each heading like # or ## or ###.

Solution

Investigate and resolve the bug preventing VS Code's chat and agent features from correctly parsing and applying instructions defined in .instructions.md files. This includes ensuring proper recognition of both workspace and user instruction files, correct interpretation of applyTo metadata, and consistent application of instruction content across all relevant AI interactions.

Benefits

  • Enhanced Productivity: Users can automate the inclusion of custom AI instructions, saving time and effort.
  • Consistent AI Behavior: Ensures AI agents and chat responses adhere to predefined guidelines, improving accuracy and relevance.
  • Improved User Experience: Streamlines the interaction with AI features in VS Code, making them more powerful and user-friendly.
  • Better Customization: Fully leverages the intended functionality of .instructions.md files for tailored AI assistance.

beingminimal avatar Jun 18 '25 13:06 beingminimal

Here is video that shows it's not working @digitarald

https://github.com/user-attachments/assets/e27ecc1f-3a40-45ee-b19d-37d2f0aabba1

beingminimal avatar Jun 19 '25 04:06 beingminimal

The automatic inclusion of instructions is currently based on the files that are part of the request context. In your case, there is no context, so no instructions are auto added.

In this release I added information to the prompt so that the agent can load the instructions when not present and needed.

TBH for now its the best to just mark your instructions as **. This will always include them, but given that they are small, this is not a problem. Even with the latest change, this will be more efficient that having the LLM to make a load.

aeschli avatar Jun 19 '25 11:06 aeschli

The internal issue where we track this is https://github.com/microsoft/vscode-copilot/issues/17214

aeschli avatar Jun 19 '25 11:06 aeschli

The automatic inclusion of instructions is currently based on the files that are part of the request context. In your case, there is no context, so no instructions are auto added.

In this release I added information to the prompt so that the agent can load the instructions when not present and needed.

TBH for now its the best to just mark your instructions as **. This will always include them, but given that they are small, this is not a problem. Even with the latest change, this will be more efficient that having the LLM to make a load.

So what i understood is i don't need to give instructions.md file in copilot chat/agent context but only those files on which i want to apply instructions.md files and want to generate code or docs? is this correct?

beingminimal avatar Jun 19 '25 14:06 beingminimal

You can add .instructions.md files either manually to the context or let them be added automatically. The automatic addition is based on the files that are attached as context of the request.

If you want them to be added automatically, you need to define the applyTo header:

  • **: it will be added to every request
  • **/*.ts: it will be added to all requests that have a typescript file attached as context of the request
  • if there's no typescript file attached as context of the request, the instruction will not be added. It won't be present if the LLM decides to create a TypeScript file.

New in June: If there's no typescript file attached as context, the LLM can load as we give it now the list of all instruction files

aeschli avatar Jun 19 '25 14:06 aeschli

New in June: If there's no typescript file attached as context, the LLM can load as we give it now the list of all instruction files

is it supported in today's insider release or going to be supported in vs code June 2025 release?

Thanks a lot for your reply and help.

beingminimal avatar Jun 19 '25 15:06 beingminimal

@aeschli

Can you please help to confirm this?

Question 1: Automatic Instruction Application for .ts Files in Chat/Agent Mode (Current Support & Future Plans)

Is it possible right now to configure GitHub Copilot in chat/agent mode such that instructions defined with applyTo: **/*.ts are automatically applied to any .ts file being worked on or generated, even if that .ts file is not explicitly added to the Copilot chat/agent context? If not currently supported, is there an estimated time of arrival (ETA) for this functionality, or are you considering supporting this in the future?

Question 2: Custom Mode Support for Instruction Application

Regarding the custom mode of GitHub Copilot, how will the automatic application of instructions (as described in Question 1) be supported within this custom mode? Are there specific configurations or mechanisms in custom mode that allow for broader, context-independent application of instructions to file types like .ts?

beingminimal avatar Jun 19 '25 15:06 beingminimal

I can only repeat what I wrote above: In May, the automatic inclusion of instructions happens when the request is made and depends on what files are attached at that time In June (and current insiders), we now tell the MML what instruction file there are, and the LLM can decide to load additional instructions. It works well for some models like Sonnet, while other models like gpt 4.1 tend ignore it.

This is no different for custom modes. If works for all modes that have the read_file agent enabled.

We are still experimenting here. Again, if instructions are short, I recommend to use '**' as pattern and have the instruction always included.

aeschli avatar Jun 20 '25 06:06 aeschli

I can only repeat what I wrote above: In May, the automatic inclusion of instructions happens when the request is made and depends on what files are attached at that time In June (and current insiders), we now tell the MML what requests there are, and the LLM can decide to load additional instructions. It works well for some models like Sonnect, while other models like gpt 4.1 ignore it.

This is no different for custom modes. If works for all modes that have the read_file agent enabled.

We are still experimenting here. Again, if instructions are short, I recommend to use '**' as pattern and have the instruction always included.

Thanks a lot for your reply and efforts and clarity.

beingminimal avatar Jun 20 '25 11:06 beingminimal

The internal issue where we track this is https://github.com/microsoft/vscode-copilot/issues/17214 @aeschli That return 404.

Do there is any documentation about this? I was using prompt.md file, but it seems like it's deprecated.

hmorneau avatar Jun 23 '25 01:06 hmorneau

https://code.visualstudio.com/docs/copilot/copilot-customization is the documentation

aeschli avatar Jun 23 '25 08:06 aeschli

The instructions are not picked in the Agent Mode when the model decides to create a new language file or trying to update the available file on it own unless we specifically add the files or the instructions manually. Any one got a grip on this? Like asking a model to look f or the instructions before creating a certain file?

prasanthkarukkuvel avatar Sep 23 '25 01:09 prasanthkarukkuvel

That's already what we do. The agent prompt gets a list of all instructions files along with their descriptions and applyTo patterns and is asked to load these if needed, in particular when creating new files. Some models follow this better than others. I recommend to use the descriptions to clarify what the instructions are for.

aeschli avatar Sep 23 '25 09:09 aeschli

Even when instructions are included in the request, the agent doesn't seem to listen. For example I tell it not to use the any type in my typescript files, However, for me it includes my "typescript" instructions file.

Image

In that file it says "Never use any" typescript.instructions.md:

Image

The agent the proceeds to build a file using the any type. It then only fixes the file because of eslint errors that I have setup.


Here is another one (from the same prompt as above) react.instructions.md:

Image

and here are the imports it decided to generate:

Image

The only thing I can think of is maybe I wasn't broad enough in the example, and maybe it assumes only for those imports (useEffect and useState)?

TheColorRed avatar Nov 05 '25 13:11 TheColorRed