github / github/copilot-cli

Compaction strips system prompt's <agent_instructions> block from custom agent profiles selected via /agent

Đang mở
#2,895 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
area:agents 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

When a custom agent is selected via `/agent` (or `--agent=`), the agent profile's instructions are loaded into the session system prompt context as `` block.
After `/compact` runs (either manually or via automatic compaction at ~80-95% context), the `` block is stripped from the context and not restored.

This effectively discards the custom agent's persona, behavioral rules, guidelines, and all other instructions -- making the `/agent` selection meaningless after compaction.

### Affected version

1.0.34

### Steps to reproduce the behavior

### Steps to reproduce

1. Create a custom agent profile at `~/.copilot/agents/my-agent.agent.md` with disable-model-invocation: true and substantial instructions
2. Launch copilot and select the agent via `/agent`
3. Verify the agent instructions are active (e.g., the model follows behaviour defined in the custom agent file)
4. Have a conversation long enough to trigger automatic compaction, or run /compact manually
5. Observe that the model no longer follows the custom agent instructions
6. Ask the model to check its system prompt — the `` block is absent

### Expected behavior

### Expected behavior

The system prompt's `` block from the selected custom agent profile should survive compaction. It is session configuration, not conversational history — it should be treated equivalently to `.github/copilot-instructions.md` or instruction files, which persist across compaction.

### Actual behavior

The block is discarded during compaction. The model reverts to default behavior without the custom agent's rules.

### Additional context

_No response_

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

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

Hướng nghiên cứu

Start by tracing how `/agent` and `--agent=` load custom profile instructions, then inspect the compaction path used by `/compact` and automatic compaction. Verify that the `` block remains available after compaction, alongside the stated instruction files.

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

Đánh giá

Công nghệ
shell
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/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.