Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Agent Messages: a message taken at a tool call leaves the person a line in the pane (#1238)

Deed94ce114497a
diff --git a/cli/src/engines/kit/messagesHook.ts b/cli/src/engines/kit/messagesHook.ts
index 1c53f3568..48a6e43f6 100644
--- a/cli/src/engines/kit/messagesHook.ts
+++ b/cli/src/engines/kit/messagesHook.ts
@@ -3,7 +3,10 @@
* call, the messages waiting in its pane's inbox (messages/inbox.ts) become the model's context before its next
* request (`hookSpecificOutput.additionalContext` after PostToolUse: Claude Code 2.1.296, Codex 0.162.1). No
* keystroke reaches the pane, so a draft or a permission dialog is never touched, and a teammate's words never
- * arrive as the person's.
+ * arrive as the person's. Each message also leaves one line in the pane for the person (`systemMessage`, which
+ * neither engine gives the model): Claude Code draws it as "PostToolUse:Bash says: ← lead: …", Codex as
+ * "↳ Hook · ← lead: …". Without it a tab's agents traded messages while their panes showed nothing (owner,
+ * 2026-10-12: "i don't see the messages in the panes").
*
* Its own command, apart from notify.mjs, which stays free of model-visible output (#684,
* coreIsolation.spec.ts). The daemon writes the script itself, into the inbox root, rather than shipping a second
@@ -67,6 +70,7 @@ async function main() {
const claimed = join(root, 'claimed')
mkdirSync(claimed, { recursive: true, mode: 0o700 })
const texts = []
+ const notices = []
for (const name of names) {
const file = join(dir, name)
let item
@@ -79,12 +83,15 @@ async function main() {
if (typeof item.session === 'string' && item.session && session && item.session !== session) continue
try { renameSync(file, join(claimed, number + '-' + name)) } catch { continue }
texts.push(item.text)
+ if (typeof item.notice === 'string' && item.notice) notices.push(item.notice)
}
try { rmdirSync(dir) } catch { /* something still waits, or another hook emptied it */ }
if (!texts.length) return
const event = typeof input?.hook_event_name === 'string' ? input.hook_event_name : 'PostToolUse'
+ // The person sees a line per message in the pane (systemMessage), the model reads them whole (additionalContext).
+ const output = { ...(notices.length ? { systemMessage: notices.join('\\n') } : {}), hookSpecificOutput: { hookEventName: event, additionalContext: texts.join('\\n\\n') } }
// A pipe is written asynchronously on macOS: exit only once the engine has it all.
- await new Promise((resolve) => process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: texts.join('\\n\\n') } }), resolve))
+ await new Promise((resolve) => process.stdout.write(JSON.stringify(output), resolve))
}
main().catch(() => {}).finally(() => process.exit(0))
diff --git a/cli/src/messages/inbox.spec.ts b/cli/src/messages/inbox.spec.ts
index 5d85887a4..c8de8b26c 100644
--- a/cli/src/messages/inbox.spec.ts
+++ b/cli/src/messages/inbox.spec.ts
@@ -106,6 +106,18 @@ describe('the messages hook, as an engine runs it', () => {
expect(inbox.claimed('%2', '0note-abc')).toBe(true)
})
+ it('shows the person a line per message in the pane, and gives the model only the messages', () => {
+ // Claude Code draws systemMessage as "PostToolUse:Bash says: …", Codex 0.162.1 as "↳ Hook · …"; neither gives it
+ // to the model, and both still give it additionalContext (each run for real, 2026-10-12).
+ inbox.put('%8', '0note-abc', { session: '', text: 'the note' })
+ inbox.put('%8', 'm0000001-aaaa', { session: '', text: '[m1 from lead]\nfirst', notice: '← lead: first' })
+ inbox.put('%8', 'm0000002-bbbb', { session: '', text: '[m2 from web]\nsecond', notice: '← web · FYI: second' })
+ expect(JSON.parse(run('%8', { session_id: 's1', hook_event_name: 'PostToolUse' }).out)).toEqual({
+ systemMessage: '← lead: first\n← web · FYI: second',
+ hookSpecificOutput: { hookEventName: 'PostToolUse', additionalContext: 'the note\n\n[m1 from lead]\nfirst\n\n[m2 from web]\nsecond' },
+ })
+ })
+
it('leaves another conversation\'s messages, and a Claude Code sub-agent\'s tool call takes nothing', () => {
inbox.put('%6', 'mine', { session: 'parent', text: 'for the parent' })
inbox.put('%6', 'anyone', { session: '', text: 'for whoever' })
diff --git a/cli/src/messages/inbox.ts b/cli/src/messages/inbox.ts
index 902752fd4..2a0e08e1f 100644
--- a/cli/src/messages/inbox.ts
+++ b/cli/src/messages/inbox.ts
@@ -13,8 +13,9 @@ import { chmodSync, mkdirSync, readdirSync, renameSync, rmdirSync, rmSync, statS
import { join } from 'node:path'
/** What one inbox file holds: the text, and the engine conversation it is for. A hook in any other conversation
- * (a Codex sub-agent runs its hooks from its parent's pane) leaves it. */
-export interface InboxItem { session: string; text: string }
+ * (a Codex sub-agent runs its hooks from its parent's pane) leaves it. `notice` is the line the pane shows the
+ * person when the hook takes it, never given to the model. */
+export interface InboxItem { session: string; text: string; notice?: string }
const PANE = /^%(\d{1,9})$/
const KEY = /^[0-9a-z._-]{1,120}$/
diff --git a/cli/src/messages/mailbox.spec.ts b/cli/src/messages/mailbox.spec.ts
index ec744402b..f178cddcd 100644
--- a/cli/src/messages/mailbox.spec.ts
+++ b/cli/src/messages/mailbox.spec.ts
@@ -1,10 +1,10 @@
-import { mkdirSync, mkdtempSync, renameSync, rmSync } from 'node:fs'
+import { mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { PaneInbox } from './inbox.js'
import { ATTEMPT_MS, deliveryKey, FINISHED_KEEP_MS, FYI_REASON, HOOKLESS_MS, HOOKLESS_REASON, Mailbox, MAX_BACKOFF_MS, PARK_MS, PARKED_MAX_MS, PUMP_MS, WITHHELD, type MailboxAgent, type MailboxDeps } from './mailbox.js'
-import type { DeliveryStatus, Message } from './model.js'
+import { NOTICE_TEXT, paneNotice, type DeliveryStatus, type Message } from './model.js'
import { MessageStore } from './store.js'
let root: string
@@ -133,6 +133,21 @@ describe('Agent Messages\' mailbox', () => {
expect(t.delivered.filter(([, , id]) => id.includes(parked.key))).toHaveLength(1)
})
+ it('leaves the person a line in the pane for each message the hook gives the model', () => {
+ // A tab's agents traded messages at their tool calls while their panes showed nothing (owner, 2026-10-12).
+ const t = setup()
+ const delivery = t.accept({ ...message(), fyi: true })
+ const item = JSON.parse(readFileSync(join(root, 'agent-messages', 'inbox', '3', `${delivery.key}.json`), 'utf8'))
+ expect(item.notice).toBe('← lead · FYI: review 3f2a9c1')
+ expect(item.text).toContain('review 3f2a9c1')
+ // Its first line that says something, on one line, cut short.
+ expect(paneNotice({ ...message(), text: '\n \nQuiet window starts now\nuntil 06:16Z' })).toBe('← lead: Quiet window starts now')
+ const long = paneNotice({ ...message(), text: 'x'.repeat(500) })
+ expect(long).toBe(`← lead: ${'x'.repeat(NOTICE_TEXT - 1)}…`)
+ expect(paneNotice({ ...message(), text: 'short' })).toBe('← lead: short')
+ expect(paneNotice({ ...message(), text: '' })).toBe('← lead: ')
+ })
+
it('never types news into an idle agent: it waits for its next tool call, or for the agent to read it', () => {
// Six quiet-window notices in 45 minutes each woke an idle teammate for a turn that said only "noted" (2026-10-12).
const t = setup()
diff --git a/cli/src/messages/mailbox.ts b/cli/src/messages/mailbox.ts
index fa1a90853..f68692cd8 100644
--- a/cli/src/messages/mailbox.ts
+++ b/cli/src/messages/mailbox.ts
@@ -18,7 +18,7 @@ import type { TurnDelivery } from '../core/api.js'
import { isMessageHold } from '../lib/messageHolds.js'
import { TERMINAL_LEASE_REFUSED } from '../lib/terminalTypes.js'
import type { PaneInbox } from './inbox.js'
-import type { DeliveryStatus, Message } from './model.js'
+import { paneNotice, type DeliveryStatus, type Message } from './model.js'
import type { LocalDelivery, MessageStore } from './store.js'
export const PUMP_MS = 2_000
@@ -293,7 +293,7 @@ export class Mailbox {
}
private put(delivery: LocalDelivery, message: Message, agent: MailboxAgent): void {
- try { this.deps.inbox.put(agent.pane, delivery.key, { session: agent.session, text: this.deps.text(delivery, message) }) }
+ try { this.deps.inbox.put(agent.pane, delivery.key, { session: agent.session, text: this.deps.text(delivery, message), notice: paneNotice(message) }) }
catch { /* the next pump puts it again */ }
}
diff --git a/cli/src/messages/model.ts b/cli/src/messages/model.ts
index 715f95db1..23e85b3a4 100644
--- a/cli/src/messages/model.ts
+++ b/cli/src/messages/model.ts
@@ -122,6 +122,16 @@ export function rendered(message: Message): string {
return `${header(message)}\n${message.text}`
}
+/** How long the pane's line for a message is: its sender and the start of its first line. */
+export const NOTICE_TEXT = 120
+
+/** The line a message leaves in its recipient's pane when the hook gives it to the model, for the person. */
+export function paneNotice(message: Message): string {
+ const first = message.text.split('\n').map((line) => line.replace(/\s+/g, ' ').trim()).find(Boolean) ?? ''
+ const line = first.length > NOTICE_TEXT ? `${first.slice(0, NOTICE_TEXT - 1)}…` : first
+ return `← ${message.from.name}${message.fyi ? ' · FYI' : ''}: ${line}`
+}
+
/** One teammate in the note. */
export interface Teammate { name: string; engine: string; machine: string; where?: string }
diff --git a/docs/design/2026-10-10-agent-messages.md b/docs/design/2026-10-10-agent-messages.md
index 5cd5601df..232b6de67 100644
--- a/docs/design/2026-10-10-agent-messages.md
+++ b/docs/design/2026-10-10-agent-messages.md
@@ -86,6 +86,11 @@ The recipient's conversation shows the message under one header line; the sender
call and the state it reached. The pane headers show `→ agent1` on the sender and `← lead` on the
recipient for a few seconds.
+A message the hook gives a working agent goes to the model whole, and leaves the person one line in the pane:
+its sender and the start of its first line (`systemMessage`, which neither engine gives the model). Claude Code
+draws it as `PostToolUse:Bash says: ← lead: Review of 3f2a9c1…`, Codex as `↳ Hook · ← lead: Review of 3f2a9c1…`.
+Before it, the owner watched a tab's agents trade messages while their panes showed nothing (2026-10-12).
+
```
[m12 from lead · Codex · studio]
Review of 3f2a9c1: the cleanup leaves workers running when the coordinator exits first…