Agent teams: per-agent autocompact control + a protocol to compact a context-exhausted teammate

Status Open
Reported on v2.1.225
Maintainer reply None cached
Activity 2 comments · opened Aug 14, 2026

Problem

Long-running agent-team teammates can hit hard context exhaustion: every inbound message — including a shutdown_request — fails with "Prompt is too long", and the lead's only documented remedy is to kill the process and spawn a replacement ("Spawn a replacement teammate to continue the work", agent-teams.md § troubleshooting). This just happened to me in practice: a teammate died mid-workflow after ~14 hours, and the replacement had to be re-briefed from scratch.

Two controls are missing:

  1. No remote compaction. The SendMessage protocol carries only shutdown_request / plan_approval_response — there is no compact_request or any way for a lead to trigger compaction on a teammate. PreCompact/PostCompact hooks are session-internal.
  2. No per-agent autocompaction scope. autoCompactEnabled / autoCompactWindow exist only at User/Project/Local/Managed scope, and subagent frontmatter has no compaction field. Users who deliberately disable autocompact for their interactive sessions (I do — I want control over when my primary context gets summarized) get it disabled for teammates too, since teammates inherit user settings — so teammates run straight into the raw ceiling. The obvious split — autocompact OFF for primaries, ON for teammates — is currently inexpressible.

Proposal

  • Accept autoCompactEnabled / autoCompactWindow as subagent/teammate frontmatter fields (and/or Agent-tool spawn parameters), overriding global settings for that agent only.
  • Add a compact_request SendMessage protocol payload (mirroring shutdown_request), handled by the harness rather than delivered as a prompt — so it still works when the teammate is already at the "Prompt is too long" ceiling.

Why

Agent teams are positioned for long-running, self-contained workflows, but teammate lifetime is currently hard-bounded by the context window with no in-band recovery. Kill-and-respawn discards the teammate's accumulated working context and forces re-briefing churn.

Environment: Claude Code 2.1.225, macOS.

View original on GitHub ↗

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