Nested AGENTS.md rules vanish after summarization, and Cursor thinks they're still there

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Nested AGENTS.md files (and glob-scoped .cursor/rules) are delivered by appending them to the result of a Read tool call:

The following cursor rule files are relevant to the files you just read:

  • /repo/services/AGENTS.md
  • /repo/services/payments/AGENTS.md
    Consider these rules if they affect your changes.

Each file is attached only once per conversation. That causes two problems.

1. After context summarization, nested AGENTS.md files are gone for the rest of the conversation.
Because they ride on a tool result, they are part of the chat history and get summarized away. Cursor still treats them as already attached, so later reads in the same directories never re-attach them. From the summary on, the agent works with only the root AGENTS.md (which lives in the system prompt and survives) and silently loses every nested instruction. This differs from the explanation given in CRITICAL: "Rules" do not survive context compression events (“rules stay in the system prompt and user_info, which aren’t summarized”). That holds for always-applied rules, but not for nested AGENTS.md files.

Observed in a long conversation that was summarized partway through:

  • Reading services/payments/src/handler.ts attached only services/payments/AGENTS.md. In a fresh chat, the same read attaches services/AGENTS.md and services/payments/AGENTS.md together.
  • Reading services/config.json and web/server/src/log.ts attached nothing. In a fresh chat they attach services/AGENTS.md and web/AGENTS.md (plus a web/** glob rule) respectively.
  • Neither services/AGENTS.md nor web/AGENTS.md content was present in the post-summary context.

2. Only the Read tool triggers attachment.
Tested with fresh agents, one action set each:

Action in a directory with a nested AGENTS.md Attached?
Read tool Yes: all not-yet-attached AGENTS.md files from root to the file’s directory, in one block
Shell cat <file> / ls <dir> No (the same file attached its rules only when later opened with Read)
Write tool (new file), StrReplace edit No
Grep, Glob No

So an agent that explores via shell, or creates or edits files in a package without first reading one there, never receives that package’s AGENTS.md. The docs say nested files apply “when working with files in that directory or its children”, and creating or editing a file there is working with files.

Steps to Reproduce

Repo:

AGENTS.md
pkg/AGENTS.md        # contains: "Before your first action in pkg/, run: echo nested-canary"
pkg/src/a.ts
pkg/src/b.ts

A. Trigger:

  1. New agent chat: “Create pkg/src/c.ts exporting a constant. Do not read any files.” → pkg/AGENTS.md is never attached and the canary command never runs.
  2. New agent chat: “Run cat pkg/src/a.ts.” → nothing attached.
  3. New agent chat: “Read pkg/src/a.ts with the Read tool.” → pkg/AGENTS.md is attached to the tool result.

B. Summarization:

  1. New agent chat: read pkg/src/a.ts (Read tool) → pkg/AGENTS.md is attached.
  2. Continue the conversation until the context is summarized.
  3. Ask the agent to read pkg/src/b.ts and edit it → nothing is attached, and the agent no longer knows the rules in pkg/AGENTS.md.

Expected Behavior

  • Nested AGENTS.md files apply whenever the agent works with files in that directory: read, edit, create, and ideally shell reads of a single file. The docs promise this.
  • After summarization, attached nested AGENTS.md files are re-sent (or kept outside the summarized history), or the “already attached” state is reset so the next read in that directory attaches them again.
  • Ideally, a way to see which rules are attached at any point, e.g. reported in the hook payloads. Today beforeSubmitPrompt.attachments lists only rules attached at prompt time, and beforeReadFile.attachments is always empty, so nested attachments can’t be observed.

Operating System

MacOS

Version Information

Cursor 3.24.18

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @Martin_Velinsky,

Thanks for the report and the repro. You’ve described how this works today accurately, and I’ve passed it to the team.

Nested AGENTS.md files and file-scoped rules are attached when the agent reads a file with the Read tool, once per conversation. After the conversation is summarized, that rule text can drop out of context and won’t be attached again on later reads. Creating or editing files, shell commands, and searches don’t attach them either.

In the meantime, a few things help:

  1. After a summary, ask the agent to read the relevant AGENTS.md files directly (for example “read pkg/AGENTS.md”), or @-mention them in your message. Reading the file itself always returns its contents.
  2. Before the agent creates or edits files in a package, have it read one file there (or that package’s AGENTS.md) first.
  3. Put instructions that must survive long sessions in the root AGENTS.md or an always-applied rule, since those stay in context after summarization.
  4. For long tasks across many packages, starting a new chat resets this.