github / github/copilot-cli

Repo-level instruction files (AGENTS.md/CLAUDE.md/etc.) are not preserved across  /compact

Đang mở
#4,687 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

area:context-memory
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

Describe the bug

(Written by Sonnet 5 as we mutually investigated the issue in-session in copilot-cli)
Early in a long session, the agent correctly read and followed a rule in the repo's  AGENTS.md  ("never commit directly to  main ; create a topic branch first"). Mid-session, context compaction occurred. After compaction, the agent committed directly to  main  twice, violating the rule it had followed earlier — it had no indication the rule still applied and never re-read AGENTS.md after compaction.

Root cause: compaction summarizes conversation history, but standing repo instruction files aren't treated as pinned/reloaded — they're just facts that can get compressed away like anything else discussed early in the session.

Suggested fix: on compaction, either (a) re-inject the current contents of any active instruction files (AGENTS.md, CLAUDE.md, copilot-instructions.md, etc.) into the fresh context, or (b) explicitly prompt/require the agent to re-read them before resuming file-editing/git work post-compaction.

Impact: silent policy drift after compaction in any long session touching a repo with custom agent instructions — particularly dangerous for rules like branch protection, since a violation may not surface until a human notices.

Affected version

1.0.80

Steps to reproduce the behavior
  1. Open a session in a repo containing an  AGENTS.md  (or  CLAUDE.md / copilot-instructions.md ) with an explicit git-workflow rule, e.g. "never commit directly to  main ; create a topic branch first."
  2. Have the agent read that file early in the session (directly, or incidentally via a  view / grep  call) and perform at least one commit that correctly follows the rule (confirms the rule was live in context).
  3. Continue the session with enough unrelated work/turns that automatic or manual ( /compact ) context compaction occurs at least once.
  4. After compaction, ask the agent to make further code changes and commit them in the same repo, without re-mentioning the branching rule.
  5. Observe: the agent commits directly to the currently-checked-out default branch (e.g.  main ), violating the rule it followed correctly in step 2 — with no re-read of  AGENTS.md  and no acknowledgment that a repo policy exists.
Expected behavior

The rule from  AGENTS.md  continues to be honored after compaction, either because the file's contents are re-injected into context at compaction time, or because the agent is prompted to re-read active instruction files before resuming work in that repo.

Actual: the rule silently stops being followed post-compaction, with no error, warning, or indication to the user that it had been dropped — only surfaced when the human happened to notice the resulting commits.

Additional context

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue nêu các tệp hướng dẫn đang hoạt động (AGENTS.md, CLAUDE.md và copilot-instructions.md) cùng với luồng /compact; hãy bắt đầu bằng cách lần theo cách quá trình compact tiếp tục một session và cách các tệp này được tải ban đầu. Tái hiện workflow được đánh số, sau đó xác minh rằng công việc sau khi compact vẫn tuân thủ quy tắc branch hoặc explicitly tải lại các tệp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
git
Lĩnh vực
cli, developer-experience
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.