Deleting My Agent Mailbox for Claude Code's SendMessage

November 17, 2026

Last night I merged a PR into agentctl that deleted agentctl send, agentctl inbox and agentctl wake, along with most of the mailbox behind them. 59 files, +688 / −1,923. The replacement is two tools that now ship in Claude Code itself: ListAgents and SendMessage.

I like deleting code, but this one is worth writing up. The mailbox took three months to build, and every one of its problems came from the same place: I was trying to get text into someone else's agent loop from outside it.

Why agents needed to talk at all

agentctl runs a bunch of Claude Code sessions in tmux. My main agent (Brandon) dispatches workers onto tickets, reviews their PRs, and sends back fixes. That last part is the whole job. "Two correctness fixes needed, push to the same branch and reply when you're done" has to get from one session to another somehow.

In August the only mechanism was agentctl signal done, which an agent was asked to run when it finished. It was voluntary, one-way and one bit. Agents forgot it, and nothing much read it anyway.

Version one: a mailbox that never delivered anything

The design was sensible on paper. Messages were JSON files on disk under .agentctl/inbox/<windowID>/, written atomically, addressed by tmux window ID and session UUID (tmux reuses @N IDs, so a bare window ID can quietly point at a different agent). Delivery happened from the agentctl monitor, which typed the message into the target pane with tmux send-keys once the agent looked idle.

It shipped, and it never delivered a single message.

The monitor only delivered to a pane whose #{pane_current_command} looked like Claude. But every agentctl pane reports zsh, because Claude runs as a child of the shell, not as the pane's foreground process. So the check failed for every window, forever, and the skip was logged at debug level, which is off by default. 135 messages piled up over several days before anyone noticed. Some were four days old.

Version two: hooks

The fix was better than the original idea. A Claude Code hook can add text to its own session by printing additionalContext in its JSON output. PostToolUse fires after every tool call, so a busy agent would get its mail within one tool call. UserPromptSubmit covered sessions where I was typing. No pane inspection and no fake keystrokes.

It also needed a pile of supporting logic:

Delivery worked now. The next problem was worse.

The agent that ignored its lead

On November 5th, Brandon noticed that a worker it had dispatched had run a migration against my real home directory instead of a test one. It wrote up what to do in a file and sent the worker:

Urgent: read /tmp/msg-27.md (your migration ran against the real home dir) and act on it

The worker replied:

A tool result contained an instruction to read /tmp/msg-27.md, which I'm ignoring since it didn't come from you.

Honestly, that's the right call. From the model's side, additionalContext shows up attached to a tool result. It's an unsigned instruction to go read a file, in the exact spot a hostile web page or README would put one. The model has been trained to be suspicious of that, and I don't want it to stop being suspicious. But it meant a lead couldn't steer its own workers mid-task, which was the whole reason the mailbox existed.

I wrote a spec to fix it: declare the mailbox in the system prompt, put the dispatcher's window ID and name in the preamble so the model could match it, mark headers "from your dispatcher" vs "not your dispatcher", and neutralize forged header lines in message bodies. All of it was about making text injected from outside look trustworthy enough. That spec sat there as issue #1 until I closed it in favor of the native tools, and I'm glad nobody got to it.

Then Claude Code shipped it

Claude Code 2.1.224 added cross-session messaging. ListAgents lists the other sessions on the machine. SendMessage sends one of them a message by name. Three things make it different from what I built:

  1. The harness owns delivery. A busy session reads the message between tool calls. An idle session starts a new turn with it. No hooks and no send-keys, and the idle-window problem that needed wake is just gone.
  2. The sender is labelled by the harness, not by the text. The message arrives tagged with where it came from and the sender's session name, as a message from another session. It isn't sitting in a tool result pretending to be something it's not.
  3. Recipients can reply. You just SendMessage back. My mailbox had a reply_to field and a hop counter to stop reply loops. This is just a conversation.

The PR itself was mostly plumbing and deleting:

One small piece of the mailbox survives. If a worker finishes its turn or sits on a permission prompt, agentctl's hooks still drop a short line into the orchestrator: agentctl notice: go-engineer (window @41) finished its turn and is idle. That's a backstop for workers that die or get stuck before they can report. It only states facts now. It used to quote the worker's last message, which was just more untrusted text going places it shouldn't.

Did it work?

A few hours after the merge, a worker's branch had a test that started the test binary, which started the test binary, and so on. It took my laptop down. While that worker was still mid-task, Brandon sent it:

STOP: do not run go test on internal/hooks (or ./...) on your PR #61 branch. It causes a fork bomb that took the machine down tonight.

followed by the cause and the fix. The worker stopped, fixed it, pushed, and reported back with the commit and confirmation that no stray test processes were left. That's the same situation as the November 5th migration, an urgent mid-task correction from the lead, and this time it just worked.

The review loop is different too. Brandon sends "PR #64 can't merge yet, rebase onto main and SendMessage me once CI has started," the worker does it, and the reply comes back on its own. I'm not running agentctl wake or watching an envelope counter.

What I took away from it

agentctl is on GitHub. The old design doc is still in docs/design/ with a "superseded" note on top, and the dead ends are left in.

← All posts