-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the feature or problem you'd like to solve
Enable a flag or option to have copilot include all agents.md files along a hierarchy instead of just the base and closest one
Proposed solution
This feature is enabled in vscode chat with the flag chat.useNestedAgentsMdFiles https://code.visualstudio.com/docs/copilot/customization/custom-instructions#_use-multiple-agentsmd-files-experimental
microsoft/vscode#268935
The request is for a flag or option like this in copilot-cli.
I know this is possible using the .github/instructions/specific.instructions.md file with applyTo in the yaml frontmatter, however we would prefer to localize our instructions to be in the repo folders next to where they apply, like how the AGENTS.md spec specifies and get the intermediate agents.md files included as well.
I tried a few workarounds, one which worked, and the others were intermittent or didnt work
- Use only AGENTS.md files as source of truth, include an applyTo at the top of them. Make a symlink from the .github/instructions folder for each one with a specific filename and appended with .instructions.md. this sym link can let us avoid having to maintain multiple locations of info and did result in copilot reading the nested agents.md files as if they were just instructions.md files in .github/instructions with applyTo being used correctly.
- Have deeper nested AGENTS.md files instruct copilot to read the next agents.md file above it in the hierarchy. Copilot didnt follow the instruction as far as i could tell, or only did if i explicitly told it to during a prompt and not from the main instruction file.
- Just add applyTo to the top of the agents.md files and not use any instructions.md files. applyTo of course didnt work in the random context of just being in an agents.md file, but this could possibly solve the feature if it was easier?
- instructions.md files with accurate applyTo where their content just says "refer to the agents.md file" and i linked the path to the file. this sometimes worked but wasnt consistent.
Example prompts or workflows
Copilot CLI Nested AGENTS.md Feature Example
Scope
Path used for this example:
root\base\Tests\UnitTestProject\SpecificTests\SpecificTest.cs
Nested AGENTS.md Structure
📂 root\base
├── 📄 AGENTS.md
└── 📁 Tests
├── 📄 AGENTS.md
└── 📁 UnitTestProject
├── 📄 AGENTS.md
└── 📁 SpecificTests
├── 📄 AGENTS.md
└── 📄 SpecificTest.cs
Nested AGENTS.md Contents (Along This Path)
1) \root\base\AGENTS.md
Exact content:
The test command is dotnet test
2) \root\base\Tests\AGENTS.md
Exact content:
For all tests within this test folder, anytime you run a command to run tests, append the argument --ThisIsInTheTestsFolder
3) root\base\Tests\UnitTestProject\AGENTS.md
Exact content:
For all tests within this test folder, anytime you run a command to run tests, append the argument --ThisIsInUnitTestProjectFolder
4) root\base\Tests\UnitTestProject\SpecificTests\AGENTS.md
Exact content:
For all tests within this test folder, anytime you run a command to run tests, append the argument --TheseAreSpecificTests
Prompt + Expected Results
Prompt
Run tests for root\base\Tests\UnitTestProject\SpecificTests\SpecificTests.cs
Expected Result (Feature OFF: no nested AGENTS discovery)
Agent may run a basic command such as:
dotnet test --TheseAreSpecificTestsObserved behavior:
- Folder-specific AGENTS rules are only applied for final folder which is the current context root\base\Tests\UnitTestProject\SpecificTests\AGENTS.md
- Required intermediate custom flags are ignored.
Expected Result (Proposed Feature ON: nested AGENTS discovery enabled)
Agent resolves AGENTS.md files from repo root to leaf folder and combines them with each subsequent agents.md taking precedence (appearing later in the combined instructions).
Expected command:
dotnet test --ThisIsInTheTestsFolder --ThisIsInUnitTestProjectFolder --TheseAreSpecificTests Observed behavior:
- All applicable nested AGENTS instructions are honored.
- Parent + child folder rules are merged in path order.
- Command aligns with repository conventions for this directory.
Suggested Acceptance Check
A nested AGENTS feature is working if a test run request in this folder automatically includes all 3 required test arguments:
--ThisIsInTheTestsFolder--ThisIsInUnitTestProjectFolder--TheseAreSpecificTests
Additional context
No response