claude-code - 💡(How to fix) Fix Agent with multi-destination addressing loses tool-use patterns after auto-compaction

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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:

  1. All destinations are still listed in the operator system prompt
  2. The agent's CLAUDE.local.md (also in system prompt) explicitly instructs multi-destination wrapping
  3. The destinations haven't changed

Root Cause

Root cause hypothesis

Fix Action

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.

RAW_BUFFERClick to expand / collapse

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:

  1. All destinations are still listed in the operator system prompt
  2. The agent's CLAUDE.local.md (also in system prompt) explicitly instructs multi-destination wrapping
  3. 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_WINDOW in container/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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING