[BUG] Context-compaction thrashing

Status Closed — not planned
Reported on v2.1.221
Maintainer reply None cached
Activity 4 comments · opened Aug 5, 2026 · closed Aug 23, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

After context compaction, Claude Code immediately re-sends the entire agent_listing_delta attachment in full (~110KB / ~27K tokens) rather than an actual incremental delta. In sessions with a large agent registry (e.g. the aide plugin, which adds ~30 additional subagents on top of built-ins), this full re-send happens on nearly every turn following a compaction. Combined with repeated open-file/IDE-selection attachments (~17-20KB per turn), this refills the context window almost immediately, triggering another compaction within a few turns. The result is a compaction "thrashing" loop — compaction fires repeatedly in rapid succession instead of the expected long gaps between compactions.

Steps to Reproduce

Ubuntu for OS and WSL for terminal

What Should Happen?

agent_listing_delta should only be sent when the actual agent/skill registry changes (new plugin loaded, agent added/removed), not automatically after every compaction event. Compaction's internal state reset (if any) that causes the harness to treat the full listing as "new again" should not force a full re-transmission — either the delta-tracking state should survive compaction, or the harness should recompute an actual delta (empty, in the common case where nothing changed) instead of dumping the full listing.

Error Messages/Logs

No explicit error is surfaced to the user; this is observable only in the session JSONL transcripts under ~/.claude/projects/<project>/*.jsonl. Evidence from one affected session (aebc905b-ba71-44c4-9f86-69bccae5d140.jsonl, 665 lines total):
 
$ grep -o '"type":"agent_listing_delta"' aebc905b-....jsonl | wc -l
25
$ grep -o '"isCompactSummary":true' aebc905b-....jsonl | wc -l
24
 
25 full agent-listing re-sends against 24 compactions — essentially 1:1, each ~109-110KB per occurrence (confirmed via line byte-size inspection). Three other sessions from the same project showed the identical 1:1 pattern (10/10, 12/13, 13/14 compactions vs. listing re-sends).

Steps to Reproduce

  1. Configure a Claude Code project with a plugin that registers a large number of subagents (e.g. the aide plugin, ~30 agents with full descriptions — pushes the agent listing to ~110KB serialized).
  2. Start a long interactive session in that project (VSCode extension entrypoint, claude-vscode) that involves enough tool calls / file reads to trigger normal context compaction at least once.
  3. After compaction fires, inspect the next few transcript lines in ~/.claude/projects/<project-slug>/<session-id>.jsonl for an attachment entry with "type":"agent_listing_delta".
  4. Observe that its payload is the full agent registry (~110KB), not a true delta, and that it reappears again after the very next compaction — with only a handful of turns in between each cycle.
  5. To quantify: run this on any transcript file:

grep -o '"isCompactSummary":true' <session>.jsonl | wc -l
grep -o '"type":"agent_listing_delta"' <session>.jsonl | wc -l

A 1:1 (or near 1:1) ratio between these two counts, recurring every 10-20 lines instead of once per session, indicates the thrashing loop.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.221 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗