Agent teams: per-agent autocompact control + a protocol to compact a context-exhausted teammate
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:
- No remote compaction. The SendMessage protocol carries only
shutdown_request/plan_approval_response— there is nocompact_requestor any way for a lead to trigger compaction on a teammate.PreCompact/PostCompacthooks are session-internal. - No per-agent autocompaction scope.
autoCompactEnabled/autoCompactWindowexist 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/autoCompactWindowas subagent/teammate frontmatter fields (and/or Agent-tool spawn parameters), overriding global settings for that agent only. - Add a
compact_requestSendMessage protocol payload (mirroringshutdown_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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗