github / github/copilot-cli

Auto-compaction loops infinitely when instruction files are large

オープン
#3,621 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:configuration area:context-memory
主要言語
Shell
スター
11.2k
フォーク
1.9k
平均マージ
14時間 16分
マージ済み PR(30日)
6

説明

### Describe the bug

## Describe the bug

When a user has large instruction files (global `~/.copilot/copilot-instructions.md` and/or
repo-level `.github/copilot-instructions.md`) the agent enters a continuous auto-compaction
loop, wiping working memory on virtually every turn. Multi-step tasks never complete.

The session output becomes a wall of:

```
● Compacting conversation history...
● Compaction completed
└ A new checkpoint has been added to your session.
```

The agent loses all prior context, restarts the task from scratch, then compacts again immediately.
This repeats indefinitely. No multi-step work survives.

---

## Affected version

```
GitHub Copilot CLI 1.0.57-5.
Run 'copilot update' to check for updates.
```

Broken: **1.0.52 through 1.0.57** (current stable as of 2026-06-01)
Working: **1.0.48** and below
Not tested: **1.0.49 through 1.0.51** (may work; the 1.0.52-2 changelog entry is the first mention of tier enforcement)

### Affected version

GitHub Copilot CLI 1.0.57-5

### Steps to reproduce the behavior

## Steps to reproduce the behavior

1. Create `~/.copilot/copilot-instructions.md` with content >= 300 KB
(or combine global + repo instructions so the total exceeds ~150,000 tokens)
2. Start a session in any repository
3. Ask a multi-step question requiring 2+ tool calls (e.g., "read file X and summarize it")
4. Observe repeated "Compacting conversation history..." output before the task completes
5. Note that context is wiped each time, and the agent restarts the same task from scratch
6. Observe this loop continues indefinitely

---

### Expected behavior

## Expected behavior

The agent completes multi-step tasks without compacting context mid-execution. If instructions
alone approach the tier limit, the agent should warn the user rather than silently loop.
`/compact off` should suppress all auto-compaction (tier-based and manual), not just
user-initiated compaction.

---

### Additional context

## Additional context

**Root cause candidate — 1.0.52-2 changelog:**
> "Context window tier selection (default ~200K vs 1M tokens) is now enforced end-to-end,
> so picking a tier actually constrains compaction, truncation, and token display"

This introduced hard tier-based limits into the auto-compaction trigger. The problem is that
the default tier (~200K tokens) does not account for the instructions footprint:

- Global instructions: ~374 KB ≈ ~140,000 tokens
- Repo instructions: ~33 KB ≈ ~12,000 tokens
- **Instructions baseline at session zero: ~152,000 tokens**

This leaves fewer than 50,000 tokens of working memory — not enough for any non-trivial
tool-call sequence. After compaction, instructions (which cannot be compacted) are still
152K tokens, so the threshold is immediately hit again. The session never stabilizes.

**Why `/compact off` does not help:**
`/compact off` disables user-initiated manual compaction only. Tier-enforcement auto-compaction
is a separate code path and is unaffected.

**Partial fixes in 1.0.56–1.0.57 that did NOT resolve this:**
- 1.0.56-0: "Context window tier selection now persists durably in session events and survives
SDK-only resume paths" — fixed tier persistence but not the instructions-footprint loop
- 1.0.57-4: "Session no longer hangs indefinitely after an error occurs during internal event
processing" — related symptom, different failure mode

**Proposed fixes (any one would help):**
1. At session start, detect when instructions alone exceed the tier; warn/prompt rather than looping
2. Set the effective tier floor = instructions_size + configurable working headroom minimum
3. Make `/compact off` suppress tier-based auto-compaction, not just manual compaction
4. Allow users to opt into the 1M-token tier without per-turn enforcement

**Workaround:** Revert to **1.0.48** (or possibly anything prior to 1.0.52 — versions 1.0.49–1.0.51 not tested).

**Environment:**
- OS: Windows 11 (Build 26100)
- CPU: x86_64
- Terminal: Windows Terminal
- Shell: PowerShell / cmd
- Node.js: v24.15.0
- Installation: `npm install -g @github/copilot`

**Note on use case:** The global instructions file is used as intended — centralizing org, team,
and repository standards so they apply across all sessions. This bug disproportionately affects
power users of the global instructions feature.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by reproducing the loop with global and repository instruction files at the sizes described, comparing versions 1.0.48 and 1.0.57. Trace the tier-enforcement auto-compaction path introduced in 1.0.52-2 and verify that a multi-step task completes, while `/compact off` has the documented effect, without repeated compaction.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, powershell, shell
領域
cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。