Agent with multi-destination addressing loses tool-use patterns after auto-compaction
Summary
When a NanoClaw agent has multiple wired destinations and auto-compaction fires, the compaction summary does not preserve the agent's <message to="name"> wrapping discipline. After compaction, the agent reverts to bare-text output or single-destination delivery even though:
- All destinations are still listed in the operator system prompt
- The agent's
CLAUDE.local.md(also in system prompt) explicitly instructs multi-destination wrapping - The destinations haven't changed
Behavior
Before compaction: Agent correctly wraps replies in <message to="dest-a">…</message> <message to="dest-b">…</message> blocks when addressing multiple channels.
After compaction: Agent emits bare text or addresses only one destination. The compaction summary appears to have summarized the tool-use pattern away — the agent "knows" it has destinations (they're in the system prompt) but no longer applies the wrapping behavior consistently.
Root cause hypothesis
The auto-compact summary is generated from conversation history. If the agent's <message to=…> blocks appear as boilerplate repeated across many turns, the compaction model may summarize them out as "noise" rather than preserving them as load-bearing behavioral instructions. The result is a summary that says "the agent has N destinations" (factual) but doesn't reinforce "the agent must wrap every reply in explicit <message to> blocks" (behavioral).
Impact
- Multi-destination agents silently drop messages to secondary channels after compaction
- Bare-text output routes through scratchpad fallback, delivering nothing
- Behavior is non-obvious: the agent appears to be working (it's generating output) but delivery is broken
Environment
- NanoClaw agent runtime (Bun/TypeScript, Claude Code SDK container)
- Observed with multiple wired destinations (WhatsApp + A2A peers)
- Reproduces after context exceeds auto-compact threshold (~152k tokens in default config)
- Auto-compact threshold:
CLAUDE_CODE_AUTO_COMPACT_WINDOWincontainer/agent-runner/src/providers/claude.ts:244
Mitigation
NanoClaw is implementing a host-side workaround: inject a destination reminder via query.push() when the compact_boundary SDK event fires, before the agent processes its next turn. This recovers the behavior but requires reliably detecting the event on the host side.
The underlying ask: auto-compact summaries should preserve behavioral instructions (tool-use patterns, output format requirements), not only factual context.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗