跪拜 Guibai
← All articles
Backend · Programmer · Artificial Intelligence

Claude Code Sessions Can Now Message Each Other Directly

By cxuanAI ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Multi-agent workflows have been held back by the friction of manually relaying context between sessions. Cross-session messaging turns independent Claude Code instances into a loosely coordinated team that can hand off findings and status autonomously, without the user becoming the clipboard.

Summary

A new cross-session messaging feature in Claude Code lets separate agent sessions hand off results, coordinate parallel worktrees, and report long-running task status without manual re-explanation. Sessions send concise, Claude-composed messages — not full conversation context — using `ListAgents` to discover peers and `SendMessage` to deliver the note. Local sessions communicate directly through inbox sockets without touching Anthropic's servers; cross-machine and web sessions route through the cloud but can only reply, not initiate.

Permissions are scoped carefully: incoming messages are tagged as agent-sent, cannot trigger permission approvals or config changes, and are governed by a `crosssessionInbound` setting that can accept, hold, or refuse them. Non-interactive `claude -p` sessions also bind an inbox socket and appear in the agent list.

The feature works on macOS, Linux, and WSL 2, requires no manual activation, and supports plain-text messages only, with duplicate suppression and a 50-message pending cap.

Takeaways
— Cross-session messaging ships in Claude Code v2.1.224 and requires no manual activation on macOS, Linux, or WSL 2; native Windows is unsupported.
— Messages carry only a plain-text summary composed by Claude, not the full conversation history, files, or context of the sending session.
— Four documented use cases: handing off discovery results, coordinating parallel worktrees, fetching long-running task status, and cross-machine replies.
— Local sessions communicate directly via inbox sockets registered in the filesystem; messages never leave the machine.
— Cross-machine and web sessions route through Anthropic's servers and can only reply to incoming messages, not initiate new ones.
— Containers and the host use separate filesystems, so sessions in different filesystem namespaces cannot discover each other unless they share a container.
— Incoming messages are explicitly marked as agent-sent and cannot authorize permissions, modify CLAUDE.md, or execute slash commands like /compact.
— The `crosssessionInbound` setting controls whether messages are accepted, held for approval, or refused; permission-mode mismatches trigger a hold by default.
— Non-interactive sessions launched with `claude -p` also bind an inbox socket and appear in `/list-agents`.
— Duplicate messages within a short window are discarded, and at most 50 pending messages are queued for Claude to read.
Conclusions

By refusing to bundle full context into messages, Anthropic forces a clean separation of concerns: each session stays lean, and the sender must articulate only what the receiver actually needs, which reduces noise and token waste.

The local-only socket architecture for same-machine messaging is a privacy and latency win, but the asymmetry — cross-machine sessions can only reply — makes remote-initiated coordination awkward and limits the feature to mostly local multi-agent setups for now.

Binding inbox sockets even for non-interactive `claude -p` sessions turns one-shot CLI invocations into addressable agents, which opens the door to scripted pipelines where batch jobs can notify a long-running planning session when they finish.

The permission model is deliberately conservative: agent-sent messages are treated as untrusted input, which is the correct posture for a feature that could otherwise become a vector for prompt-injection across sessions.

Concepts & terms
inbox socket
A local socket that Claude Code binds for each session to receive messages from other sessions on the same machine. Sessions register their socket address in a local file, which `ListAgents` reads to discover peers.
crosssessionInbound
A configuration setting that controls how a Claude Code session handles incoming cross-session messages. It accepts three values: `accept` (deliver directly to Claude), `hold` (queue for user approval), or `refuse` (discard).
ListAgents / SendMessage
Two internal tools Claude uses for cross-session messaging. `ListAgents` discovers reachable sessions, subagents, and remote peers; `SendMessage` delivers a composed message to a named recipient. Users trigger them with natural-language prompts rather than calling the tools directly.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗