You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nested/scoped instructions are only discovered after view, so edits, new files and shell changes skip them #5497
Summary
With enableOnDemandInstructionDiscovery on, nested AGENTS.md and applyTo instructions load only after a successful view of a file. An agent that changes files without viewing them gets no scoped rules and no warning. Nothing tells the agent that rules exist and were skipped.
Environment
@github/copilot-sdk 1.0.8, running the same runtime as the CLI. I did not test the interactive CLI.
Flag on. One model, small test repo with a nested AGENTS.md and a scoped *.instructions.md.
Observed
After a successful view of a nested file, a system.notification with kind.type: "instruction_discovered" and triggerTool: "view" fires, and the rules reach the agent.
edit without a prior view: no rules, no error.
create of a new file: no discovery trigger.
bash (for example cat or sed): no discovery trigger.
Neutral prompts, with no instruction about viewing (4 tasks × 2 runs):
Task
Rules applied
Edit one existing file
4 of 4: the agent viewed first
Create a new file
1 of 2: one run missed the rules
Change every packages/*/f.ts
0 of 2: the agent used glob and bash head, then edited blind
Overall, 3 of 8 runs ignored scoped rules.
Expected
Why it matters
Apps built on the SDK cannot rely on the flag. They need their own pre-tool hook to guarantee delivery, which is fragile because it must parse tool arguments, including shell commands.
Suggestions
Trigger discovery on edit, create and patch paths, before the tool runs.
Or add a mode, such as "beforeWrite", that loads rules for the target path on the first write.
Or emit an event when a write happens in a directory that has undiscovered instructions.
Affected version
No response
Steps to reproduce the behavior
No response
Expected behavior
Scoped rules for a path should load before any tool that changes that path (edit, create, patch, and ideally shell writes), not only after a view.
Activity