Agent-to-agent communication in Claude Code: every option, honestly compared
You have three terminals open. One session is refactoring the auth module, one is watching the test suite, one is on a different branch. None of them can see the other two, so you are the message bus: read a result here, paste a summary there, hope you didn’t drop the important half.
There are five practical ways to fix that, ordered here from the crudest to the most structured. Two are Claude Code features, one is a weekend of MCP work, one is a tmux trick, and one is a separate program. The last one is the project this blog belongs to, so treat its section accordingly.
A useful test for all five: does the message reach the right session, does the receiver know it didn’t come from you, and does it work when the receiver is busy?
Subagents are not one of the five. They run inside a single session and answer their caller; a subagent whose tools include SendMessage can also message main or a named sibling, but there is no shared channel and no registered address, so they are a delegation tool rather than a channel. If that is the distinction you are stuck on, the subagents versus agent teams comparison covers it in detail.
1. tmux send-keys
If both sessions run inside tmux, you can type into one from the other:
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_current_command}'
tmux send-keys -t work:1.1 -l -- 'auth migration failed, check src/db/migrate.ts'
tmux send-keys -t work:1.1 Enter
-l sends the string literally instead of interpreting words like Enter as key names, and -- stops tmux from reading a leading dash in your message as a flag.
What happens: keystrokes land in that pane’s terminal as if you typed them. Every limitation follows from that. There is no sender identity, no delivery state, and no reply path the receiver can use on its own. If the session is mid-turn, the text sits in the input line until the turn ends. If a permission prompt or a picker is open, the text goes into the dialog and may trigger an option. Multiline messages paste badly; for those, use tmux load-buffer and tmux paste-buffer.
Use it for a nudge between two sessions on one machine while you are watching both. Don’t build a protocol on it.
2. A shared MCP server as a queue
Write a small MCP server with post_message and read_messages tools, register it in both sessions, and add a line to CLAUDE.md telling the agent to check its inbox. Messages get a sender field, a timestamp and a history you can query. Any harness that speaks MCP can join.
The catch is structural: MCP is pull-based. A server cannot push a turn into a session. It can only answer a tool call, so an idle session will never see the message until something starts a turn. In practice you end up with a cron job that pokes the session, a claude -p --continue loop, or you pressing enter. You also own the schema, the retention policy and the cleanup, and every poll costs tokens.
That is still reasonable if you want an audit trail and explicit message types, and you already run MCP servers. It is a bad first move if all you want is “tell that session the tests passed”.
3. Agent teams
Claude Code can build its own coordinated group: one session acts as lead, spawns teammates with the Agent tool, and gives them a shared task list and a mailbox. Teammates message each other by name with SendMessage, receive messages automatically between turns, and notify the lead when they go idle. You can talk to any teammate directly.
This is the right tool when you want Claude to decompose the work and the workers should discuss it. It is experimental (it needs CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), one team per session, no nested teams, and the lead is fixed. Spawning needs an interactive session, so -p runs don’t form teams. Token spend scales with each teammate.
What it does not do is connect the sessions you already started. The team is a thing the lead creates, not a bus you can attach an unrelated terminal to.
4. Native cross-session messaging
The easiest one to overlook, because it is on by default. Claude Code 2.1.224 and later on macOS, Linux and WSL 2 (2.1.234 on native Windows, 2.1.248 on Bedrock and the other cloud providers when feature-flag fetching is off) lets one session message another through SendMessage, with ListAgents for discovery. Type /list-agents or /peers to see what a session can reach.
You don’t call the tools. You ask in prose (“tell the session working on the payments API that the schema migration finished”), or you type @ and pick the session from the typeahead (2.1.232 or later). Claude writes the message.
Each session binds a Unix domain socket on macOS and Linux, or a named pipe on native Windows, limited to your OS user, and peers deliver there. The receiver reads the message between tool calls during a turn, and starts a new turn when it is idle, so a busy session is not interrupted mid-tool. The receiving session’s permission prompts still apply, and crossSessionInbound controls whether it accepts, holds or refuses peer messages.
The documented limits are worth knowing before you rely on it. Plain text only. Roughly a million characters per message to a session on the same machine. Rapid bursts get refused at the sender; identical repeats get dropped; at most 50 accepted messages queue for Claude to read; message loops throttle themselves. Sessions on other machines are reachable only through Remote Control, which needs a claude.ai subscription on Pro, Max, Ultra, Team or Enterprise; API keys don’t work.
If everything you run is Claude Code and it’s current, start here. It needs no extra process and no configuration.
5. A local daemon (asenq)
asenq is a small local service built for the case the native feature doesn’t cover: sessions in different harnesses. A per-user daemon listens on ~/.asenq/asenq.sock (mode 0600) and stores sessions and messages in SQLite. Each installed harness gets wired to it (a Claude Code hook plus MCP attach, an OpenCode plugin, an omp extension), and delivery goes through whatever path that harness exposes. A message arrives as a labelled user turn, so the agent can see the sender, the message id and the kind, and is told it came from another agent rather than from you.
What you get beyond the native feature: one namespace across Claude Code, OpenCode and omp; a durable name per session that survives restarts; channel posts you read on demand; message history in SQLite; and a human address with an inbox and a TUI, so you are a participant rather than a switchboard.
asenq is not on npm yet and dist/ isn’t committed, so install from a checkout:
git clone https://github.com/parciffal/asenq.git
cd asenq
npm install
npm run build
npm link
asenq setup
asenq doctor
The npm install -g github:parciffal/asenq shorthand does not work yet, because the package has no build step on install. Setup edits JSON files (and backs each one up as <file>.asenq-bak first), and asenq setup --remove reverses it while keeping your history. It needs Node 22.13 or newer, or Bun, on macOS or Linux. It does not spawn sessions, track tasks, merge work or relay anything to a cloud, and it has no Windows support.
The honest cost: it is another daemon to keep running, another dependency in your setup, and it is at v0.1.0. If you only use Claude Code, native messaging covers most of what asenq does, and you should use that instead. asenq earns its place when your sessions aren’t all Claude Code, when you want to be a recipient yourself, or when names and history need to outlive a terminal.
The trade-offs
| Approach | Reaches a busy session | Receiver knows the sender | Across harnesses | Your reply path | Setup | Breaks when |
|---|---|---|---|---|---|---|
| tmux send-keys | Only if the pane is at a prompt | No | Yes, anything in a pane | Same trick, backwards | None | A dialog is open, or the text lands mid-turn |
| MCP queue | Only when it calls the tool | Yes, if you put it in the schema | Any MCP client | Write a tool for it | You write and host a server | Nobody polls |
| Agent teams | Yes, automatic | Yes, team mailbox | No | Message a teammate directly | Flag plus a current version | Experimental limits; one team per session |
| Native messaging | Yes, between tool calls | Yes, sender name and reply address | No | You asked for it, or Claude replies | None on 2.1.224+ | Claude-only; inbound policy can refuse |
| asenq | Yes, and starts a turn if idle | Yes, name, id and kind | Claude Code, OpenCode, omp | asenq send, inbox, TUI |
Install, setup, run a daemon | Daemon down; unsupported harness |
Choosing by situation
| Situation | What works | Why |
|---|---|---|
| Same repo, all Claude Code | Built-in messaging | No setup; sessions are addressable by name on one machine |
| Separate repos or worktrees, all Claude Code | Built-in messaging | Addressing is per session, not per directory |
| Claude Code plus OpenCode or omp | asenq | The built-in feature is Claude-only |
| You want one place to read and reply | asenq | The human has an address, an inbox and a TUI |
| One nudge while both panes are on screen | tmux | Nothing to install |
| Sessions on different machines | Built-in via Remote Control | asenq is one machine only |
How to pick
If everything is Claude Code and up to date, use the native feature. Learn /list-agents and forget the rest.
If your sessions are not all Claude Code, or you want your own inbox next to the agents, asenq is the narrower fit. It was written for exactly that gap.
For one quick nudge while watching two panes, tmux is fine and will stay fine.
For workers that should argue with each other over a job Claude decomposes, agent teams are the intended tool. Keep the experimental label in mind.
If you need an auditable log with message types and retention, an MCP queue you own does that, provided you accept polling as part of the design.
One thing none of these solve is comprehension. Delivery state proves the text arrived, not that the receiver read it, understood it, or acted on it. If the message matters, ask for a reply and check that it happened.
Related
- Can Claude Code sessions talk to each other? Three routes: /blog/claude-code-sessions-talk-to-each-other/
- How asenq delivers messages: /blog/how-asenq-delivers-messages/
- Subagents vs agent teams vs local messaging: /blog/claude-code-subagents-vs-agent-teams-vs-local-messaging/
- Run multiple Claude Code agents in parallel: /blog/run-multiple-claude-code-agents-in-parallel/
Sources
- Cross-session messaging (versions,
ListAgents, sockets, inbound controls, limits): https://code.claude.com/docs/en/cross-session-messaging - Agent teams (flag, mailbox, spawn rules, limitations): https://code.claude.com/docs/en/agent-teams
- tmux manual (
send-keys,load-buffer,paste-buffer): https://man.openbsd.org/tmux - Model Context Protocol specification (servers expose tools; clients call them): https://modelcontextprotocol.io/specification
- asenq install, setup and removal: https://github.com/parciffal/asenq
- asenq delivery mechanics: https://github.com/parciffal/asenq/blob/main/docs/how-delivery-works.md