Skip to content

Auto-compaction starts on one usage reading that its own context breakdown contradicts #5393

Open

Description

@doomslayer2k

Describe the bug

A session about a third full shows "Compacting conversation…". One model call reported a doubled prompt (#5392), and the background compaction started on that single number — although the session.compaction_start event itself shows the runtime's own breakdown of the context well under the threshold:

trigger          threshold
currentTokens    790,176      (82% of 968,000)
breakdown        312,920      (system 45,606 + conversation 224,057 + tools 43,257) = 32%

The next call read 405,981 again.

Frequency: 21 of 251 threshold compactions in 5 days on one machine started this way. Three ran to completion and summarised sessions that were really 52–67% full; one fired at a reported 134%. The other 18 never completed — a local extension cancels such starts (confirmed in its log for 5 of them).

Extensions: the trigger is the runtime's own; an extension only observed it, and in some cases cancelled it.

Wanted labels: area:context-memory, type: Bug.

Affected version

Runtime 1.0.102-0.unstable.r41779900948.gf482387 (desktop app 1.1.35).

Steps to reproduce

Needs a doubled usage report, which is intermittent:

  1. Work in a Claude Opus 5.5 session at 30–60% of its window.
  2. When one call reports its prompt doubled, the next session.compaction_start (trigger: "threshold") fires with currentTokens ≈ 2× the event's own systemTokens + conversationTokens + toolDefinitionsTokens.

Expected behavior

One implausible reading does not start a compaction: the trigger count is checked against the runtime's own estimate of the same context, or confirmed by the next reading.

Additional context

App version         1.1.35
OS                  Windows 10 Enterprise 26H2 (build 26300.9711)
Architecture        AMD64
Copilot CLI         copilot-sdk-runtime-1.0.102-0.unstable.r41779900948.gf482387
In-depth investigation

What the trigger counts. Across 251 threshold starts, currentTokens equals the last parent request's input + output (p10–p90 1.00) — so one reported number decides.

The two populations do not overlap. currentTokens ÷ (system + conversation + tools) from the same event:

  • genuine starts: at most 1.27;
  • starts after a doubled report: at least 2.17.

A cut-off anywhere between them (e.g. 1.95), falling back to the breakdown, would have stopped all 21 and none of the 230 genuine ones.

Cost of the three that completed: unsteered summaries at a real 52–67% full, each discarding working context the session still had room for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:context-memoryContext window, memory, compaction, checkpoints, and instruction loading

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions