Skip to content

Hand a claude session its mail through the hooks it already calls - #27

Merged
tdwd merged 1 commit into
mainfrom
deliver-messages
Oct 27, 2026
Merged

tdwd merged 1 commit into
mainfrom
deliver-messages

Conversation

@tdwd

@tdwd tdwd commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Agents had to be reminded to check the inbox. A claude session now reads new messages automatically: the coordinator answers the UserPromptSubmit, PostToolBatch and Stop hooks it already receives for the status dot with the waiting messages as additionalContext, plus a systemMessage naming the senders so the person watching sees each delivery.

  • The reply never carries a decision or a block. On Stop the context continues the turn, so mail that arrives as a turn ends is read before it stops.
  • Mail stays in the box, for the next event or inbox, inside a subagent, on a Stop already continuing, and past the size budget below Claude Code's 10,000-character cap.
  • Messages go out as JSON, so a body cannot pose as another sender's message.
  • Deck still never writes into a pane. An idle session reads its mail when its next turn starts; other agents still use inbox.

Checked: make race passes locally. TestLiveClaudeReadsMailWithoutAsking passed against claude 2.1.296 and fails with Stop delivery disabled. Each guard was removed in turn and a test went red. Not covered: a reply lost in transit loses its mail, and two agents messaging each other can keep each other busy. Not tried in a real terminal.

A session only read messages when told to call the inbox tool. The
coordinator now answers three of the hooks it already receives for the
status dot - UserPromptSubmit, PostToolBatch and Stop - with the
waiting messages as additionalContext and a systemMessage naming the
senders, so the person watching the pane sees each delivery. On Stop
the context continues the turn, and the state stays Working.

The reply never carries a decision or a block. Mail is held back, and
stays in the box for the next event or for inbox, inside a subagent
(agent_id set), on a Stop already continuing (stop_hook_active), and
past mailBudget, below Claude Code's 10,000-character context cap. The
messages go out as JSON, so a body cannot pose as a second message.

Each event gets its own endpoint because the reply names its event.
Deck still never writes into a pane, so an idle session reads its mail
when its next turn starts, and other agents still collect with inbox.
TestLiveClaudeReadsMailWithoutAsking proves claude 2.1.296 accepts the
reply at both ends of a turn; it fails with Stop delivery disabled.
@tdwd
tdwd merged commit 3b23839 into main Oct 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant