Agent Teams: SendMessage from background subagents silenced after context compaction — parent session never receives completion notifications

Resolved 💬 3 comments Opened Mar 3, 2026 by flavio-bongiovanni Closed Mar 7, 2026

Preflight Checklist

  • [x] I have searched existing issues and this is not fully covered by existing reports
  • [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?

When background Task agents (spawned with run_in_background: true and team_name) send messages to the team lead via SendMessage, those messages are permanently silenced after context compaction fires. The background agents continue executing normally and write their output files to disk, but SendMessage from the agent to the lead inbox is never delivered as a conversation turn. The parent session has no way to know the agents completed.

This is the asymmetric failure not fully described in #23620 or #29193:

  • #23620 covers the lead losing team awareness (can't send TO teammates)
  • #29193 covers TaskOutput/TaskStop handles orphaned (can't poll results)
  • This issue: Teammates can't send messages TO the lead — inbox delivery is broken for messages arriving post-compaction

The net result: a multi-agent research session (10 background voyager-researcher agents) ran successfully for ~20 minutes, all 10 agents completed and wrote output files to disk, but zero notifications arrived to the compacted session. The only way to detect completion was manual filesystem polling in a loop.

Steps to Reproduce

  1. Enable Agent Teams: "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" in .claude/settings.json
  2. Create a team: TeamCreate(team_name="my-team")
  3. Spawn 5-10 background agents: Task(subagent_type="...", team_name="my-team", name="agent-N", run_in_background=true, prompt="... send completion via SendMessage ...")
  4. Continue working in the lead session until context compaction fires automatically
  5. Wait for agents to complete
  6. Observe: Agents write output files normally, but no SendMessage notifications arrive to the lead session. SendMessage calls inside the agents return success, but the messages are never surfaced as conversation turns in the compacted session.

Expected Behavior

  • Background agents' SendMessage calls are delivered as conversation turns to the lead session even after compaction
  • OR: At minimum, the lead session should be warned that pending inbox messages exist from agents that completed before compaction was detected (similar to how CLAUDE.md is re-injected post-compaction)

Actual Behavior

After compaction, the lead session has no inbox poller active for the pre-compaction team. Messages sent by background agents via SendMessage are written to ~/.claude/teams/{name}/inboxes/team-lead.json with "read": false, but the compacted session never processes them. They accumulate silently.

The background agents themselves complete normally — their file-based outputs exist on disk. Only the notification channel is broken.

Root Cause Hypothesis

The inbox poller that monitors ~/.claude/teams/{name}/inboxes/team-lead.json is started at session init and does not survive the compaction boundary. The new (compacted) session would need to:

  1. Re-read ~/.claude/teams/{name}/config.json to discover active teams
  2. Re-start the inbox poller for each active team
  3. Surface queued "read": false messages as conversation turns

Workaround

Manual filesystem polling loop:

# Watch for output files instead of relying on SendMessage
while [ $(ls ~/.star/research/session-id/r*.md 2>/dev/null | wc -l) -lt 10 ]; do
  sleep 30
done

This is brittle and requires knowing the expected file count in advance.

Related Issues

  • #23620 — Agent team lost when lead's context gets compacted (same root cause, covers the send direction)
  • #29193 — Background task handles orphaned after context compaction (TaskOutput/TaskStop)
  • #29751 — Tasks persist as stale/in-progress after context compaction

Claude Model

Sonnet 4.6 (lead), Sonnet 4.6 + Opus 4.6 (background agents)

Is this a regression?

This never worked (confirmed behavior)

Claude Code Version

v2.1.59+ (Linux/WSL2)

Platform

Anthropic API (Max 20x subscription)

Operating System

Linux (WSL2 — Windows 11, kernel 6.6.87.2-microsoft-standard-WSL2)

Terminal/Shell

bash

Additional Information

  • Observed during a 10-agent research run (~20 min session) using Agent Teams with voyager-researcher subagent type
  • All 10 agents wrote output files successfully — filesystem I/O was unaffected
  • Zero of 10 SendMessage completion notifications arrived post-compaction
  • The session had gone through compaction once before spawning the agents; compaction fired again ~10 min into the run
  • Setting run_in_background: false would likely avoid this (agents would deliver messages synchronously before compaction fires), but sacrifices all parallelism for long research runs

View original on GitHub ↗

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