Skip to content

Nested/scoped instructions are only discovered after view, so edits, new files and shell changes skip them #5497

Backlog

Description

@ajzozakiewicz

Describe the bug

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

  1. 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.
  2. edit without a prior view: no rules, no error.
  3. create of a new file: no discovery trigger.
  4. bash (for example cat or sed): no discovery trigger.
  5. 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.

Additional context

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions