Skip to content

.github/instructions files fully inlined into system prompt ignoring applyTo frontmatter #2857

@T-Gro

Description

@T-Gro

Describe the bug

When a repository contains .github/instructions/*.instructions.md files with applyTo YAML frontmatter, the
CLI inlines the full content of every instruction file into the system prompt at session start — regardless of whether the task touches matching files.

The system prompt also tells the agent to view these files before making changes, which is redundant since they're already in context.

In repos with many instruction files (e.g. dotnet/runtime has 14), this wastes significant context tokens on every session.

Affected version

GitHub Copilot CLI 1.0.33

Steps to reproduce the behavior

Steps to reproduce:

  1. Clone a repo with multiple .github/instructions/*.instructions.md files (e.g. dotnet/runtime)
  2. Start a Copilot CLI session
  3. Ask a simple question that doesn't involve code changes
  4. Observe large context usage from session start — all instruction file contents are in the system prompt

Expected behavior

The CLI should include only the pattern → filepath mapping in the system and let the agent view relevant instruction files on demand using the applyTo glob patterns.

Whenever a tool would decide to read/write a file, the system would frontload the relevant content.

Additional context

This was spotted by increased context usage - for large repos, it is not feasible to fit all instruction files into a single session's context window.

The ability to split instructions based on repo's directory structure is good - but it must be done in a lazy, just in time, manner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:configurationConfig files, instruction files, settings, and environment variablesarea:context-memoryContext window, memory, compaction, checkpoints, and instruction loading

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions