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: one Settings ▸ Agents switch, on by default, instead of each tab's icon (#1267)

Dee3cff0433602b
diff --git a/README.md b/README.md
index b9eb9990c..078c0ff73 100644
--- a/README.md
+++ b/README.md
@@ -73,8 +73,8 @@ for workloads, slow tails, connection failures and raw data.
In the workspace, a **harness** is one running session of an agent such as Codex
or Claude Code, with its own conversation and working context. A **tab** groups
harnesses. Use **New Harness** to start one and **New Tab** to group work.
-Turn on **Agent Messages** for a tab (its chat icon, or right-click the tab) to let its
-agents message each other with `harness send`; it is off by default.
+Harnesses in the same tab can message each other with `harness send`: **Agent Messages**,
+on by default, and turned off in Settings ▸ Agents.
The Store offers **harnesses** with instructions, tools, and optional viewers for
specific crafts. Install a harness, then start it in your workspace. See the
diff --git a/cli/AGENTS.md b/cli/AGENTS.md
index fae72aa46..740dc3703 100644
--- a/cli/AGENTS.md
+++ b/cli/AGENTS.md
@@ -33,7 +33,7 @@ they show as `harnessd`, `harnessd-core` and `harnessd-<process>` (`src/harnessd
| models | grid, local models, the Model Manager | on demand: once grid is in use here (a managed grid, saved grid pictures, local models), or on a models request |
| updater | checks, downloads and stages a new build (`src/services/updaterProcess.ts`) | by the master, for the installed copy only |
| devices | the dials, the window bridges, the fleet, the voice router, the Wi-Fi device | on demand: once there is a device |
-| orchestrator, messages (Agent Messages), sharing, memory, router | the experiments | on demand: on a request, or saved state at start |
+| orchestrator, messages (Agent Messages), sharing, memory, router | the experiments | on demand: on a request, or saved state at start; messages also at start while Settings ▸ Agents has it on (the default) |
`HARNESSD_SERVICES` names a subset to run in their own processes, by service or by process.
`HARNESSD_SERVICES=none` runs every service in the core's process, for debugging or a quick way back. How
diff --git a/cli/README.md b/cli/README.md
index d65c0d5ca..3123da3f9 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -30,8 +30,9 @@ Windows is not supported.
## Agent Messages
-Harnesses in the same tab can message each other once **Agent Messages** is on for that tab (the chat icon on the tab;
-off by default). An agent runs, in its own pane:
+Harnesses in the same tab can message each other while **Agent Messages** are on: one switch per computer, in
+Settings ▸ Agents, on by default. From a terminal, `harness settings agent-messages off` (or `on`) turns it, and
+`harness settings` alone lists every setting. An agent runs, in its own pane:
```bash
harness send # who is in this tab, and how to work together
@@ -40,8 +41,8 @@ harness send api,web --text-file /tmp/note.md # a longer message, from the tem
harness send web --fyi "Staging is free until 15:00" # news: it starts no turn of theirs
```
-The pane says who is sending; a message goes only to harnesses that share a tab with Agent Messages on, on this
-machine or another of the owner's paired machines. A working agent reads it at its next tool call, through
+The pane says who is sending; a message goes only to harnesses that share a tab with the sender, on this machine
+or another of the owner's paired machines, while each of the two computers has Agent Messages on. A working agent reads it at its next tool call, through
Harness's PostToolUse hook, with nothing typed into its pane; an idle agent gets it as a prompt, typed only into
an empty composer. Each message arrives under one header line naming its sender, never as the person's words,
and waits until it is delivered. See the [design](../docs/design/2026-10-10-agent-messages.md).
diff --git a/cli/e2e/agentClient.e2e.ts b/cli/e2e/agentClient.e2e.ts
index cba4fce7e..8596da514 100644
--- a/cli/e2e/agentClient.e2e.ts
+++ b/cli/e2e/agentClient.e2e.ts
@@ -1,11 +1,11 @@
/**
* Harness for agents on the real daemon (docs/design/2026-10-11-agent-client.md): an agent, from its own pane, runs
* the `harness` verbs as it would through its shell tool. It lists the harnesses, starts one with a task, waits for
- * it, reads its answer, and closes it; it may not close one it did not start. Neither may message the other while no
- * tab has Agent Messages on (owner, 2026-10-11: Agent Messages off means off). The fake engines answer by echoing (harness/fakeEngine.mjs). A harness it starts says so in the pull
+ * it, reads its answer, and closes it; it may not close one it did not start. Neither may message the other while
+ * they share no tab (owner, 2026-10-11: Agent Messages off means off). The fake engines answer by echoing (harness/fakeEngine.mjs). A harness it starts says so in the pull
* requests it opens: in the arguments its engine is launched with, each launch, until the person turns it off.
*
- * Signed in to the fake backend, which answers the account's tabs: none has Agent Messages on.
+ * Signed in to the fake backend, which answers the account's tabs: there are none.
*/
import { execFileSync, spawn } from 'node:child_process'
import { createInterface } from 'node:readline'
@@ -73,7 +73,7 @@ describe('Harness for agents, end to end', () => {
await backend?.close(); backend = undefined
})
- it('an agent sees, starts, waits for, reads and closes a harness of its own, and may not message it with Agent Messages off', async () => {
+ it('an agent sees, starts, waits for, reads and closes a harness of its own, and may not message it outside a shared tab', async () => {
const relay = await FakeBackend.start()
backend = relay
relay.addMachine(ME)
@@ -134,9 +134,10 @@ describe('Harness for agents, end to end', () => {
expect(shown.out).toContain('hello kid')
expect((await run('ps')).out).toMatch(/\nkid +Claude Code +\w+ +you /)
- // No tab has Agent Messages on: neither messages the other, either way, as for any two harnesses. Since #1180 the
- // two messaged each other with no tab, and the owner found agents talking before turning Agent Messages on.
- const off = 'Agent Messages are off in this tab. The person turns them on with the chat icon on the tab'
+ // They share no tab: neither messages the other, either way, as for any two harnesses, though Agent Messages are on
+ // (Settings ▸ Agents, the default). Since #1180 the two messaged each other with no tab, and the owner found agents
+ // talking before turning Agent Messages on.
+ const off = 'No other harness is in this tab. The person puts harnesses in one tab for them to message each other.'
const sent = await run('send', 'kid', 'Also check the footer.')
expect(sent.code, sent.out + sent.err).toBe(1)
expect(sent.err).toContain(off)
@@ -149,7 +150,10 @@ describe('Harness for agents, end to end', () => {
const back = await harness(d, String(kid.tmuxPane), ['send', 'lead', 'Footer checked.'])
expect(back.code, back.out + back.err).toBe(1)
expect(back.err).toContain(off)
- expect((await harness(d, String(kid.tmuxPane), ['send'])).err).toContain(off)
+ // Nor does `harness send` alone name the other.
+ const listed = await harness(d, String(kid.tmuxPane), ['send'])
+ expect(listed.code, listed.err).toBe(0)
+ expect(listed.out.trim()).toBe('No teammates in this tab yet.')
// It closes what it started, and only that; the harness it started may not close it.
const own = await run('close', 'lead')
@@ -523,7 +527,7 @@ describe('Harness for agents, end to end', () => {
expect(JSON.parse(listed.out).harnesses).toEqual([])
// The setting is the daemon's, as the window reads it.
const read = await fetch(`http://127.0.0.1:${d.port}/api/agent-settings`)
- expect(await read.json()).toEqual({ agentsStartAgents: false, pullRequestLine: true })
+ expect(await read.json()).toEqual({ agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
})
it('a harness an agent starts says so in the pull requests it opens, on every launch, until the person turns it off', async () => {
const relay = await FakeBackend.start()
diff --git a/cli/e2e/agentMessages.e2e.ts b/cli/e2e/agentMessages.e2e.ts
index a33dd5a71..86fecd2e3 100644
--- a/cli/e2e/agentMessages.e2e.ts
+++ b/cli/e2e/agentMessages.e2e.ts
@@ -1,17 +1,21 @@
/**
- * Agent Messages on the real daemon (docs/design/2026-10-10-agent-messages.md): its own process, started only once
- * it is used; a message typed into an idle agent through the core's safe input; and a message reaching a working
- * agent through its PostToolUse hook at its next tool call, with nothing typed into its pane. The fake engines run
- * the hooks the daemon installed, as both CLIs do (harness/fakeEngine.mjs, `!work`).
+ * Agent Messages on the real daemon (docs/design/2026-10-10-agent-messages.md): its own process, started with the
+ * core while Settings ▸ Agents has it on (the default), and otherwise only once it is used; a message typed into an
+ * idle agent through the core's safe input; and a message reaching a working agent through its PostToolUse hook at
+ * its next tool call, with nothing typed into its pane. The fake engines run the hooks the daemon installed, as both
+ * CLIs do (harness/fakeEngine.mjs, `!work`).
*
- * The directory of tabs comes from the account: the daemon is signed in to the fake backend, which answers it.
+ * The directory of tabs comes from the account: the daemon is signed in to the fake backend, which answers it. Each
+ * tab's own flag, which older windows still turn, is no part of it: one switch per computer decides (owner,
+ * 2026-10-12).
*/
-import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { afterEach, describe, expect, it, onTestFailed } from 'vitest'
import { LocalClient, type Frame } from './harness/client.js'
import { IsolatedDaemon, until } from './harness/daemon.js'
import { FakeBackend, type FakeMachine } from './harness/fakeBackend.js'
+import { writeAgentSettings } from '../src/lib/agentSettings.js'
/** Signed in to the fake backend, which answers the account's tabs (`GET /api/agent-messages`). */
const ME: FakeMachine = { machineId: 'a7'.repeat(16), computerId: 'e2e-computer-0000-0000-0000000000a7', name: 'studio', token: 'e2e-token-messages' }
@@ -34,6 +38,16 @@ async function create(d: IsolatedDaemon, client: LocalClient, folder: string, en
}, 60_000, 500)
}
const starts = (d: IsolatedDaemon) => [...d.log().matchAll(/\[harnessd\] service messages started/g)].length
+/** Settings ▸ Agents, as the window turns a switch: through the daemon, which wakes what it turned on. */
+const settings = (d: IsolatedDaemon, body: Record<string, boolean>) => fetch(`http://127.0.0.1:${d.port}/api/agent-settings`, {
+ method: 'PATCH', headers: { 'x-adapter-local': '1', 'content-type': 'application/json' }, body: JSON.stringify(body) })
+/** The notes waiting in the agents' inboxes, by agent, once there are [count]. */
+const notesFor = (d: IsolatedDaemon, count: number) => until(`${count} agents' notes`, () => {
+ try {
+ const state = JSON.parse(readFileSync(join(d.dataDir, 'agent-messages', 'state.json'), 'utf8')) as { notes: Record<string, unknown> }
+ return Object.keys(state.notes).length === count ? state.notes : null
+ } catch { return null }
+}, 30_000, 500)
const statusOf = async (client: LocalClient, id: string) => {
const history = await client.request<{ messages?: Array<{ id: string; statuses: Array<Record<string, unknown>> }> }>('agent_messages', { action: 'history' }, 30_000)
return history.messages?.find((m) => m.id === id)?.statuses[0] ?? null
@@ -58,8 +72,8 @@ describe('Agent Messages, end to end', () => {
return d
}
- it('off, it has no process; its first request starts it, and is answered', async () => {
- const d = await fresh()
+ it('turned off in Settings ▸ Agents, it has no process; its first request starts it, and is answered', async () => {
+ const d = await fresh((daemon) => writeAgentSettings(daemon.dataDir, { agentMessages: false }))
const client = await LocalClient.connect(d)
await until('the services to connect', () => d.log().includes('[services] search connected') || null, 30_000, 200)
expect(starts(d), 'an experiment no one used').toBe(0)
@@ -70,13 +84,17 @@ describe('Agent Messages, end to end', () => {
client.close()
})
- it('its saved state turns it on as the daemon starts', async () => {
- const d = await fresh((daemon) => mkdirSync(join(daemon.dataDir, 'agent-messages'), { recursive: true }))
+ it('its saved state turns it on as the daemon starts, even turned off in Settings ▸ Agents', async () => {
+ // What waits there is held, then failed, rather than left behind.
+ const d = await fresh((daemon) => {
+ mkdirSync(join(daemon.dataDir, 'agent-messages'), { recursive: true })
+ writeAgentSettings(daemon.dataDir, { agentMessages: false })
+ })
await until('Agent Messages to start for its saved state', () => d.log().includes('[services] messages connected') || null, 30_000, 200)
expect(starts(d)).toBe(1)
})
- /** Signed in to the fake backend, with lead and api in one tab whose Agent Messages are on. */
+ /** Signed in to the fake backend, with lead and api in one tab. */
const team = async (engine = 'claude') => {
const relay = await FakeBackend.start()
backend = relay
@@ -85,40 +103,61 @@ describe('Agent Messages, end to end', () => {
const client = await LocalClient.connect(d, { machineId: ME.machineId })
const lead = await create(d, client, 'lead')
const api = await create(d, client, `api-${engine}`, engine)
- const tabs = (enabled: boolean) => ({ revision: 1, machines: [{ machineId: ME.machineId, name: 'studio' }],
- tabs: [{ id: 'app', name: 'app', enabled, panes: [lead, api].map((agent) => ({ machineId: ME.machineId, agentId: agent.id })) }] })
- relay.agentMessages = tabs(true)
+ relay.agentMessages = { revision: 1, machines: [{ machineId: ME.machineId, name: 'studio' }],
+ tabs: [{ id: 'app', name: 'app', panes: [lead, api].map((agent) => ({ machineId: ME.machineId, agentId: agent.id })) }] }
const roster = await client.request('agent_messages', { action: 'send', pane: lead.tmuxPane }, 40_000)
expect(roster.roster, JSON.stringify(roster)).toContain('Agent Messages are on in tab "app"')
const apiName = String(roster.roster).split('\n')[1].trim().split(/\s{2,}/)[0]
const send = (text: string) => client.request('agent_messages', { action: 'send', pane: lead.tmuxPane, to: [apiName], text }, 40_000)
- return { d, relay, client, lead, api, apiName, tabs, send }
+ return { d, relay, client, lead, api, apiName, send }
}
- it('starts once a tab is turned on here, with no other request, and gives the tab\'s agents their note', async () => {
- // On one machine nothing else started it, and no agent heard of `harness send` (a fresh Mac, 2026-10-12).
+ it('on by default, it starts with a fresh daemon, with no request and no saved state, and gives two agents in one tab their note', async () => {
+ // Each tab had a switch of its own, off by default, which the owner hit by mistake: one setting replaced it, on by
+ // default (2026-10-12). Started only by a request or saved state, on one machine nothing started it, and no agent
+ // heard of `harness send` (a fresh Mac, 2026-10-12).
const relay = await FakeBackend.start()
backend = relay
relay.addMachine(ME)
const d = await fresh(signIn, { BACKEND_WS_URL: relay.wsUrl, WEB_URL: relay.httpUrl, ADAPTER_COMPUTER_ID: ME.computerId })
+ expect(existsSync(join(d.dataDir, 'agent-settings.json')), 'the default, never written').toBe(false)
+ await until('Agent Messages to start for its setting', () => starts(d) === 1 || null, 30_000, 200)
+ const client = await LocalClient.connect(d, { machineId: ME.machineId })
+ const lead = await create(d, client, 'lead')
+ const api = await create(d, client, 'api')
+ // The tab as a window that never turned anything on writes it: no flag, or one left off, is all the same.
+ relay.agentMessages = { revision: 1, machines: [{ machineId: ME.machineId, name: 'studio' }],
+ tabs: [{ id: 'app', name: 'app', enabled: false, panes: [lead, api].map((agent) => ({ machineId: ME.machineId, agentId: agent.id })) }] }
+ // Each agent's note waits in its inbox for its next tool call; read again at its 15-second look.
+ const notes = await notesFor(d, 2)
+ expect(Object.keys(notes).sort()).toEqual([lead.id, api.id].sort())
+ expect(starts(d)).toBe(1)
+ client.close()
+ })
+
+ it('starts once Settings ▸ Agents turns it on, with no other request; an older window\'s tab switch starts nothing', async () => {
+ const relay = await FakeBackend.start()
+ backend = relay
+ relay.addMachine(ME)
+ const d = await fresh((daemon) => { signIn(daemon); writeAgentSettings(daemon.dataDir, { agentMessages: false }) },
+ { BACKEND_WS_URL: relay.wsUrl, WEB_URL: relay.httpUrl, ADAPTER_COMPUTER_ID: ME.computerId })
const client = await LocalClient.connect(d, { machineId: ME.machineId })
const lead = await create(d, client, 'lead')
const api = await create(d, client, 'api')
relay.agentMessages = { revision: 1, machines: [{ machineId: ME.machineId, name: 'studio' }],
tabs: [{ id: 'app', name: 'app', enabled: false, panes: [lead, api].map((agent) => ({ machineId: ME.machineId, agentId: agent.id })) }] }
await until('the services to connect', () => d.log().includes('[services] search connected') || null, 30_000, 200)
- const turn = (enabled: boolean) => fetch(`http://127.0.0.1:${d.port}/api/agent-messages/tabs/app`, {
- method: 'PATCH', headers: { 'x-adapter-local': '1', 'content-type': 'application/json' }, body: JSON.stringify({ enabled }) })
- expect((await turn(false)).status).toBe(200)
+ // An older window's chat icon still reaches the backend, and decides nothing here.
+ const tab = await fetch(`http://127.0.0.1:${d.port}/api/agent-messages/tabs/app`, {
+ method: 'PATCH', headers: { 'x-adapter-local': '1', 'content-type': 'application/json' }, body: JSON.stringify({ enabled: true }) })
+ expect(tab.status).toBe(200)
+ expect((await settings(d, { pullRequestLine: true })).status).toBe(200)
await new Promise((settle) => setTimeout(settle, 1_000))
- expect(starts(d), 'turned off, nothing starts').toBe(0)
- expect((await turn(true)).status).toBe(200)
- await until('Agent Messages to start for the tab turned on', () => starts(d) === 1 || null, 30_000, 200)
- // Each agent's note waits in its inbox for its next tool call.
- const notes = await until('both agents\' notes', () => {
- const state = JSON.parse(readFileSync(join(d.dataDir, 'agent-messages', 'state.json'), 'utf8')) as { notes: Record<string, unknown> }
- return Object.keys(state.notes).length === 2 ? state.notes : null
- }, 30_000, 500)
+ expect(starts(d), 'off in Settings ▸ Agents, nothing starts').toBe(0)
+ const on = await settings(d, { agentMessages: true })
+ expect(await on.json()).toMatchObject({ agentMessages: true })
+ await until('Agent Messages to start for the setting turned on', () => starts(d) === 1 || null, 30_000, 200)
+ const notes = await notesFor(d, 2)
expect(Object.keys(notes).sort()).toEqual([lead.id, api.id].sort())
client.close()
})
@@ -165,8 +204,8 @@ describe('Agent Messages, end to end', () => {
client.close()
})
- it('sends from one harness\'s pane to its teammate in a tab with Agent Messages on, and refuses once the tab turns off', async () => {
- const { relay, client, api, apiName, tabs, send } = await team()
+ it('sends from one harness\'s pane to its teammate in its tab, and refuses once Agent Messages are turned off', async () => {
+ const { d, client, api, apiName, send } = await team()
const started = client.next((frame: Frame) => frame.type === 'turn_started' && frame.agentId === api.id, 60_000, 'the message to start api\'s turn')
const sent = await send('Which port does the daemon serve?')
expect(sent).toMatchObject({ tab: 'app', recipients: [{ name: apiName }] })
@@ -175,11 +214,11 @@ describe('Agent Messages, end to end', () => {
// Its last messages come back with the roster.
const roster = await client.request('agent_messages', { action: 'send', pane: api.tmuxPane }, 40_000)
expect(roster.recent).toEqual([expect.objectContaining({ id: sent.id, from: expect.any(String), state: 'delivered' })])
- // A pane that is no harness says so; and with the tab turned off, nothing is sent.
+ // A pane that is no harness says so; and with Agent Messages turned off in Settings ▸ Agents, nothing is sent.
expect(await client.request('agent_messages', { action: 'send', pane: '%999', to: [apiName], text: 'x' }, 40_000)).toMatchObject({ error: 'NOT_A_HARNESS' })
- relay.agentMessages = tabs(false)
+ expect((await settings(d, { agentMessages: false })).status).toBe(200)
await new Promise((settle) => setTimeout(settle, 2_500))
- expect(await send('still there?')).toMatchObject({ error: 'MESSAGES_OFF' })
+ expect(await send('still there?')).toMatchObject({ error: 'MESSAGES_OFF', detail: expect.stringContaining('Settings ▸ Agents') })
client.close()
})
})
diff --git a/cli/e2e/harness/fakeBackend.ts b/cli/e2e/harness/fakeBackend.ts
index 7a958db70..54479a8f1 100644
--- a/cli/e2e/harness/fakeBackend.ts
+++ b/cli/e2e/harness/fakeBackend.ts
@@ -4,8 +4,9 @@
* that leaves this machine.
*
* - `GET /api/machines`: the account's machines, each `running` or `offline` as the test says.
- * - `GET /api/agent-messages`: the account's tabs and their Agent Messages flag, as the test sets them.
- * - `PATCH /api/agent-messages/tabs/:id`: one tab's flag turned, as a window turns it through its daemon.
+ * - `GET /api/agent-messages`: the account's tabs and who is in each, as the test sets them.
+ * - `PATCH /api/agent-messages/tabs/:id`: one tab's old Agent Messages flag turned, as an older window turns it
+ * through its daemon; no daemon reads it now (Settings ▸ Agents decides).
* - `/api/adapter-ws`: each daemon's own socket, as the node of its machine. Frames for it arrive as
* `{t:'down', connId, frame}`; what it sends comes back as `{t:'up', targetConnId?, commanderEligible?, frame}`.
* - `/api/device-ws`: a daemon's lane to its owner's other machines, as a device holding a commander
@@ -81,7 +82,7 @@ const bytes = (raw: RawData): Uint8Array => new Uint8Array(Array.isArray(raw) ?
export class FakeBackend {
readonly seen: string[] = []
- /** What `GET /api/agent-messages` answers: the account's tabs with Agent Messages on or off; null, a 404. */
+ /** What `GET /api/agent-messages` answers: the account's tabs and who is in each; null, a 404. */
agentMessages: Record<string, unknown> | null = null
private readonly machines = new Map<string, FakeMachine>()
private readonly online = new Map<string, boolean>()
diff --git a/cli/src/agentClient/commands.ts b/cli/src/agentClient/commands.ts
index 29c44e5b4..42472ceb5 100644
--- a/cli/src/agentClient/commands.ts
+++ b/cli/src/agentClient/commands.ts
@@ -857,8 +857,8 @@ export async function agentOrigin(deps: ClientDeps = {}, record: Rpc = messagesR
// Said once, at the top: the task is from an agent, not the person (a teammate's tmux paste read as the
// owner's). It reads the answer itself (`show`): an invitation to reply had the first eval's agent send its
// whole report back as a message as well, which would land in the middle of the starter's own turn. Nor is the
- // new harness told to message it: being started by it gives no way to, only a tab with Agent Messages on does
- // (owner, 2026-10-11: "Agent Messages off means off").
+ // new harness told to message it: being started by it gives no way to, only sharing a tab does (owner,
+ // 2026-10-11: "Agent Messages off means off").
const here = machineId === o.where.machineId
const header = caller.outside
? `[from ${caller.name} outside Harness · ${o.machine}, the agent that started you. It reads your answer itself.]\n\n`
diff --git a/cli/src/agentClient/ledger.ts b/cli/src/agentClient/ledger.ts
index 1685ff63a..0539eea82 100644
--- a/cli/src/agentClient/ledger.ts
+++ b/cli/src/agentClient/ledger.ts
@@ -4,8 +4,7 @@
* pane. A harness with no line was started by the person.
*
* Read by `harness ps` (who started each), and by `new` and `close` (limits, depth, and which harnesses an agent
- * may close). It never lets two harnesses message each other: only a tab with Agent Messages on does (owner,
- * 2026-10-11). It is a collaboration scope, not a sandbox: any process of this user can write the file.
+ * may close). It never lets two harnesses message each other: only sharing a tab does (owner, 2026-10-11). It is a collaboration scope, not a sandbox: any process of this user can write the file.
*
* A harness asked for and not started yet (its engine still installing) has a line of its own, `Pending`, with the
* machine's creation id: it starts by itself later, after `harness new` has answered, and is then recorded as started
diff --git a/cli/src/agentClient/mcp.spec.ts b/cli/src/agentClient/mcp.spec.ts
index ed42c1c94..0f6161b0c 100644
--- a/cli/src/agentClient/mcp.spec.ts
+++ b/cli/src/agentClient/mcp.spec.ts
@@ -32,10 +32,11 @@ describe('harness mcp', () => {
expect(outside.every((t) => t.argv === undefined)).toBe(true)
expect((await names(true)).map((t) => t.name)).toContain('harness_send')
expect(await answer(call('harness_send', { to: 'x', text: 'y' }), deps())).toMatchObject({ error: { code: -32602 } })
- // It reaches teammates in a tab with Agent Messages on, and nothing else: not a harness the agent started
- // (owner, 2026-10-11: Agent Messages off means off).
+ // It reaches teammates in the agent's tab while Agent Messages are on (Settings ▸ Agents, owner 2026-10-12), and
+ // nothing else: not a harness the agent started (owner, 2026-10-11: Agent Messages off means off).
const send = (await names(true)).find((t) => t.name === 'harness_send') as unknown as { description: string }
- expect(send.description).toMatch(/teammate.*Agent Messages on.*Refused anywhere else, even to a harness you started/)
+ expect(send.description).toMatch(/teammate: a harness in the same tab as you, while Agent Messages are on \(Settings ▸ Agents, on by default\)\. Refused anywhere else, even to a harness you started/)
+ expect(INSTRUCTIONS).toContain('A follow-up goes by harness_send only to a teammate in your tab, while Agent Messages are on')
expect(INSTRUCTIONS).toContain('starting a harness does not let you message it')
expect(INSTRUCTIONS).not.toContain('Send follow-ups for the same work to the harness you started')
// When to start one at all, and to close it, as every harness is told as it starts (lib/agentAttribution.ts).
diff --git a/cli/src/agentClient/mcp.ts b/cli/src/agentClient/mcp.ts
index 4a8f2fd67..a1ee836c8 100644
--- a/cli/src/agentClient/mcp.ts
+++ b/cli/src/agentClient/mcp.ts
@@ -25,7 +25,7 @@ export const INSTRUCTIONS = `Harness runs coding agents (Claude Code, Codex) in
Every harness spends the person's tokens. Start one (harness_start) only for work that can run in parallel with yours, needs another model's view (a review, a second opinion from Codex), takes long, or belongs in its own folder. Do quick work yourself. For scratch or new work give it a project name (project), not a folder of your own: Claude Code and Codex ask the person to trust a folder Harness did not make.
-List first (harness_list). Put everything in the task: starting a harness does not let you message it. A follow-up goes by harness_send only to a teammate in a tab where the person turned Agent Messages on; otherwise start a new harness with the fuller task. Never give work to, or close, a harness you did not start: those are the person's.
+List first (harness_list). Put everything in the task: starting a harness does not let you message it. A follow-up goes by harness_send only to a teammate in your tab, while Agent Messages are on; otherwise start a new harness with the fuller task. Never give work to, or close, a harness you did not start: those are the person's.
Name every harness. Then wait for it (harness_wait), read its answer (harness_read), and close it once you have its answer (harness_close). At most 4 of yours at once, and a harness another agent started may not start harnesses itself. Never ask a harness to publish, deploy, delete or push.`
@@ -107,7 +107,7 @@ export const TOOLS: Tool[] = [
},
{
name: 'harness_send',
- description: 'Send a message to a teammate: a harness in the same tab as you, where the person turned Agent Messages on (the tab\'s chat icon). Refused anywhere else, even to a harness you started.',
+ description: 'Send a message to a teammate: a harness in the same tab as you, while Agent Messages are on (Settings ▸ Agents, on by default). Refused anywhere else, even to a harness you started.',
inputSchema: schema({ to: { type: 'string', description: 'The teammate\'s name.' }, text: { type: 'string' } }, ['to', 'text']),
// A message adds to a teammate's inbox in this tab and nothing more; as harness_start, said so Codex does not ask.
annotations: { destructiveHint: false, openWorldHint: false },
diff --git a/cli/src/agentClient/settings.spec.ts b/cli/src/agentClient/settings.spec.ts
index 3a06bead4..6563cf57c 100644
--- a/cli/src/agentClient/settings.spec.ts
+++ b/cli/src/agentClient/settings.spec.ts
@@ -17,6 +17,7 @@ describe('harness settings', () => {
expect(out.pop()).toBe([
'agents-start-agents on agents may start, wait for and close harnesses of their own',
'pull-request-line on a harness another agent starts says so in the pull requests it opens',
+ 'agent-messages on agents in the same tab may message each other',
].join('\n'))
expect(run('agents-start-agents', 'off')).toBe(0)
expect(out.pop()).toBe('agents-start-agents is off.')
@@ -27,7 +28,14 @@ describe('harness settings', () => {
expect(readAgentSettings(dir).agentsStartAgents).toBe(true)
expect(run('pull-request-line', 'off')).toBe(0)
expect(out.pop()).toBe('pull-request-line is off.')
- expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: false })
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: false, agentMessages: true })
+ // Agent Messages, where `harness send` tells the person to turn them on again.
+ expect(run('agent-messages', 'off')).toBe(0)
+ expect(out.pop()).toBe('agent-messages is off.')
+ expect(readAgentSettings(dir).agentMessages).toBe(false)
+ expect(run('agent-messages', 'on')).toBe(0)
+ expect(out.pop()).toBe('agent-messages is on.')
+ expect(readAgentSettings(dir).agentMessages).toBe(true)
})
it('refuses what it does not know with the usage, and prints it for --help', () => {
diff --git a/cli/src/agentClient/settings.ts b/cli/src/agentClient/settings.ts
index 6b4f09507..36ba538d1 100644
--- a/cli/src/agentClient/settings.ts
+++ b/cli/src/agentClient/settings.ts
@@ -12,11 +12,13 @@ export const SETTINGS_USAGE = `Usage: harness settings [<name> on|off]
What agents may do on this computer, as Settings ▸ Agents shows it:
agents-start-agents agents may start, wait for and close harnesses of their own, and are told how (on by default)
pull-request-line a harness another agent starts says so in the pull requests it opens: one line beside the
- engine's own (on by default)`
+ engine's own (on by default)
+ agent-messages agents in the same tab may message each other with harness send (on by default)`
const ABOUT: Record<keyof AgentSettings, string> = {
agentsStartAgents: 'agents may start, wait for and close harnesses of their own',
pullRequestLine: 'a harness another agent starts says so in the pull requests it opens',
+ agentMessages: 'agents in the same tab may message each other',
}
export function settingsCommand(argv: readonly string[], dataDir: string, out: (line: string) => void = console.log, err: (line: string) => void = console.error): number {
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index 976df95c5..0364e4672 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -139,14 +139,14 @@ Machine:
harness machines list the machines on this account (this computer's is marked)
harness search <words> find the conversation on this computer that said them: every turn of
every harness, live or stopped (--limit=N, --json)
- harness send <name> "text" from an agent's pane: message a teammate in this tab, when Agent Messages
- are on there (the tab's chat icon); \`harness send\` alone lists who is here
+ harness send <name> "text" from an agent's pane: message a teammate in this tab (Agent Messages,
+ Settings ▸ Agents); \`harness send\` alone lists who is here
harness ps [--all] the harnesses here: state, who started each, what each is about
harness show <name> a harness's state and last turn: what it was asked and what it answered
harness wait <name>[,<name>] wait until they stop working (--any, --timeout 30m); exit 3 = needs the person
harness close <name> [--now] save a harness's screen and stop it; an agent closes only what it started
harness mcp the agent verbs as an MCP server on stdin/stdout, for agents that use MCP
- harness settings [<name> on|off] what agents may do here (agents-start-agents, pull-request-line), as Settings ▸ Agents
+ harness settings [<name> on|off] what agents may do here (agents-start-agents, pull-request-line, agent-messages), as Settings ▸ Agents
harness machines delete <id> remove ANOTHER machine (refuses this one; use \`harness logout\`)
harness remote from a Harness terminal tile: open a terminal on another of your machines and move this tile to it
harness version print the installed version (v${VERSION})
diff --git a/cli/src/core/api.ts b/cli/src/core/api.ts
index e90d48764..e6e43ff19 100644
--- a/cli/src/core/api.ts
+++ b/cli/src/core/api.ts
@@ -17,6 +17,7 @@ import type { RecentTurn } from '../cable/cableHost.js'
import type { ReviewedAnswer } from '../cable/questionInbox.js'
import type { AgentEngine } from '../engines/types.js'
import type { AppSwarms } from '../cable/cableSession.js'
+import type { AgentSettings } from '../lib/agentSettings.js'
import type { UnreadNotification } from '../lib/notificationRead.js'
import type { AutonomousDeviceAgent, AutonomousDeviceDelivery, AutonomousDeviceReceipt } from '../lib/autonomous-device/service.js'
import type { StoreAgent } from '../lib/autonomous-device/store.js'
@@ -574,7 +575,8 @@ export const MESSAGES_REQUESTS = ['agent_messages'] as const
* The experiments: services that cost nothing until they are on (docs/design/2026-10-06-core-boundary-next.md,
* "Experimental features: move only"). Each runs in a process of its own that the master starts only once the
* core asks for it (harnessd/services.ts `onDemand`): when one of its `requests` arrives, or at start when its
- * saved `state` is in the data folder (paths under it; `dir/*.ext` for a file of that kind in that folder).
+ * saved `state` is in the data folder (paths under it; `dir/*.ext` for a file of that kind in that folder), or
+ * while its Settings ▸ Agents `setting` is on (lib/agentSettings.ts).
* Off, it has no process and none of its code is loaded anywhere. Each may act on the core through the hooks
* an experiment has (core/experimentQueries.ts, core/deliveries.ts), and no other process may.
*
@@ -583,10 +585,11 @@ export const MESSAGES_REQUESTS = ['agent_messages'] as const
* entry here; and its start for the core's own process (services/inline.ts `EXPERIMENT_STARTS`). Removing
* one is deleting those.
*/
-export const EXPERIMENTS: Readonly<Record<string, { requests: readonly string[]; state: readonly string[] }>> = {
+export const EXPERIMENTS: Readonly<Record<string, { requests: readonly string[]; state: readonly string[]; setting?: keyof AgentSettings }>> = {
orchestrator: { requests: ORCHESTRATOR_REQUESTS, state: ['orchestrator/*.json'] },
// Agent Messages. Its history and waiting deliveries: a message was sent from here or delivered to an agent here.
- messages: { requests: MESSAGES_REQUESTS, state: ['agent-messages'] },
+ // On by default (Settings ▸ Agents), so it starts with the core: its agents hear of `harness send` from it.
+ messages: { requests: MESSAGES_REQUESTS, state: ['agent-messages'], setting: 'agentMessages' },
// Its invitations and links: a harness was shared from here.
sharing: { requests: SHARE_REQUESTS, state: ['harness-shares.json', 'harness-collaboration.json'] },
// Request-only, on from its first request until the daemon stops: another machine's Memories pane asks, and
diff --git a/cli/src/core/experiments.spec.ts b/cli/src/core/experiments.spec.ts
index 858248186..af8ef57bc 100644
--- a/cli/src/core/experiments.spec.ts
+++ b/cli/src/core/experiments.spec.ts
@@ -2,12 +2,16 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { createAccountNotices, createExperimentHooks, stateIsThere, wakeExperiments, writeAgentMessagesTab } from './experiments.js'
+import { writeAgentSettings } from '../lib/agentSettings.js'
+import { EXPERIMENTS } from './api.js'
+import { createAccountNotices, createExperimentHooks, stateIsThere, wakeExperiments, writeAgentSettingsAndWake } from './experiments.js'
describe('the experiments on as the core starts', () => {
let dataDir: string
beforeEach(() => { dataDir = mkdtempSync(join(tmpdir(), 'experiments-')) })
afterEach(() => rmSync(dataDir, { recursive: true, force: true }))
+ /** Agent Messages as core/api.ts declares it: on by its Settings ▸ Agents switch, or by its saved state. */
+ const experiments = { messages: { state: ['agent-messages'], setting: 'agentMessages' as const }, orchestrator: { state: ['orchestrator/*.json'] } }
it('finds saved state by path, or by a file of its kind in its folder', () => {
expect(stateIsThere(dataDir, ['agent-messages'])).toBe(false)
@@ -39,6 +43,30 @@ describe('the experiments on as the core starts', () => {
expect(want.mock.calls).toEqual([['orchestrator']])
})
+ it('asks for an experiment whose Settings ▸ Agents switch is on, with no saved state, and not once it is off', () => {
+ // Agent Messages is on by default: its agents hear of `harness send` only from its process, which nothing else
+ // starts on a machine where no one has sent yet (owner, 2026-10-12).
+ const wake = (outOfProcess = new Set(['messages', 'orchestrator'])) => {
+ const want = vi.fn()
+ return { woken: wakeExperiments({ dataDir, experiments, outOfProcess, want }), want }
+ }
+ const first = wake()
+ expect(first.woken).toEqual(['messages'])
+ expect(first.want.mock.calls).toEqual([['messages']])
+ // As core/api.ts declares the experiments: on a fresh data folder, Agent Messages alone.
+ const outOfProcess = new Set(Object.keys(EXPERIMENTS))
+ expect(wakeExperiments({ dataDir, experiments: EXPERIMENTS, outOfProcess, want: vi.fn() })).toEqual(['messages'])
+ // In the core's process it is started there, not asked for.
+ expect(wake(new Set()).woken).toEqual([])
+ writeAgentSettings(dataDir, { agentMessages: false })
+ const off = wake()
+ expect(off.woken).toEqual([])
+ expect(off.want).not.toHaveBeenCalled()
+ // Off, its saved state still wakes it: what waits there is held, then failed, rather than left behind.
+ mkdirSync(join(dataDir, 'agent-messages'))
+ expect(wake().woken).toEqual(['messages'])
+ })
+
it('hands the account\'s notices to each listener here, guarded, and to the experiments\' processes', () => {
const tell = vi.fn()
const log = vi.fn()
@@ -85,16 +113,20 @@ describe('the experiments on as the core starts', () => {
createExperimentHooks({ want: vi.fn(), notify, outOfProcess: new Set(), experiments: [] }).want('x')
})
- it('asks for Agent Messages once a tab is turned on, and not when one is turned off or the backend refuses', async () => {
+ it('asks for an experiment once a Settings ▸ Agents write leaves its switch on, and not when off or refused', async () => {
// On one machine nothing else starts it: no agent heard of `harness send` (a fresh Mac, 2026-10-12).
const want = vi.fn()
- const ok = { status: 200, body: { success: true } }
- expect(await writeAgentMessagesTab(async () => ok, { enabled: true }, want)).toBe(ok)
- expect(want).toHaveBeenCalledTimes(1)
- await writeAgentMessagesTab(async () => ok, { enabled: false }, want)
- await writeAgentMessagesTab(async () => ok, null, want)
- await writeAgentMessagesTab(async () => ({ status: 404, body: {} }), { enabled: true }, want)
- await writeAgentMessagesTab(async () => ({ status: 199, body: {} }), { enabled: true }, want)
- expect(want).toHaveBeenCalledTimes(1)
+ const settings = (body: Record<string, unknown>, status = 200) => async () => ({ status, body })
+ const on = { agentsStartAgents: true, pullRequestLine: true, agentMessages: true }
+ const answer = await writeAgentSettingsAndWake(settings(on), experiments, want)
+ expect(answer).toEqual({ status: 200, body: on })
+ expect(want.mock.calls).toEqual([['messages']])
+ // Another switch written, this one left on: asked for again, which changes nothing for one already running.
+ await writeAgentSettingsAndWake(settings({ ...on, pullRequestLine: false }), experiments, want)
+ expect(want).toHaveBeenCalledTimes(2)
+ await writeAgentSettingsAndWake(settings({ ...on, agentMessages: false }), experiments, want)
+ await writeAgentSettingsAndWake(settings({ error: { code: 'BAD_REQUEST' } }, 400), experiments, want)
+ await writeAgentSettingsAndWake(settings(on, 199), experiments, want)
+ expect(want).toHaveBeenCalledTimes(2)
})
})
diff --git a/cli/src/core/experiments.ts b/cli/src/core/experiments.ts
index 26dc283c9..9091069ce 100644
--- a/cli/src/core/experiments.ts
+++ b/cli/src/core/experiments.ts
@@ -1,14 +1,17 @@
/**
* Which experiments are on as the core starts (core/api.ts `EXPERIMENTS`): one whose saved state is in the
* data folder is asked for at once, so that what it does on its own (a saved project's queued work) goes on
- * after a restart, as it did when it ran in the core's process. One with none waits for its first request:
- * off, it has no process. Read once, at start, and bounded: a name or a folder listing, never a file's
- * contents.
+ * after a restart, as it did when it ran in the core's process; so is one whose Settings ▸ Agents switch is on
+ * (Agent Messages, on by default). One with neither waits for its first request: off, it has no process. Read
+ * once, at start, and bounded: a name or a folder listing, and the one small settings file.
*/
import { readdirSync, existsSync } from 'node:fs'
import { join } from 'node:path'
+import { readAgentSettings, type AgentSettings } from '../lib/agentSettings.js'
import type { BackendNotice } from './api.js'
+type Experiments = Readonly<Record<string, { state: readonly string[]; setting?: keyof AgentSettings }>>
+
/** Whether any of `state` is in `dataDir`: a path under it, or `dir/*.ext` for a file of that kind in that folder. */
export function stateIsThere(dataDir: string, state: readonly string[]): boolean {
return state.some((entry) => {
@@ -23,28 +26,36 @@ export function stateIsThere(dataDir: string, state: readonly string[]): boolean
})
}
-/** Ask for each experiment that runs in its own process and has saved state here. */
+/** Ask for each experiment that runs in its own process and has saved state here, or whose Settings ▸ Agents switch
+ * is on (Agent Messages, on by default: its agents hear of `harness send` only from its process). */
export function wakeExperiments(options: {
dataDir: string
- experiments: Readonly<Record<string, { state: readonly string[] }>>
+ experiments: Experiments
outOfProcess: ReadonlySet<string>
want: (service: string) => void
}): string[] {
+ const settings = readAgentSettings(options.dataDir)
const woken = Object.entries(options.experiments)
- .filter(([name, experiment]) => options.outOfProcess.has(name) && stateIsThere(options.dataDir, experiment.state))
+ .filter(([name, experiment]) => options.outOfProcess.has(name)
+ && (stateIsThere(options.dataDir, experiment.state) || (experiment.setting !== undefined && settings[experiment.setting])))
.map(([name]) => name)
for (const name of woken) options.want(name)
return woken
}
/**
- * A tab's Agent Messages switch, written through the backend. Turned on, the experiment is asked for at once, so the
- * tab's agents get its note now: otherwise only its first request or its saved state starts it, and on one machine
- * neither comes, so no agent heard of `harness send` (a fresh Mac, 2026-10-12).
+ * A Settings ▸ Agents change, written by the core. An experiment whose switch it leaves on is asked for at once, so it
+ * acts now (Agent Messages' agents get its note) rather than at its first request or the next start: on one machine
+ * neither came, and no agent heard of `harness send` (a fresh Mac, 2026-10-12). Asking again for one already running
+ * changes nothing. A tab's own switch, which older windows still write, decides nothing and wakes nothing.
*/
-export async function writeAgentMessagesTab<T extends { status: number }>(write: () => Promise<T>, body: unknown, want: () => void): Promise<T> {
+export async function writeAgentSettingsAndWake<T extends { status: number; body: Record<string, unknown> }>(
+ write: () => Promise<T>, experiments: Experiments, want: (service: string) => void,
+): Promise<T> {
const result = await write()
- if (result.status >= 200 && result.status < 300 && (body as { enabled?: unknown } | null)?.enabled === true) want()
+ if (result.status >= 200 && result.status < 300) {
+ for (const [name, experiment] of Object.entries(experiments)) if (experiment.setting && result.body[experiment.setting] === true) want(name)
+ }
return result
}
diff --git a/cli/src/core/main.ts b/cli/src/core/main.ts
index 111412b80..2f4280136 100644
--- a/cli/src/core/main.ts
+++ b/cli/src/core/main.ts
@@ -179,7 +179,7 @@ import { answerAgentQuery } from './agentQueries.js'
import { createDeliveries } from './deliveries.js'
import { createTerminalWatch } from './terminalWatch.js'
import { createSharingLink } from './sharingLink.js'
-import { createExperimentHooks, wakeExperiments, writeAgentMessagesTab } from './experiments.js'
+import { createExperimentHooks, wakeExperiments, writeAgentSettingsAndWake } from './experiments.js'
import { answerExperimentQuery, createForExperiment } from './experimentQueries.js'
import { answerConnectorsQuery } from './connectorsQueries.js'
import { createOrchestratorLink } from './orchestratorLink.js'
@@ -1822,14 +1822,14 @@ async function runForeground(session: AuthSession | null): Promise<void> {
// route and hears about everyone else's edits as `desk_changed` (backendSocket.ts).
onDeskRead: () => proxyBackend('GET', '/api/desk'),
onDeskOps: (body) => proxyBackend('POST', '/api/desk/ops', body),
- // Which tabs have Agent Messages on, for the window's tabs (backend routes/agentMessages.ts).
+ // The account's tabs for Agent Messages (backend routes/agentMessages.ts). A tab's flag is an older window's only:
+ // Settings ▸ Agents decides, so its switch is passed on and wakes nothing.
onAgentMessagesRead: () => proxyBackend('GET', '/api/agent-messages'),
- onAgentMessagesWrite: (tabId, body) => writeAgentMessagesTab(() => proxyBackend('PATCH', `/api/agent-messages/tabs/${tabId}`, body), body,
- () => experimentHooks.want('messages')),
+ onAgentMessagesWrite: (tabId, body) => proxyBackend('PATCH', `/api/agent-messages/tabs/${tabId}`, body),
onExperimentalRead: () => proxyBackend('GET', '/api/experimental-settings'),
onExperimentalWrite: (body) => proxyBackend('PATCH', '/api/experimental-settings', body),
onAgentSettingsRead: agentSettings.read,
- onAgentSettingsWrite: agentSettings.write,
+ onAgentSettingsWrite: (body) => writeAgentSettingsAndWake(() => agentSettings.write(body), EXPERIMENTS, (service) => experimentHooks.want(service)),
onStore: (method, path, body) => proxyBackend(method, path, body),
}, { socketPath: localSocketPath(env.ADAPTER_DATA_DIR, env.PORT), allowPortFallback: true })
try { saveDaemonPort(env.ADAPTER_DATA_DIR, env.PORT, hookPort) } catch (error) {
@@ -1848,8 +1848,9 @@ async function runForeground(session: AuthSession | null): Promise<void> {
if (coreLink.supervised) {
coreLink.bound(hookPort)
coreLink.startHeartbeat()
- // The experiments with saved state are on: their processes are asked for now, the master heeding a
- // bound core alone (core/experiments.ts). The others wait for their first request.
+ // The experiments with saved state, or with their Settings ▸ Agents switch on, are on: their processes are
+ // asked for now, the master heeding a bound core alone (core/experiments.ts). The others wait for their first
+ // request.
wakeExperiments({ dataDir: env.ADAPTER_DATA_DIR, experiments: EXPERIMENTS, outOfProcess, want: (service) => experimentHooks.want(service) })
devicesWake.start(outOfProcess)
wakeModels({ outOfProcess, dataDir: env.ADAPTER_DATA_DIR, runtimeDir: env.ADAPTER_RUNTIME_DIR, want: (service) => coreLink.want(service) })
diff --git a/cli/src/harnessd/services.ts b/cli/src/harnessd/services.ts
index 365e19021..c6757da41 100644
--- a/cli/src/harnessd/services.ts
+++ b/cli/src/harnessd/services.ts
@@ -394,8 +394,9 @@ export const SERVICE_HOSTS: Readonly<Record<string, ServiceHostSpec>> = {
// The router (services/routerProcess.ts), an experiment: started at its first request. A few decisions in
// flight, each one bounded Jev answer.
router: { services: ['router'], heapLimitMiB: 128, rssLimitMiB: 384, onDemand: true },
- // Agent Messages (services/messagesProcess.ts), an experiment: its mailbox, history and the account's tabs
- // with Agent Messages on. Started only once it is on (core/api.ts `EXPERIMENTS`).
+ // Agent Messages (services/messagesProcess.ts), an experiment: its mailbox, history and the account's tabs.
+ // Started with the core while Settings ▸ Agents has it on, the default; else at its first request or for its
+ // saved state (core/api.ts `EXPERIMENTS`).
messages: { services: ['messages'], heapLimitMiB: 256, rssLimitMiB: 512, onDemand: true },
// Share, an experiment (services/sharingProcess.ts): its invitations, its observers' sessions and their
// ciphers; the headless Chrome it captures a shared viewer in is a process of its own, outside this budget.
diff --git a/cli/src/hookServer.spec.ts b/cli/src/hookServer.spec.ts
index 04a6acd84..5341436af 100644
--- a/cli/src/hookServer.spec.ts
+++ b/cli/src/hookServer.spec.ts
@@ -365,11 +365,12 @@ describe('what the person lets agents do', () => {
const routes = agentSettingsRoutes(dataDir)
const { base } = await start({ onAgentSettingsRead: routes.read, onAgentSettingsWrite: routes.write })
const patch = (body: string, local = true) => fetch(`${base}/api/agent-settings`, { method: 'PATCH', headers: { 'content-type': 'application/json', ...(local ? { 'x-adapter-local': '1' } : {}) }, body })
- expect(await (await fetch(`${base}/api/agent-settings`)).json()).toEqual({ agentsStartAgents: true, pullRequestLine: true })
+ expect(await (await fetch(`${base}/api/agent-settings`)).json()).toEqual({ agentsStartAgents: true, pullRequestLine: true, agentMessages: true })
expect((await patch('{"agentsStartAgents":false}', false)).status).toBe(403)
- expect(await (await patch('{"agentsStartAgents":false}')).json()).toEqual({ agentsStartAgents: false, pullRequestLine: true })
- expect(await (await patch('{"pullRequestLine":false}')).json()).toEqual({ agentsStartAgents: false, pullRequestLine: false })
- expect(await (await fetch(`${base}/api/agent-settings`)).json()).toEqual({ agentsStartAgents: false, pullRequestLine: false })
+ expect(await (await patch('{"agentsStartAgents":false}')).json()).toEqual({ agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
+ expect(await (await patch('{"pullRequestLine":false}')).json()).toEqual({ agentsStartAgents: false, pullRequestLine: false, agentMessages: true })
+ expect(await (await patch('{"agentMessages":false}')).json()).toEqual({ agentsStartAgents: false, pullRequestLine: false, agentMessages: false })
+ expect(await (await fetch(`${base}/api/agent-settings`)).json()).toEqual({ agentsStartAgents: false, pullRequestLine: false, agentMessages: false })
expect((await patch('{"other":1}')).status).toBe(400)
expect((await patch('{bad')).status).toBe(400)
} finally { rmSync(dataDir, { recursive: true, force: true }) }
diff --git a/cli/src/hookServer.ts b/cli/src/hookServer.ts
index 5402e048e..814960a9f 100644
--- a/cli/src/hookServer.ts
+++ b/cli/src/hookServer.ts
@@ -165,11 +165,12 @@ export interface HookServerHandlers {
/** POST /api/desk/ops — the window's tab edits, applied on the backend (its routes/desk.ts); a
* local write, so CSRF-guarded like a rename. */
onDeskOps?: (body: unknown) => Promise<PairOutcome>
- /** GET /api/agent-messages — which tabs have Agent Messages on (docs/design/2026-10-10-agent-messages.md),
- * proxied like the desk: the window draws each tab's chat icon from it without starting the experiment's process. */
+ /** GET /api/agent-messages — the account's tabs and who is in each (docs/design/2026-10-10-agent-messages.md),
+ * proxied like the desk without starting the experiment's process. An older window draws each tab's chat icon
+ * from its flag, which no daemon reads now: Settings ▸ Agents decides (lib/agentSettings.ts). */
onAgentMessagesRead?: () => Promise<PairOutcome>
- /** PATCH /api/agent-messages/tabs/:tabId — turn Agent Messages on or off for one tab; a local write, so
- * CSRF-guarded like the desk's ops. */
+ /** PATCH /api/agent-messages/tabs/:tabId — an older window's tab switch, passed to the backend so it gets the
+ * answer it expects, and deciding nothing; a local write, so CSRF-guarded like the desk's ops. */
onAgentMessagesWrite?: (tabId: string, body: unknown) => Promise<PairOutcome>
/** GET/PATCH /api/agent-settings — what the person lets agents do on this computer (lib/agentSettings.ts), kept by
* this daemon rather than the account: Settings ▸ Agents. The write is CSRF-guarded like the others. */
diff --git a/cli/src/lib/agentSettings.spec.ts b/cli/src/lib/agentSettings.spec.ts
index 42ae5f86b..e882f73b4 100644
--- a/cli/src/lib/agentSettings.spec.ts
+++ b/cli/src/lib/agentSettings.spec.ts
@@ -10,31 +10,41 @@ afterEach(() => rmSync(dir, { recursive: true, force: true }))
describe('what the person lets agents do', () => {
it('lets agents start agents until the person turns it off', () => {
- expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: true })
- expect(writeAgentSettings(dir, { agentsStartAgents: false })).toEqual({ agentsStartAgents: false, pullRequestLine: true })
- expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: false, pullRequestLine: true })
- expect(JSON.parse(readFileSync(agentSettingsPath(dir), 'utf8'))).toEqual({ version: 1, agentsStartAgents: false, pullRequestLine: true })
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: true, agentMessages: true })
+ expect(writeAgentSettings(dir, { agentsStartAgents: false })).toEqual({ agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
+ expect(JSON.parse(readFileSync(agentSettingsPath(dir), 'utf8'))).toEqual({ version: 1, agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
expect(statSync(agentSettingsPath(dir)).mode & 0o777).toBe(0o600)
expect(AGENT_SETTING_NAMES['agents-start-agents']).toBe('agentsStartAgents')
})
it('adds a line to the pull requests of a harness another agent started until the person turns it off', () => {
- expect(writeAgentSettings(dir, { pullRequestLine: false })).toEqual({ agentsStartAgents: true, pullRequestLine: false })
+ expect(writeAgentSettings(dir, { pullRequestLine: false })).toEqual({ agentsStartAgents: true, pullRequestLine: false, agentMessages: true })
expect(readAgentSettings(dir).pullRequestLine).toBe(false)
// A file written before the setting existed: the default for it, and the other kept.
writeFileSync(agentSettingsPath(dir), '{"version":1,"agentsStartAgents":false}')
- expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: false, pullRequestLine: true })
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
expect(AGENT_SETTING_NAMES['pull-request-line']).toBe('pullRequestLine')
})
+ it('lets agents in one tab message each other until the person turns it off, on a computer that never said', () => {
+ // It replaced each tab's chat icon, off by default, which the owner hit by mistake (2026-10-12): on by default, so a
+ // file written before it existed, which says nothing of it, has it on.
+ writeFileSync(agentSettingsPath(dir), '{"version":1,"agentsStartAgents":true,"pullRequestLine":false}')
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: false, agentMessages: true })
+ expect(writeAgentSettings(dir, { agentMessages: false })).toEqual({ agentsStartAgents: true, pullRequestLine: false, agentMessages: false })
+ expect(readAgentSettings(dir).agentMessages).toBe(false)
+ expect(AGENT_SETTING_NAMES['agent-messages']).toBe('agentMessages')
+ })
+
it('applies only booleans it knows, and reads a broken file as the defaults', () => {
expect(writeAgentSettings(dir, null)).toBeNull()
expect(writeAgentSettings(dir, 'off')).toBeNull()
expect(writeAgentSettings(dir, { agentsStartAgents: 'no', other: true })).toBeNull()
- expect(writeAgentSettings(dir, { agentsStartAgents: false, other: true })).toEqual({ agentsStartAgents: false, pullRequestLine: true })
- writeFileSync(agentSettingsPath(dir), '{"agentsStartAgents": "nope", "pullRequestLine": 0}')
- expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: true })
+ expect(writeAgentSettings(dir, { agentsStartAgents: false, other: true })).toEqual({ agentsStartAgents: false, pullRequestLine: true, agentMessages: true })
+ writeFileSync(agentSettingsPath(dir), '{"agentsStartAgents": "nope", "pullRequestLine": 0, "agentMessages": "off"}')
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: true, agentMessages: true })
writeFileSync(agentSettingsPath(dir), 'not json')
- expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: true })
+ expect(readAgentSettings(dir)).toEqual({ agentsStartAgents: true, pullRequestLine: true, agentMessages: true })
})
})
diff --git a/cli/src/lib/agentSettings.ts b/cli/src/lib/agentSettings.ts
index ad8b69858..54e06d55e 100644
--- a/cli/src/lib/agentSettings.ts
+++ b/cli/src/lib/agentSettings.ts
@@ -17,12 +17,15 @@ export interface AgentSettings {
/** A harness another agent started adds a line to the pull requests it opens (lib/agentAttribution.ts). Read at
* each launch of one, so a harness running when it is turned off keeps its line until it restarts. */
pullRequestLine: boolean
+ /** Agents in the same tab may message each other (`harness send`, messages/service.ts). It replaced each tab's own
+ * switch, a chat icon beside its × that was easy to hit by mistake (owner, 2026-10-12). */
+ agentMessages: boolean
}
-export const AGENT_SETTINGS_DEFAULTS: AgentSettings = { agentsStartAgents: true, pullRequestLine: true }
+export const AGENT_SETTINGS_DEFAULTS: AgentSettings = { agentsStartAgents: true, pullRequestLine: true, agentMessages: true }
/** Each setting's name in `harness settings`, and its key. */
-export const AGENT_SETTING_NAMES: Record<string, keyof AgentSettings> = { 'agents-start-agents': 'agentsStartAgents', 'pull-request-line': 'pullRequestLine' }
+export const AGENT_SETTING_NAMES: Record<string, keyof AgentSettings> = { 'agents-start-agents': 'agentsStartAgents', 'pull-request-line': 'pullRequestLine', 'agent-messages': 'agentMessages' }
export const agentSettingsPath = (dataDir: string): string => join(dataDir, 'agent-settings.json')
@@ -59,7 +62,7 @@ export function agentSettingsRoutes(dataDir: string): { read: () => Promise<{ st
read: async () => ({ status: 200, body: { ...readAgentSettings(dataDir) } }),
write: async (body) => {
const next = writeAgentSettings(dataDir, body)
- return next ? { status: 200, body: { ...next } } : { status: 400, body: { error: { code: 'BAD_REQUEST', message: 'Nothing to change: send {"agentsStartAgents": true|false} or {"pullRequestLine": true|false}.' } } }
+ return next ? { status: 200, body: { ...next } } : { status: 400, body: { error: { code: 'BAD_REQUEST', message: 'Nothing to change: send {"agentsStartAgents": true|false}, {"pullRequestLine": true|false} or {"agentMessages": true|false}.' } } }
},
}
}
diff --git a/cli/src/messages/command.ts b/cli/src/messages/command.ts
index f48d12fe7..08f9f4961 100644
--- a/cli/src/messages/command.ts
+++ b/cli/src/messages/command.ts
@@ -1,6 +1,6 @@
/**
- * `harness send`: an agent messages its teammates in a tab with Agent Messages on
- * (docs/design/2026-10-10-agent-messages.md). Run in the agent's own pane: the pane says who is sending.
+ * `harness send`: an agent messages its teammates, the harnesses in its tab, while Agent Messages are on
+ * (Settings ▸ Agents, on by default; docs/design/2026-10-10-agent-messages.md). Run in the agent's own pane: the pane says who is sending.
*
* harness send who is in this tab, and the rules
* harness send <name>[,<name>] text message them (or --text-file PATH, in the temporary folder)
@@ -26,8 +26,8 @@ export const SEND_USAGE = `harness send — message your teammates in this tab
harness send <name> --fyi "text" news no one must act on now: it arrives at their next tool call
and never starts a turn of theirs
-Run it in your own harness pane. Agent Messages must be on in the tab (the chat icon on the tab), even
-to message a harness you started.
+Run it in your own harness pane. It reaches the harnesses in your tab while Agent Messages are on
+(Settings ▸ Agents, on by default); a harness you started only if it is in your tab.
Use --json for structured output.`
export interface SendArgs { names: string[]; text: string; json: boolean; fyi?: boolean }
diff --git a/cli/src/messages/directory.ts b/cli/src/messages/directory.ts
index b9822f8c5..3fc6199c2 100644
--- a/cli/src/messages/directory.ts
+++ b/cli/src/messages/directory.ts
@@ -1,16 +1,18 @@
/**
* Who may message whom (docs/design/2026-10-10-agent-messages.md, "Who may message whom"): the account's
- * desk tabs, each with its owned panes and whether Agent Messages is on in it, read from the backend
- * (`GET /api/agent-messages`). A message goes only between harnesses that share a tab whose flag is on.
+ * desk tabs, each with its owned panes, read from the backend (`GET /api/agent-messages`). A message goes only
+ * between harnesses that share a tab, while this computer has Agent Messages on (Settings ▸ Agents, on by default).
+ * Each tab's own flag, which the backend still answers for older windows, is not read: the tab's switch was a chat
+ * icon beside its × that was easy to hit by mistake, and the owner made it one setting, on by default (2026-10-12).
*
- * Read when the service starts, every 15 seconds while it runs, again on the account's `desk_changed` (which a
- * flag change publishes too), and fresh before a send. An unreadable directory never clears what was read: a
- * failed read keeps the last one, and before any read nothing may be sent.
+ * Read when the service starts, every 15 seconds while it runs, again on the account's `desk_changed`, and fresh
+ * before a send. An unreadable directory never clears what was read: a failed read keeps the last one, and before
+ * any read nothing may be sent.
*/
export interface Member { machineId: string; agentId: string }
/** `named`: the person named the tab; any other is labelled by the windows themselves (backend lib/agentMessages.ts). */
-export interface DirectoryTab { id: string; name: string; named: boolean; enabled: boolean; panes: Member[] }
+export interface DirectoryTab { id: string; name: string; named: boolean; panes: Member[] }
export interface Directory { revision: number; machines: ReadonlyMap<string, string | null>; tabs: DirectoryTab[] }
export const POLL_MS = 15_000
@@ -37,7 +39,7 @@ export function parseDirectory(value: unknown): Directory | null {
return machineId && agentId ? [{ machineId, agentId }] : []
})
// A backend from before `named` says nothing: then only the window's own default name is no name.
- tabs.push({ id, name, named: typeof t.named === 'boolean' ? t.named : name !== 'New Tab', enabled: t.enabled === true, panes })
+ tabs.push({ id, name, named: typeof t.named === 'boolean' ? t.named : name !== 'New Tab', panes })
}
return { revision: typeof v.revision === 'number' ? v.revision : 0, machines, tabs }
}
@@ -48,6 +50,8 @@ export interface DirectoryDeps {
read(): Promise<unknown>
/** The directory changed: deliveries and notes may need another look. */
changed?(): void
+ /** Whether this computer has Agent Messages on (Settings ▸ Agents); on when not said. */
+ on?(): boolean
now?(): number
}
@@ -56,21 +60,27 @@ export class MessageDirectory {
private readAt = -Infinity
private reading: Promise<Directory | null> | null = null
private timer: ReturnType<typeof setInterval> | null = null
+ private wasOn = true
constructor(private readonly deps: DirectoryDeps) {}
private now(): number { return this.deps.now?.() ?? Date.now() }
current(): Directory | null { return this.value }
+ /** Whether this computer has Agent Messages on: off, no tab carries a message. */
+ on(): boolean { return this.deps.on?.() ?? true }
+
/** The directory, read again unless the last read is fresh; a failed read keeps the last one. */
refresh(force = false): Promise<Directory | null> {
if (!force && this.value && this.now() - this.readAt < FRESH_MS) return Promise.resolve(this.value)
return this.reading ??= this.deps.read().then((raw) => {
const next = parseDirectory(raw)
if (next) {
- const before = JSON.stringify(this.value ? [this.value.revision, this.value.tabs] : null)
+ // The setting counts as part of what was read: turned on or off, deliveries and notes get another look.
+ const before = JSON.stringify(this.value ? [this.value.revision, this.value.tabs, this.wasOn] : null)
this.value = next
+ this.wasOn = this.on()
this.readAt = this.now()
- if (JSON.stringify([next.revision, next.tabs]) !== before) this.deps.changed?.()
+ if (JSON.stringify([next.revision, next.tabs, this.wasOn]) !== before) this.deps.changed?.()
}
return this.value
}, () => this.value).finally(() => { this.reading = null })
@@ -88,17 +98,18 @@ export class MessageDirectory {
this.timer = null
}
- /** The tabs with Agent Messages on that a harness is in. */
+ /** The tabs a harness is in, while Agent Messages are on; none while they are off. */
tabsOf(member: Member): DirectoryTab[] {
- return (this.value?.tabs ?? []).filter((tab) => tab.enabled && tab.panes.some((p) => same(p, member)))
+ if (!this.on()) return []
+ return (this.value?.tabs ?? []).filter((tab) => tab.panes.some((p) => same(p, member)))
}
- /** The first tab with Agent Messages on that two harnesses share, or null. */
+ /** The first tab two harnesses share while Agent Messages are on, or null. */
shared(a: Member, b: Member): DirectoryTab | null {
return this.tabsOf(a).find((tab) => tab.panes.some((p) => same(p, b))) ?? null
}
- /** Everyone a harness may message: the other members of its tabs with Agent Messages on, once each. */
+ /** Everyone a harness may message: the other members of its tabs, once each, while Agent Messages are on. */
peers(member: Member): Member[] {
const out: Member[] = []
for (const tab of this.tabsOf(member)) {
diff --git a/cli/src/messages/mailbox.spec.ts b/cli/src/messages/mailbox.spec.ts
index 6e48af151..a78561028 100644
--- a/cli/src/messages/mailbox.spec.ts
+++ b/cli/src/messages/mailbox.spec.ts
@@ -432,11 +432,11 @@ describe('Agent Messages\' mailbox', () => {
const statuses: DeliveryStatus[] = []
// The directory is not read yet (signed out, the backend down): nothing else is refused.
const restarted = new Mailbox({ store: new MessageStore(join(root, 'state')), inbox: t.inbox, agent: () => null, deliver: () => {}, refused: () => 'refused', ready: () => false,
- forbidden: (d) => (d.messageId === 'm0000006' ? 'it was sent outside any tab with Agent Messages on' : null), text: () => '', changed: (s) => { statuses.push(s) }, now: t.now })
+ forbidden: (d) => (d.messageId === 'm0000006' ? 'it was sent outside any tab' : null), text: () => '', changed: (s) => { statuses.push(s) }, now: t.now })
restarted.start()
restarted.stop()
const state = new MessageStore(join(root, 'state')).state.local
- expect(state.find((d) => d.key === never.key)).toMatchObject({ state: 'failed', reason: 'it was sent outside any tab with Agent Messages on' })
+ expect(state.find((d) => d.key === never.key)).toMatchObject({ state: 'failed', reason: 'it was sent outside any tab' })
expect(statuses).toEqual([expect.objectContaining({ messageId: 'm0000006', state: 'failed' })])
// Its attempt in flight did not go back to the hook; the other one's did.
expect(t.inbox.waiting('%3', never.key)).toBe(false)
diff --git a/cli/src/messages/service.spec.ts b/cli/src/messages/service.spec.ts
index 299b7f2a1..cc87fcd07 100644
--- a/cli/src/messages/service.spec.ts
+++ b/cli/src/messages/service.spec.ts
@@ -9,9 +9,10 @@ import { PaneInbox } from './inbox.js'
import { deliveryKey, FYI_REASON, PUMP_MS } from './mailbox.js'
import { header, LIMITS, LONG_TEXT, longAdvice, MessageError, parseMessage, type Message } from './model.js'
import type { Rpc } from './rpc.js'
-import { HELD_OFF_REASON, HELD_OUTSIDE_MS, REMOTE_STATUS_MS, startAgentMessages, SWEEP_AFTER_MS, TICK_MS } from './service.js'
+import { HELD_OFF_REASON, HELD_OUTSIDE_MS, MESSAGES_OFF_TEXT, REMOTE_STATUS_MS, SETTING_FRESH_MS, startAgentMessages, SWEEP_AFTER_MS, TICK_MS, WHO_MS } from './service.js'
import { MessageStore } from './store.js'
import { Ledger, ledgerPath } from '../agentClient/ledger.js'
+import { writeAgentSettings } from '../lib/agentSettings.js'
let root: string
beforeEach(() => { root = mkdtempSync(join(tmpdir(), 'agent-messages-')) })
@@ -23,7 +24,7 @@ const session = (agentId: string, pane: string, engine = 'claude', cwd = `/work/
({ agentId, sessionId: `s-${agentId}`, engine, cwd, tmuxPane: pane, active: true, title: agentId }) as unknown as RegisteredSession
interface Setup {
- tabs?: Array<{ id: string; name: string; enabled: boolean; panes: Array<{ machineId: string; agentId: string }> }>
+ tabs?: Array<{ id: string; name: string; panes: Array<{ machineId: string; agentId: string }> }>
agents?: RegisteredSession[]
rpc?: Rpc
backendStatus?: number
@@ -32,7 +33,7 @@ interface Setup {
function setup(over: Setup = {}) {
let clock = 1_000_000
const agents = over.agents ?? [session('lead', '%1', 'codex'), session('api', '%2'), session('web', '%3')]
- const tabs = over.tabs ?? [{ id: 'app', name: 'app', enabled: true, panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'api' }, { machineId: 'm2', agentId: 'phone' }] }]
+ const tabs = over.tabs ?? [{ id: 'app', name: 'app', panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'api' }, { machineId: 'm2', agentId: 'phone' }] }]
const directory = { revision: 4, machines: [{ machineId: 'm1', name: 'studio' }, { machineId: 'm2', name: 'laptop' }], tabs }
const delivered: Array<[string, string, string]> = []
const windows: Array<Record<string, unknown>> = []
@@ -71,6 +72,9 @@ function setup(over: Setup = {}) {
service, ask, delivered, windows, backend, rpcCalls, agents, tabs, directory, changed,
inbox: new PaneInbox(join(root, 'inbox-root')),
tick: (ms: number) => { clock += ms },
+ /** Settings ▸ Agents on this computer, as the person turns Agent Messages on or off: read at the service's next
+ * look, once what it read last is no longer fresh. */
+ setting: (on: boolean) => { writeAgentSettings(root, { agentMessages: on }); clock += SETTING_FRESH_MS },
deliveryEvent: (event: TurnDelivery) => { for (const l of deliveryListeners) l(event) },
notice: (notice: BackendNotice) => { for (const l of noticeListeners) l(notice) },
}
@@ -194,7 +198,7 @@ describe('harness send', () => {
it('tells two teammates with the same start apart only by more of the name', async () => {
const t = setup({
agents: [session('lead', '%1'), session('api-a', '%2'), session('api-b', '%3')],
- tabs: [{ id: 'app', name: 'app', enabled: true, panes: ['lead', 'api-a', 'api-b'].map((agentId) => ({ machineId: 'm1', agentId })) }],
+ tabs: [{ id: 'app', name: 'app', panes: ['lead', 'api-a', 'api-b'].map((agentId) => ({ machineId: 'm1', agentId })) }],
})
expect((await t.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).error).toBe('AMBIGUOUS_RECIPIENT')
expect((await t.ask({ action: 'send', pane: '%1', to: 'api-b', text: 'x' })).recipients).toEqual([{ name: 'api-b', state: 'queued' }])
@@ -206,7 +210,7 @@ describe('harness send', () => {
const titled = (agentId: string, pane: string) => ({ ...session(agentId, pane, 'codex'), title: 'Ask teammate to create notes' }) as unknown as RegisteredSession
const t = setup({
agents: [titled('efedc3c7-lead', '%1'), titled('07934321-one', '%2'), titled('11112222-two', '%3')],
- tabs: [{ id: 'app', name: 'app', enabled: true, panes: ['efedc3c7-lead', '07934321-one', '11112222-two'].map((agentId) => ({ machineId: 'm1', agentId })) }],
+ tabs: [{ id: 'app', name: 'app', panes: ['efedc3c7-lead', '07934321-one', '11112222-two'].map((agentId) => ({ machineId: 'm1', agentId })) }],
})
const roster = String((await t.ask({ action: 'send', pane: '%1' })).roster)
expect(roster).toContain('Ask teammate to create notes (07934321)')
@@ -230,7 +234,7 @@ describe('harness send', () => {
const t = setup({
agents: [session('lead', '%1'), { ...session('cx', '%2', 'codex'), title: 'claude-code-2026-10-1...' } as unknown as RegisteredSession,
{ ...session('dots', '%3', 'codex'), title: '...' } as unknown as RegisteredSession],
- tabs: [{ id: 'app', name: 'app', enabled: true, panes: ['lead', 'cx', 'dots'].map((agentId) => ({ machineId: 'm1', agentId })) }],
+ tabs: [{ id: 'app', name: 'app', panes: ['lead', 'cx', 'dots'].map((agentId) => ({ machineId: 'm1', agentId })) }],
})
expect((await t.ask({ action: 'send', pane: '%1', to: 'claude-code-2026-10-12-02-15', text: 'x' })).recipients)
.toEqual([{ name: 'claude-code-2026-10-1...', state: 'queued' }])
@@ -245,37 +249,82 @@ describe('harness send', () => {
const pair = [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'api' }]
const roster = async (tabs: Array<Record<string, unknown>>) =>
String((await setup({ tabs: tabs as unknown as Setup['tabs'] }).ask({ action: 'send', pane: '%1' })).roster).split('\n')[0]
- expect(await roster([{ id: 'a', name: 'claude-code-2026-10-12-02-15', named: false, enabled: true, panes: pair }]))
+ expect(await roster([{ id: 'a', name: 'claude-code-2026-10-12-02-15', named: false, panes: pair }]))
.toBe('[Harness] Agent Messages are on in this tab. Teammates:')
- expect(await roster([{ id: 'a', name: 'app', named: true, enabled: true, panes: pair }])).toBe('[Harness] Agent Messages are on in tab "app". Teammates:')
- expect(await roster([{ id: 'a', name: 'app', named: true, enabled: true, panes: pair }, { id: 'b', name: 'web', named: true, enabled: true, panes: pair }]))
+ expect(await roster([{ id: 'a', name: 'app', named: true, panes: pair }])).toBe('[Harness] Agent Messages are on in tab "app". Teammates:')
+ expect(await roster([{ id: 'a', name: 'app', named: true, panes: pair }, { id: 'b', name: 'web', named: true, panes: pair }]))
.toBe('[Harness] Agent Messages are on in tabs "app", "web". Teammates:')
- expect(await roster([{ id: 'a', name: 'app', named: true, enabled: true, panes: pair }, { id: 'b', name: 'New Tab', named: false, enabled: true, panes: pair }]))
+ expect(await roster([{ id: 'a', name: 'app', named: true, panes: pair }, { id: 'b', name: 'New Tab', named: false, panes: pair }]))
.toBe('[Harness] Agent Messages are on in tab "app" and this one. Teammates:')
// A backend from before `named`: only the window's own default name is no name.
- expect(await roster([{ id: 'a', name: 'New Tab', enabled: true, panes: pair }])).toBe('[Harness] Agent Messages are on in this tab. Teammates:')
- expect(await roster([{ id: 'a', name: 'app', enabled: true, panes: pair }])).toBe('[Harness] Agent Messages are on in tab "app". Teammates:')
- })
-
- it('refuses in a tab with Agent Messages off, and when the directory cannot be read', async () => {
- const off = setup({ tabs: [{ id: 'app', name: 'app', enabled: false, panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'api' }] }] })
- expect(await off.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toMatchObject({ error: 'MESSAGES_OFF' })
+ expect(await roster([{ id: 'a', name: 'New Tab', panes: pair }])).toBe('[Harness] Agent Messages are on in this tab. Teammates:')
+ expect(await roster([{ id: 'a', name: 'app', panes: pair }])).toBe('[Harness] Agent Messages are on in tab "app". Teammates:')
+ })
+
+ it('refuses while Agent Messages are off on this computer, saying where to turn them on, and when the directory cannot be read', async () => {
+ // One Settings ▸ Agents switch replaced each tab's chat icon, which the owner hit by mistake (2026-10-12).
+ const off = setup()
+ off.setting(false)
+ const refused = { error: 'MESSAGES_OFF', detail: 'Agent Messages are off on this computer. The person turns them on in Settings ▸ Agents, or with `harness settings agent-messages on`.' }
+ expect(await off.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toEqual(refused)
+ expect(MESSAGES_OFF_TEXT).toBe(refused.detail)
+ // Nor does `harness send` alone list anyone.
+ expect(await off.ask({ action: 'send', pane: '%1' })).toEqual(refused)
+ expect(off.delivered).toEqual([])
+ // Off is the person's word: said so even when the tabs cannot be read.
+ const offAndDown = setup({ backendStatus: 500 })
+ expect(await offAndDown.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toEqual(refused)
+ // On again: it sends at the next look.
+ off.setting(true)
+ expect((await off.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).recipients).toEqual([{ name: 'api', state: 'queued' }])
const down = setup({ backendStatus: 500 })
expect(await down.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toMatchObject({ error: 'DIRECTORY_UNAVAILABLE' })
})
- it('sends nothing when the tab turns Agent Messages off while it asks another machine for names', async () => {
+ it('says a harness alone in its tab, or in none, has no teammates, and still lists its last messages', async () => {
+ const alone = setup({ tabs: [{ id: 'app', name: 'app', panes: [{ machineId: 'm1', agentId: 'lead' }] }, { id: 'web', name: 'web', panes: [{ machineId: 'm1', agentId: 'api' }] }] })
+ const none = { error: 'NO_TEAMMATES', detail: 'No other harness is in this tab. The person puts harnesses in one tab for them to message each other.' }
+ expect(await alone.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toEqual(none)
+ expect(await alone.ask({ action: 'send', pane: '%1', text: 'x' })).toEqual(none)
+ // web is in no tab at all.
+ expect(await alone.ask({ action: 'send', pane: '%3', to: 'lead', text: 'x' })).toEqual(none)
+ expect(await alone.ask({ action: 'send', pane: '%1' })).toEqual({ roster: 'No teammates in this tab yet.', recent: [] })
+ expect(await alone.ask({ action: 'send', pane: '%3' })).toEqual({ roster: 'No teammates in this tab yet.', recent: [] })
+ expect(alone.delivered).toEqual([])
+ })
+
+ /** A send that asks another machine for names, with [meanwhile] done while that machine is asked: the directory is
+ * read and every name learned first, then the names grow old, so only the send asks again. */
+ const whileAsking = async (meanwhile: (t: ReturnType<typeof setup>) => Promise<void> | void) => {
let t: ReturnType<typeof setup>
+ let armed = false
t = setup({ rpc: async (_target, payload) => {
if (payload.action === 'who') {
- t.tabs[0].enabled = false
- t.notice({ type: 'desk_changed', revision: 5 })
- await new Promise((settle) => setTimeout(settle, 0))
+ if (armed) await meanwhile(t)
return { agents: [{ agentId: 'phone', name: 'phone', engine: 'claude' }] }
}
return { statuses: [] }
} })
- expect(await t.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toEqual({ error: 'MESSAGES_OFF', detail: 'api is no longer in a tab with you that has Agent Messages on. Nothing was sent.' })
+ expect(String((await t.ask({ action: 'send', pane: '%1' })).roster)).toContain('phone')
+ t.tick(WHO_MS)
+ armed = true
+ return t
+ }
+
+ it('sends nothing when Agent Messages are turned off while it asks another machine for names', async () => {
+ const t = await whileAsking((t) => t.setting(false))
+ expect(await t.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toEqual({ error: 'MESSAGES_OFF', detail: `${MESSAGES_OFF_TEXT} Nothing was sent.` })
+ expect(t.delivered).toEqual([])
+ expect((await t.ask({ action: 'history' })).messages).toEqual([])
+ })
+
+ it('sends nothing when the teammate leaves the tab while it asks another machine for names', async () => {
+ const t = await whileAsking(async (t) => {
+ t.tabs[0].panes = t.tabs[0].panes.filter((p) => p.agentId !== 'api')
+ t.notice({ type: 'desk_changed', revision: 5 })
+ await new Promise((settle) => setTimeout(settle, 0))
+ })
+ expect(await t.ask({ action: 'send', pane: '%1', to: 'api', text: 'x' })).toEqual({ error: 'NOT_IN_TAB', detail: 'api is no longer in a tab with you. Nothing was sent.' })
expect(t.delivered).toEqual([])
expect((await t.ask({ action: 'history' })).messages).toEqual([])
})
@@ -341,27 +390,31 @@ describe('a harness and the harnesses it started', () => {
at: 1, depth: 1, by: { machineId: 'm1', agentId: by, name: by, engine: 'codex' }, child: { machineId: childMachine, agentId: child, name: child },
})
- it('may not message each other where no tab has Agent Messages on, either way', async () => {
- const t = setup({ tabs: [{ id: 'app', name: 'app', enabled: false, panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'web' }] }] })
+ it('may not message each other while Agent Messages are off, nor without a tab they share, either way', async () => {
+ const t = setup({ tabs: [{ id: 'app', name: 'app', panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'web' }] }] })
start('lead', 'web')
+ t.setting(false)
expect(await t.ask({ action: 'send', pane: '%1', to: 'web', text: 'Also check the footer.' })).toMatchObject({ error: 'MESSAGES_OFF' })
expect(await t.ask({ action: 'send', pane: '%3', to: 'lead', text: 'Done: 3 fixes.' })).toMatchObject({ error: 'MESSAGES_OFF' })
// Nor does `harness send` alone list them.
expect(await t.ask({ action: 'send', pane: '%1' })).toMatchObject({ error: 'MESSAGES_OFF' })
+ t.setting(true)
const none = setup({ tabs: [] })
- expect(await none.ask({ action: 'send', pane: '%1', to: 'web', text: 'x' })).toMatchObject({ error: 'MESSAGES_OFF' })
+ expect(await none.ask({ action: 'send', pane: '%1', to: 'web', text: 'x' })).toMatchObject({ error: 'NO_TEAMMATES' })
+ expect(await none.ask({ action: 'send', pane: '%3', to: 'lead', text: 'x' })).toMatchObject({ error: 'NO_TEAMMATES' })
+ expect(String((await none.ask({ action: 'send', pane: '%1' })).roster)).not.toMatch(/\bweb\b/)
expect(t.delivered).toEqual([])
expect(none.delivered).toEqual([])
})
it('are refused as any other recipient outside the sender\'s tabs, and listed only as tab teammates', async () => {
- // lead and api share a tab with Agent Messages on; web, which lead started, is in none.
+ // lead and api share a tab; web, which lead started, is in none.
const t = setup()
start('lead', 'web')
start('lead', 'api')
const refused = await t.ask({ action: 'send', pane: '%1', to: 'web', text: 'x' })
expect(refused).toEqual({ error: 'UNKNOWN_RECIPIENT', detail: 'No teammate named "web" in this tab. Teammates: api, phone.' })
- expect(await t.ask({ action: 'send', pane: '%3', to: 'lead', text: 'x' })).toMatchObject({ error: 'MESSAGES_OFF' })
+ expect(await t.ask({ action: 'send', pane: '%3', to: 'lead', text: 'x' })).toMatchObject({ error: 'NO_TEAMMATES' })
const roster = await t.ask({ action: 'send', pane: '%1' })
expect(roster.roster).toContain('Teammates:')
expect(roster.roster).not.toMatch(/\bweb\b/)
@@ -375,7 +428,7 @@ describe('a harness and the harnesses it started', () => {
it('a message an older version queued between them under no tab is never delivered, read directory or not', async () => {
vi.useFakeTimers()
// Queued by 0.3.75 under its `started` log: one waiting in web's inbox for its hook, and one to api, which shares
- // a tab with Agent Messages on with lead now.
+ // a tab with lead now.
const store = new MessageStore(join(root, 'state'))
const old = (id: string, to: string) => ({ id, tabId: 'started', at: 1, text: 'Also check the footer.',
from: { machineId: 'm1', agentId: 'lead', name: 'lead', engine: 'codex', machine: 'studio' }, to: [{ machineId: 'm1', agentId: to, name: to }] })
@@ -399,24 +452,24 @@ describe('a harness and the harnesses it started', () => {
expect(t.delivered).toEqual([])
const history = await t.ask({ action: 'history', tabId: 'started' })
expect((history.messages as Array<{ statuses: unknown[] }>).map((m) => m.statuses)).toEqual([
- [expect.objectContaining({ machineId: 'm1', agentId: 'web', state: 'failed', reason: 'it was sent outside any tab with Agent Messages on' })],
- [expect.objectContaining({ machineId: 'm1', agentId: 'api', state: 'failed', reason: 'it was sent outside any tab with Agent Messages on' })],
+ [expect.objectContaining({ machineId: 'm1', agentId: 'web', state: 'failed', reason: 'it was sent outside any tab' })],
+ [expect.objectContaining({ machineId: 'm1', agentId: 'api', state: 'failed', reason: 'it was sent outside any tab' })],
])
t.service.stop()
})
- it('a hand-over an older machine logged under `started` is failed even between two in a tab with Agent Messages on', async () => {
+ it('a hand-over an older machine logged under `started` is failed even between two in one tab', async () => {
const t = setup()
const answer = await t.ask({ action: 'deliver', message: { id: 'm00000cc', tabId: 'started', text: 'hi', at: 5,
from: { machineId: 'm2', agentId: 'phone', name: 'phone', engine: 'claude', machine: 'laptop' }, to: [{ machineId: 'm1', agentId: 'api', name: 'api' }] } }, OWNER_REMOTE)
- expect(answer.statuses).toEqual([expect.objectContaining({ agentId: 'api', state: 'failed', reason: 'it was sent outside any tab with Agent Messages on' })])
+ expect(answer.statuses).toEqual([expect.objectContaining({ agentId: 'api', state: 'failed', reason: 'it was sent outside any tab' })])
expect(t.delivered).toEqual([])
})
it('reach a tab teammate by the start of its id, for a harness whose name is a sentence', async () => {
const titled = { ...session('abcdef99-1', '%3'), title: 'so we have built it, then' } as unknown as RegisteredSession
const t = setup({ agents: [session('lead', '%1', 'codex'), titled],
- tabs: [{ id: 'app', name: 'app', enabled: true, panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'abcdef99-1' }] }] })
+ tabs: [{ id: 'app', name: 'app', panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm1', agentId: 'abcdef99-1' }] }] })
expect((await t.ask({ action: 'send', pane: '%1', to: 'abcdef', text: 'x' })).recipients).toEqual([{ name: 'so we have built it, then', state: 'queued' }])
// Too short to be an id's start.
expect((await t.ask({ action: 'send', pane: '%1', to: 'abcde', text: 'x' })).error).toBe('UNKNOWN_RECIPIENT')
@@ -442,7 +495,13 @@ describe('a harness and the harnesses it started', () => {
it('stay apart across machines: another machine checks against its own tabs', async () => {
const t = setup({ tabs: [] })
start('lead', 'phone', 'm2')
+ expect((await t.ask({ action: 'send', pane: '%1', to: 'phone', text: 'x' })).error).toBe('NO_TEAMMATES')
+ // And while Agent Messages are off here, whatever the tabs say.
+ t.tabs.push({ id: 'app', name: 'app', panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm2', agentId: 'phone' }] })
+ t.notice({ type: 'desk_changed', revision: 5 })
+ t.setting(false)
expect((await t.ask({ action: 'send', pane: '%1', to: 'phone', text: 'x' })).error).toBe('MESSAGES_OFF')
+ expect(t.rpcCalls.filter(([, p]) => p.action === 'deliver')).toEqual([])
})
})
@@ -490,11 +549,21 @@ describe('from the owner\'s other machines', () => {
it('refuses a message for an agent outside the sender\'s tabs, and one that is not a message', async () => {
const t = setup()
const answer = await t.ask({ action: 'deliver', message: incoming('web') }, OWNER_REMOTE)
- expect(answer.statuses).toEqual([expect.objectContaining({ agentId: 'web', state: 'failed' })])
+ expect(answer.statuses).toEqual([expect.objectContaining({ agentId: 'web', state: 'failed', reason: 'it is not in a tab with the sender' })])
expect(t.delivered).toHaveLength(0)
expect(await t.ask({ action: 'deliver', message: { id: 'x' } }, OWNER_REMOTE)).toMatchObject({ error: 'INVALID_MESSAGE' })
})
+ it('refuses a hand-over while this machine has Agent Messages off, whatever the sender\'s machine says', async () => {
+ // Each computer has its own switch: the sender's had it on, and this one's person turned it off.
+ const t = setup()
+ t.setting(false)
+ const answer = await t.ask({ action: 'deliver', message: incoming() }, OWNER_REMOTE)
+ expect(answer.statuses).toEqual([expect.objectContaining({ agentId: 'api', state: 'failed', reason: 'Agent Messages are off on its computer' })])
+ expect(t.delivered).toEqual([])
+ expect(t.inbox.waiting('%2', deliveryKey('m00000aa', 'api'))).toBe(false)
+ })
+
it('names its agents for another machine, and only those it has', async () => {
const t = setup()
expect(await t.ask({ action: 'who', agentIds: ['api', 'ghost', 3] }, OWNER_REMOTE)).toEqual({ agents: [{ agentId: 'api', name: 'api', engine: 'claude', project: 'api' }] })
@@ -504,7 +573,7 @@ describe('from the owner\'s other machines', () => {
})
describe('the roster note and the directory', () => {
- it('puts the note in each agent\'s inbox once the tab has a teammate, and takes it back when the tab turns off', async () => {
+ it('puts the note in each agent\'s inbox once the tab has a teammate, and takes it back when Agent Messages are turned off', async () => {
vi.useFakeTimers()
const t = setup()
t.service.start()
@@ -516,7 +585,7 @@ describe('the roster note and the directory', () => {
}
expect(waiting('%1').some((n) => n.startsWith('0note-'))).toBe(true)
expect(waiting('%2').some((n) => n.startsWith('0note-'))).toBe(true)
- // Web is in no tab with Agent Messages on: nothing.
+ // Web shares no tab: nothing.
expect(waiting('%3')).toEqual([])
// The hook took lead's note: it is not put again.
const note = waiting('%1').find((n) => n.startsWith('0note-'))!.replace(/\.json$/, '')
@@ -524,11 +593,41 @@ describe('the roster note and the directory', () => {
require('node:fs').renameSync(join(t.inbox.paneDir('%1')!, `${note}.json`), join(root, 'inbox-root', 'claimed', `1-${note}.json`))
await vi.advanceTimersByTimeAsync(TICK_MS)
expect(waiting('%1')).toEqual([])
- // Turned off: the notes go.
- t.tabs[0].enabled = false
- t.notice({ type: 'desk_changed', revision: 5 })
- await vi.advanceTimersByTimeAsync(0)
+ // Turned off: the notes go at the next look, with no word from the backend.
+ t.setting(false)
+ await vi.advanceTimersByTimeAsync(TICK_MS)
expect(waiting('%2')).toEqual([])
+ // On again: put back.
+ t.setting(true)
+ await vi.advanceTimersByTimeAsync(TICK_MS)
+ expect(waiting('%2').some((n) => n.startsWith('0note-'))).toBe(true)
+ t.service.stop()
+ })
+
+ it('counts Agent Messages turned on or off as a change of the directory, at its next read', async () => {
+ // Deliveries and notes get another look at once, as for a tab changed (messages/directory.ts).
+ vi.useFakeTimers()
+ const t = setup()
+ t.service.start()
+ await vi.advanceTimersByTimeAsync(0)
+ const reads = () => t.changed.mock.calls.length
+ const first = reads()
+ expect(first).toBeGreaterThan(0)
+ // Read again with nothing changed: no change.
+ t.notice({ type: 'desk_changed', revision: 4 })
+ await vi.advanceTimersByTimeAsync(0)
+ expect(reads()).toBe(first)
+ t.setting(false)
+ t.notice({ type: 'desk_changed', revision: 4 })
+ await vi.advanceTimersByTimeAsync(0)
+ expect(reads()).toBe(first + 1)
+ t.notice({ type: 'desk_changed', revision: 4 })
+ await vi.advanceTimersByTimeAsync(0)
+ expect(reads()).toBe(first + 1)
+ t.setting(true)
+ t.notice({ type: 'desk_changed', revision: 4 })
+ await vi.advanceTimersByTimeAsync(0)
+ expect(reads()).toBe(first + 2)
t.service.stop()
})
@@ -561,8 +660,9 @@ describe('the roster note and the directory', () => {
again.stop()
})
- it('holds a waiting delivery while its tab has Agent Messages off, goes on once it is on again, and fails it later', async () => {
- // Turned off by a slip of the mouse and on again a minute later, a tab failed the message waiting in it (2026-10-12).
+ it('holds a waiting delivery while Agent Messages are off, goes on once they are on again, and fails it later', async () => {
+ // Turned off by a slip of the mouse and on again a minute later, a tab's switch failed the message waiting in it
+ // (2026-10-12). The switch is Settings ▸ Agents now, and a slip there must cost nothing either.
vi.useFakeTimers()
const t = setup()
t.service.start()
@@ -571,8 +671,8 @@ describe('the roster note and the directory', () => {
const key = deliveryKey(reply.id as string, 'api')
const status = async () => ((await t.ask({ action: 'history', limit: 10 })).messages as Array<{ id: string; statuses: Array<{ state: string; reason?: string }> }>)
.find((m) => m.id === reply.id)!.statuses[0]
- const turn = async (enabled: boolean) => {
- t.tabs[0].enabled = enabled
+ const turn = async (on: boolean) => {
+ t.setting(on)
t.notice({ type: 'desk_changed', revision: 6 })
await vi.advanceTimersByTimeAsync(0)
}
@@ -596,7 +696,7 @@ describe('the roster note and the directory', () => {
expect(await status()).toMatchObject({ state: 'queued', reason: HELD_OFF_REASON })
t.tick(HELD_OUTSIDE_MS)
await vi.advanceTimersByTimeAsync(PUMP_MS)
- expect(await status()).toMatchObject({ state: 'failed', reason: 'Agent Messages were turned off in this tab' })
+ expect(await status()).toMatchObject({ state: 'failed', reason: 'Agent Messages were turned off on its computer' })
expect(t.inbox.waiting('%2', key)).toBe(false)
t.service.stop()
})
diff --git a/cli/src/messages/service.ts b/cli/src/messages/service.ts
index 8d3fe1be8..0251e43cd 100644
--- a/cli/src/messages/service.ts
+++ b/cli/src/messages/service.ts
@@ -1,12 +1,12 @@
/**
- * Agent Messages (docs/design/2026-10-10-agent-messages.md): harnesses in a tab with Agent Messages on message
- * each other with `harness send`. This is the whole service, on the core's API, in the core's process or in its
- * own (services/messages.ts, services/messagesProcess.ts):
+ * Agent Messages (docs/design/2026-10-10-agent-messages.md): harnesses in one tab message each other with `harness
+ * send`, while this computer has Agent Messages on (Settings ▸ Agents, on by default). This is the whole service,
+ * on the core's API, in the core's process or in its own (services/messages.ts, services/messagesProcess.ts):
* - `send`: from `harness send` in an agent's pane, over this machine's socket. The pane names the sender.
* - `deliver`, `status`, `who`: from the owner's other machines, over the paired relay.
* - `history`: the windows' log of a tab.
* - `started`: another machine's record of a harness it started here, for the agent client's limits and depth
- * (agentClient/ledger.ts). It lets no one message anyone: only a tab with Agent Messages on does.
+ * (agentClient/ledger.ts). It lets no one message anyone: only sharing a tab does.
* Deliveries to this machine's agents are the mailbox's (mailbox.ts); a message for another machine's agent is
* handed to that machine's daemon, which owns its delivery and is asked what became of it.
*/
@@ -15,6 +15,7 @@ import { hostname } from 'node:os'
import { basename, join } from 'node:path'
import type { CoreApi, ServiceRequests, TurnDelivery } from '../core/api.js'
import { env } from '../config/env.js'
+import { readAgentSettings } from '../lib/agentSettings.js'
import type { RegisteredSession } from '../lib/registry.js'
import { MessageDirectory, type Member } from './directory.js'
import { PaneInbox } from './inbox.js'
@@ -58,10 +59,16 @@ export const REMOTE_STATUS_MS = 15_000
export const WHO_MS = 60_000
/** How old an inbox file nothing here waits on must be before a start sweeps it away. */
export const SWEEP_AFTER_MS = 10 * 60_000
-/** How long a delivery no tab with Agent Messages on carries is held, given to no one, before it fails. */
+/** How long a delivery no tab carries (Agent Messages turned off, or the tab left) is held, given to no one, before
+ * it fails. */
export const HELD_OUTSIDE_MS = 5 * 60_000
-export const HELD_OFF_REASON = 'Agent Messages are off in this tab: it waits 5 minutes for them to be on again, then fails'
+export const HELD_OFF_REASON = 'Agent Messages are off on its computer: it waits 5 minutes for them to be on again, then fails'
export const HELD_LEFT_REASON = 'it is not in a tab with the sender: it waits 5 minutes for that to change, then fails'
+/** How long this computer's Agent Messages setting (Settings ▸ Agents) is taken as read: the mailbox's pump asks
+ * every 2 s (mailbox.ts PUMP_MS), and a send or a hand-over asks too. */
+export const SETTING_FRESH_MS = 2_000
+/** What `harness send` says while this computer has Agent Messages off: where the person turns them on again. */
+export const MESSAGES_OFF_TEXT = 'Agent Messages are off on this computer. The person turns them on in Settings ▸ Agents, or with `harness settings agent-messages on`.'
const PANE = /^%\d{1,9}$/
/** The most messages `harness send` alone gives an agent at once, unread ones first. */
@@ -81,9 +88,9 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
const self = (): string => core.daemon.machineId()
const at = (machineId: string) => ({ port: core.daemon.port, machineId, dataDir: options.dataDir ?? core.dataDir })
const store = new MessageStore(options.stateDir ?? join(core.dataDir, 'agent-messages'))
- // Who started which harness is the agent client's (limits, depth, who may close what), never a way to message.
- // Agent Messages off means off: a harness started by another reaches it only through a tab with Agent Messages
- // on, like any teammate (owner, 2026-10-11, on finding agents messaging each other with no tab turned on).
+ // Who started which harness is the agent client's (limits, depth, who may close what), never a way to message: a
+ // harness started by another reaches it only through a tab they share, like any teammate (owner, 2026-10-11, on
+ // finding agents messaging each other with no tab turned on).
const lineage = new Ledger(options.ledgerFile ?? ledgerPath(core.dataDir))
const inbox = new PaneInbox(options.inboxRoot ?? env.HARNESS_AGENT_MESSAGES_DIR)
/** Other machines' names for their agents, with when they were asked. */
@@ -95,7 +102,17 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
let timer: ReturnType<typeof setInterval> | null = null
let lastRemoteStatus = -Infinity
+ // Settings ▸ Agents, kept by the core in the data folder (lib/agentSettings.ts) and written by `harness settings`
+ // too, which tells no one: a small file, read again at most every SETTING_FRESH_MS, so a switch turned off takes
+ // effect at the next look.
+ let setting = { on: true, at: -Infinity }
+ const messagingOn = (): boolean => {
+ if (now() - setting.at >= SETTING_FRESH_MS) setting = { on: readAgentSettings(options.dataDir ?? core.dataDir).agentMessages, at: now() }
+ return setting.on
+ }
+
const directory = new MessageDirectory({
+ on: messagingOn,
read: async () => {
const response = await core.account.backend('GET', '/api/agent-messages')
if (response.status !== 200 || response.body.success !== true) throw new Error('directory unavailable')
@@ -133,23 +150,24 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
/**
* Why a local delivery may never be made, whatever the tabs say, or null. Before 2026-10-11 a harness and one it
- * started messaged each other with no tab on, logged under `started`; Agent Messages off means off, so what an
- * older version left waiting there is never delivered, even to two that share a tab with it on now. Asked before
+ * started messaged each other with no tab on, logged under `started`; only a tab carries a message, so what an
+ * older version left waiting there is never delivered, even to two that share a tab now. Asked before
* the directory is read too: the hook takes what waits in a pane's inbox without asking, and a directory that
* cannot be read (signed out, the backend down) would otherwise leave it there to be taken.
*/
function forbidden(delivery: LocalDelivery): string | null {
- return store.entry(delivery.messageId)?.message.tabId === 'started' ? 'it was sent outside any tab with Agent Messages on' : null
+ return store.entry(delivery.messageId)?.message.tabId === 'started' ? 'it was sent outside any tab' : null
}
/** When the tabs stopped carrying each local delivery (`messageId agentId`), while they do not. */
const outsideSince = new Map<string, number>()
/**
- * Whether a local delivery may be made: null; held, given to no one, while no tab with Agent Messages on carries
- * it, for HELD_OUTSIDE_MS; refused after that, or at once when it may never be made. Only what may never be made is
- * refused before the directory is read. A tab turned off by a slip of the mouse and on again a minute later failed
- * the message waiting in it (owner, 2026-10-12): held, it goes on once the tab is on again.
+ * Whether a local delivery may be made: null; held, given to no one, while no tab carries it (Agent Messages are
+ * off here, or the two no longer share a tab), for HELD_OUTSIDE_MS; refused after that, or at once when it may never
+ * be made. Only what may never be made is refused before the directory is read. A tab's switch turned off by a slip
+ * of the mouse and on again a minute later failed the message waiting in it (owner, 2026-10-12): held, it goes on
+ * once it is carried again.
*/
function verdict(delivery: LocalDelivery): { refused: string } | { held: string } | null {
const entry = store.entry(delivery.messageId)
@@ -159,17 +177,16 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
if (!directory.current()) return null
const key = `${delivery.messageId} ${delivery.agentId}`
const recipient = { machineId: self(), agentId: delivery.agentId }
- // Only a tab with Agent Messages on carries a message.
+ // Only a tab the two share carries a message, and none while Agent Messages are off here.
if (directory.shared(entry.message.from, recipient)) { outsideSince.delete(key); return null }
- const tab = directory.current()!.tabs.find((t) => t.id === entry.message.tabId)
- const off = Boolean(tab && !tab.enabled)
+ const off = !directory.on()
const since = outsideSince.get(key) ?? now()
if (now() - since < HELD_OUTSIDE_MS) {
outsideSince.set(key, since)
return { held: off ? HELD_OFF_REASON : HELD_LEFT_REASON }
}
outsideSince.delete(key)
- return { refused: off ? 'Agent Messages were turned off in this tab' : 'it is no longer in a tab with the sender' }
+ return { refused: off ? 'Agent Messages were turned off on its computer' : 'it is no longer in a tab with the sender' }
}
function localChanged(status: DeliveryStatus, delivery: LocalDelivery): void {
@@ -263,7 +280,8 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
if (wait) await done
}
- /** The note a local agent should have read, or null when it is in no tab with Agent Messages on and a teammate. */
+ /** The note a local agent should have read, or null when it shares no tab with a teammate, or Agent Messages are
+ * off here. */
function rosterOf(agentId: string): { text: string; signature: string } | null {
const me = { machineId: self(), agentId }
const peers = directory.peers(me)
@@ -332,10 +350,11 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
if (!PANE.test(pane)) throw new MessageError('NOT_A_HARNESS', 'Run harness send from a harness pane.')
const session = live().find((s) => s.tmuxPane === pane)
if (!session) throw new MessageError('NOT_A_HARNESS', 'This pane is not a harness Harness knows. Run harness send from an agent\'s pane.')
- if (!await directory.refresh()) throw new MessageError('DIRECTORY_UNAVAILABLE', 'Harness could not read which tabs have Agent Messages on. Try again in a moment.')
+ // Off is the person's word, answered before the tabs are read: a backend that cannot be reached is not the reason.
+ if (!directory.on()) throw new MessageError('MESSAGES_OFF', MESSAGES_OFF_TEXT)
+ if (!await directory.refresh()) throw new MessageError('DIRECTORY_UNAVAILABLE', 'Harness could not read who is in which tab. Try again in a moment.')
const me = { machineId: self(), agentId: session.agentId }
const peers = directory.peers(me)
- if (!directory.tabsOf(me).length) throw new MessageError('MESSAGES_OFF', 'Agent Messages are off in this tab. The person turns them on with the chat icon on the tab, or the tab\'s right-click menu.')
await learnNames(peers, true)
const mates = distinct(me, peers)
const names = (Array.isArray(payload.to) ? payload.to : typeof payload.to === 'string' ? payload.to.split(',') : [])
@@ -345,6 +364,8 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
// was compacted asks this to learn again what it was told: seen on a real team, one rebuilt it from its team
// history in five commands.
if (!names.length && !text) return { roster: rosterOf(session.agentId)?.text ?? 'No teammates in this tab yet.', recent: recentFor(me) }
+ // Alone in its tab, or in none: a name it gives can be no one's, and the person is the one who can change that.
+ if (!peers.length) throw new MessageError('NO_TEAMMATES', 'No other harness is in this tab. The person puts harnesses in one tab for them to message each other.')
if (!names.length) throw new MessageError('USAGE', 'Name who to message: harness send <name> "text"')
if (!text.trim()) throw new MessageError('USAGE', 'Write the message: harness send <name> "text"')
if (text.length > LIMITS.text) throw new MessageError('TOO_LONG', `A message holds at most ${LIMITS.text} characters.`)
@@ -364,10 +385,12 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
}
}
if (recipients.length > LIMITS.recipients) throw new MessageError('TOO_MANY_RECIPIENTS', `A message goes to at most ${LIMITS.recipients} teammates.`)
- // The first recipient's tab names the message's log. The directory can change while other machines are asked
- // for names: a tab turned off, or left, meanwhile leaves none, and nothing is sent.
+ // The first recipient's tab names the message's log. The directory and the setting can change while other
+ // machines are asked for names: Agent Messages turned off, or the tab left, meanwhile leaves none, and nothing is
+ // sent.
const tab = directory.shared(me, recipients[0])
- if (!tab) throw new MessageError('MESSAGES_OFF', `${recipients[0].name} is no longer in a tab with you that has Agent Messages on. Nothing was sent.`)
+ if (!tab && !directory.on()) throw new MessageError('MESSAGES_OFF', `${MESSAGES_OFF_TEXT} Nothing was sent.`)
+ if (!tab) throw new MessageError('NOT_IN_TAB', `${recipients[0].name} is no longer in a tab with you. Nothing was sent.`)
const times = (sent.get(session.agentId) ?? []).filter((t) => now() - t < LIMITS.window)
if (times.length >= LIMITS.perSender) {
core.clients.windows({ type: 'messages_changed', payload: { limited: { machineId: self(), agentId: session.agentId } } })
@@ -480,7 +503,7 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
if (!message) throw new MessageError('INVALID_MESSAGE', 'That is not a message.')
// This machine's own harnesses send through `send`, which names them by their pane: never as another's.
if (message.from.machineId === self()) throw new MessageError('NOT_FROM_THERE', 'A message from this machine is sent here, not handed over.')
- if (!await directory.refresh()) throw new MessageError('DIRECTORY_UNAVAILABLE', 'Harness could not read which tabs have Agent Messages on. It is handed over again later.')
+ if (!await directory.refresh()) throw new MessageError('DIRECTORY_UNAVAILABLE', 'Harness could not read who is in which tab. It is handed over again later.')
if (store.state.local.filter((d) => d.state === 'queued').length >= LIMITS.waiting) {
throw new MessageError('MAILBOX_FULL', 'Too many messages are waiting on that machine. It is handed over again later.')
}
@@ -489,8 +512,10 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})
const statuses: DeliveryStatus[] = []
for (const r of message.to.filter((r) => r.machineId === self())) {
if (!known && !store.state.local.some((d) => d.messageId === message.id && d.agentId === r.agentId)) {
- if (directory.current() && !directory.shared(message.from, r)) {
- store.status({ messageId: message.id, machineId: self(), agentId: r.agentId, state: 'failed', reason: 'it is not in a tab with Agent Messages on with the sender', at: now() })
+ // Off here, a hand-over fails at once, as one to an agent outside the sender's tabs does: only what already
+ // waits here is held through a switch turned off and on again.
+ if (!directory.shared(message.from, r)) {
+ store.status({ messageId: message.id, machineId: self(), agentId: r.agentId, state: 'failed', reason: directory.on() ? 'it is not in a tab with the sender' : 'Agent Messages are off on its computer', at: now() })
} else {
store.status({ messageId: message.id, machineId: self(), agentId: r.agentId, state: 'queued', at: now() })
mailbox.accept(message, r.agentId)
diff --git a/cli/src/services/AGENTS.md b/cli/src/services/AGENTS.md
index d409125c7..529e445d8 100644
--- a/cli/src/services/AGENTS.md
+++ b/cli/src/services/AGENTS.md
@@ -184,8 +184,9 @@ like any other. Named in `HARNESSD_SERVICES`, it starts with the others.
- **What asks.** A request for a service that has not connected yet (`serviceLinks` `onDemand`, in
`src/core/main.ts`) asks for it and waits for it, within the request's own wait. The service is welcomed
- before its queued requests are delivered. Each experiment with saved state in the data folder is
- asked for as the core starts (`src/core/experiments.ts`). The devices are asked for once there is a device:
+ before its queued requests are delivered. Each experiment with saved state in the data folder, or with its
+ Settings ▸ Agents switch on (Agent Messages, on by default), is asked for as the core starts, and when a
+ Settings ▸ Agents write leaves that switch on (`src/core/experiments.ts`). The devices are asked for once there is a device:
a dial's port in /dev, a paired Wi-Fi device, or its session (`src/core/devicesWake.ts`). Models is asked
for as the core starts when grid is in use here: a managed grid, whose pin it follows, saved grid pictures,
which agents' grid notes are read from, or local models (`src/core/modelsWake.ts`); otherwise its first
@@ -206,7 +207,8 @@ like any other. Named in `HARNESSD_SERVICES`, it starts with the others.
An experiment (the orchestrator, Agent Messages, Share, memory, the router) is a service that costs nothing until it is
on: its own process, which the master starts only when the core asks for it (`want`), when one of
-its requests arrives or, as the core starts, when its saved state is in the data folder. Off, nothing of it runs or
+its requests arrives or, as the core starts, when its saved state is in the data folder or its Settings ▸ Agents
+switch is on (Agent Messages, on by default since 2026-10-12, so its agents get its note). Off, nothing of it runs or
is loaded anywhere; one failing costs its own process and nothing else. `e2e/experiments.e2e.ts` proves it:
off, on by request, on by saved state, killed, hung and crashing on every start.
@@ -221,7 +223,8 @@ To add one:
also reads the backend as the account (`core.account.backend`) and has its welcomes signed by the gateway
(`core.account.observerKey`), so it holds no credential, and watches terminals read-only
(`core.terminals.watch`, `services/watchLink.ts`).
-2. Its entry in `EXPERIMENTS` (`src/core/api.ts`): its requests and its saved state.
+2. Its entry in `EXPERIMENTS` (`src/core/api.ts`): its requests, its saved state, and its Settings ▸ Agents
+ `setting` if the person turns it on and off there (`src/lib/agentSettings.ts`).
3. Its process in `SERVICE_HOSTS` (`src/harnessd/services.ts`) with `onDemand: true`, and its runner in
`SERVICE_RUNNERS` (`src/serviceProcess.ts`).
4. Its start for the core's own process, in `services/inline.ts`, and one line in `core/main.ts` that starts
diff --git a/cli/src/services/messages.ts b/cli/src/services/messages.ts
index a9ca7887a..26823a17f 100644
--- a/cli/src/services/messages.ts
+++ b/cli/src/services/messages.ts
@@ -1,6 +1,6 @@
/**
- * Agent Messages (`messages`), an experiment: harnesses in a tab with Agent Messages on message each other with
- * `harness send` (messages/service.ts, docs/design/2026-10-10-agent-messages.md). Its typed deliveries go
+ * Agent Messages (`messages`), an experiment: harnesses in one tab message each other with `harness send`, while
+ * Settings ▸ Agents has it on, the default (messages/service.ts, docs/design/2026-10-10-agent-messages.md). Its typed deliveries go
* through `core.turns.deliver` under `team:` ids, which the core writes only into an idle, empty composer, and
* the core asks in line whether one may still be written (`canWrite`).
* - The `agent_messages` request: `harness send` in an agent's pane, the owner's other machines, the windows.
diff --git a/docs/design/2026-10-10-agent-messages.md b/docs/design/2026-10-10-agent-messages.md
index b8c46ffaf..3024eace9 100644
--- a/docs/design/2026-10-10-agent-messages.md
+++ b/docs/design/2026-10-10-agent-messages.md
@@ -34,8 +34,11 @@ So the product needs a safe doorbell, and nothing more.
## What the person sees
-Setup is putting harnesses in a tab and turning **Agent Messages** on for that tab. It is **off by default**,
-per tab.
+Setup is putting harnesses in a tab. **Agent Messages** is one switch per computer, in Settings ▸ Agents
+(`harness settings agent-messages on|off` from a terminal), and it is **on by default**: while it is on, every
+tab carries messages between its harnesses; off, no tab on that computer does. Until October 12 each tab had a
+switch of its own, a 💬 beside its ×, off by default; it was easy to hit by mistake, and the owner turned a tab off
+that way and failed a message waiting in it, so it became this one setting (owner, 2026-10-12).
How they work together comes from how they are prompted:
@@ -48,34 +51,19 @@ it is not a switchboard. Harness has no roles.
### The tab
-💬 stands for a chat icon: two speech bubbles (`bubble.left.and.bubble.right` on macOS, Lucide
-`messages-square` elsewhere), agents talking. It replaced ⇄, which read as machines moving data (owner,
-2026-10-11). Show Agent Messages uses a bubble with text lines.
+A tab shows nothing of Agent Messages: no switch beside its ×, and no traffic. Its status slot keeps the
+working spinner, ✓ or ?, and messages arrive when they arrive; an animated 💬 there, for 10 seconds after each
+message, sent the owner looking in the panes for messages that agents take at their tool calls, so it went
+(owner, 2026-10-12). The tab's right-click menu and the File menu keep **Show Agent Messages** (a speech bubble
+with text lines) and nothing else of it: the **Agent Messages** checkmark that turned a tab on went with the
+tab's 💬.
-💬 sits just left of ×, and hovering a tab shows both. Tabs show no shortcut (⌘1…⌘9 still work), and
-holding ⌘ changes nothing on them (owner, 2026-10-11).
+### Settings ▸ Agents
-| State | Not hovered | Hovered | Click 💬 |
-|---|---|---|---|
-| Off (default) | `app ✓` | `app ✓ 💬 ×` (💬 a quiet outline) | turns on |
-| On | `app ✓` | `app ✓ 💬 ×` (💬 filled, in color) | turns off |
-
-The tab shows no traffic: its status slot keeps the working spinner, ✓ or ?, and messages arrive when they
-arrive. An animated 💬 there, for 10 seconds after each message, sent the owner looking in the panes for
-messages that agents take at their tool calls, so it went (owner, 2026-10-12). The color of an on 💬 is the
-design system's accent blue (`AppPalette.accentOnSurface`), its one color for "on" and selection; it stays
-clear of the status marks' cyan, green, yellow and red, and the bubbles' shape carries the meaning too. At
-rest a tab gives its name the whole width; when hovered, a name that would run into 💬 and × moves left
-only as far as they need, then gives up its tail.
-
-On and off differ in shape as well as color: on, the bubbles are filled, at full strength; off, an outline
-at a third of the text's strength. One outline in two tints read alike ("really hard to see on/off
-states", owner, 2026-10-12, who chose filled over a blue pill and a slash). 💬 and × are 20pt targets 8pt
-apart (16pt, 3pt apart, were easy to click by mistake), and the tab's × is the pane's: 7pt across with a
-1pt stroke (AppKit `xmark` 9pt semibold beside Lucide's 12pt `x`).
-
-Tooltips: "Agent messages off · click to turn on", "Agent messages on · click to turn off". The tab's
-right-click menu and the File menu gain **Agent Messages** (a checkmark) and **Show Agent Messages**.
+**Agent Messages**, beside the other things the person lets agents do on this computer
+(docs/design/2026-10-11-agent-client.md): "agents in the same tab may message each other", on by default. It is
+kept by the daemon in its data folder (`agent-settings.json`, `agentMessages`), so each computer has its own:
+turned off on one, its agents neither send nor receive, and a teammate on another computer is told so.
### Panes
@@ -116,8 +104,9 @@ answers to the whole name. The note names a tab the person named; any other, whi
themselves (`code`, a project), is "this tab" (`named` in the backend's directory). The command prints the message
ID and each recipient's state.
-When a tab with Agent Messages on has two or more harnesses, each agent receives a short note through the
-messages hook (below) at its next tool call, and again when the roster changes. An agent whose context was
+While Agent Messages are on and a tab has two or more harnesses, each agent receives a short note through the
+messages hook (below) at its next tool call, and again when the roster changes; turned off, the notes waiting
+are taken back. An agent whose context was
compacted runs `harness send` alone to read them, and its last few messages, again:
```
@@ -171,15 +160,26 @@ not only `send` (docs/design/2026-10-11-agent-client.md, No permission prompts).
file in the temporary folder (its real path, one name): otherwise it could read for an agent what a deny rule or
the sandbox keeps from it, and send that to a teammate on another machine.
+`harness send` says plainly why it sent nothing: `MESSAGES_OFF` while this computer has Agent Messages off
+("The person turns them on in Settings ▸ Agents, or with `harness settings agent-messages on`"), answered
+before the tabs are read; `NO_TEAMMATES` for an agent alone in its tab, or in none (`harness send` alone still
+answers "No teammates in this tab yet." and its last messages); `NOT_IN_TAB` when the recipient left the tab
+while the send was under way.
+
## How it works
-Agent Messages is the `messages` experiment, in a process of its own (`messages`). Its contract with the core
-is the one Swarm's had: `core.turns.deliver` under `team:` delivery ids, and `MessagesPort.canWrite`, asked in
-line as one is written. It costs nothing until a tab turns it on: the process starts when a tab is turned on
-from this machine, on its first request, or when its saved state is in the data folder (`agent-messages/`).
-Turning a tab on starts it because on one machine nothing else would: its agents never got the note, and never
-heard of `harness send`. Another machine's window starts it with its first request for the tab's log. (It began as Swarm's `collaboration`
-experiment in the `teams` process, rewritten in place; both were renamed when Swarm's last code went.)
+Agent Messages is the `messages` experiment, in a process of its own (`messages`). Its contract with the core is
+the one Swarm's had: `core.turns.deliver` under `team:` delivery ids, and `MessagesPort.canWrite`, asked in line
+as one is written. Its process starts with the core while the setting is on (`EXPERIMENTS.messages.setting`,
+core/experiments.ts), and when Settings ▸ Agents leaves it on through the daemon (`PATCH /api/agent-settings`): on
+one machine nothing else would start it, and its agents would never get the note or hear of `harness send` (a
+fresh Mac, 2026-10-12). That is the price of on by default: one more process at idle on every computer, signed in
+or not (61 MiB resident after 20 idle seconds, from the release bundle on a Mac, beside search's 78; 2026-10-12).
+Off, it costs nothing until its first request or its saved state (`agent-messages/`) starts it; another machine's
+window starts it with its first request for the tab's log. `harness settings` writes the file without the daemon:
+a running service reads it within 2 seconds, and one that is not running starts at its next request or the next
+start. (It began as Swarm's `collaboration` experiment in the `teams` process, rewritten in place; both were
+renamed when Swarm's last code went.)
### Identity
@@ -191,18 +191,22 @@ already type into any pane.
### Who may message whom
-The backend keeps one record per tab, `agent_message_tabs` (`{userId, tabId, enabled}`, absent means off),
-beside the desk; the desk's format does not change, because a backend pod that has not upgraded drops a tab
-whose JSON it does not know (`desk.ts` `parseTabs`). `GET /api/agent-messages` answers every tab with its
-owned panes (`machineId`, `agentId`) and its flag, and the machines' names; `PATCH /api/agent-messages/tabs/:tabId`
-sets the flag and publishes the account's existing `desk_changed`. The window reads and sets the flag through the
-daemon's proxy, like `/api/desk`, so drawing the tabs never starts the service. The service reads the directory as
-Swarm did: polled every 15 s, read again on `desk_changed`, and fresh before each send.
+`GET /api/agent-messages` answers the account's tabs, each with its owned panes (`machineId`, `agentId`), and the
+machines' names. The service reads it as Swarm did: polled every 15 s, read again on the account's
+`desk_changed`, and fresh before each send. It reads this computer's setting from the data folder at most every
+2 seconds; a change counts as a change of the directory at its next read, and the notes and waiting deliveries
+heed it at their next look.
+
+The backend still keeps one record per tab, `agent_message_tabs` (`{userId, tabId, enabled}`), answers each
+tab's flag beside its panes, and sets it at `PATCH /api/agent-messages/tabs/:tabId`, for older windows that draw
+a tab's 💬 from it and turn it through the daemon's proxy. No daemon reads the flag now, and the daemon passes the
+switch on without acting on it.
-A message goes only to harnesses that share a tab with the sender, in a tab whose flag is on. The sender's
-daemon checks; the recipient's daemon checks again before delivering, and holds its deliveries until it has read
-the directory. Only another of the owner's machines hands a message over (`deliver`), never a process on this
-one, and never naming this machine as the sender.
+A message goes only to harnesses that share a tab with the sender, while the sender's computer has Agent
+Messages on. The sender's daemon checks; the recipient's daemon checks again before delivering, against its own
+setting too (a hand-over to a computer with it off fails, "Agent Messages are off on its computer"), and holds
+its deliveries until it has read the directory. Only another of the owner's machines hands a message over
+(`deliver`), never a process on this one, and never naming this machine as the sender.
### Delivery
@@ -243,12 +247,14 @@ and a pane number tmux gives out again is another's. A stopped harness's files a
returns; a start sweeps old files nothing waits on.
States: **queued**, **delivered** (claimed by the hook, or typed; "unconfirmed" when the core could not say),
-**failed** (the recipient left the tab or the flag was turned off), each with the time, the route and a reason.
+**failed** (the recipient left the tab, or Agent Messages were turned off on its computer), each with the time, the
+route and a reason.
-A delivery no tab with Agent Messages on carries any more is held for 5 minutes before it fails: out of the hook's
-reach and never typed, so off still means off, and put back once a tab carries it again. A tab turned off by a slip
-of the mouse and on again a minute later failed the message waiting in it (owner, 2026-10-12); a harness that leaves
-its tab for a moment loses nothing either.
+A delivery no tab carries any more (Agent Messages turned off on the recipient's computer, or the two no longer
+share a tab) is held for 5 minutes before it fails: out of the hook's reach and never typed, so off still means
+off, and put back once it is carried again. A tab's 💬 turned off by a slip of the mouse and on again a minute
+later failed the message waiting in it (owner, 2026-10-12); a slip in Settings ▸ Agents, or a harness that leaves
+its tab for a moment, loses nothing.
### Limits
@@ -271,15 +277,21 @@ Experimental → Swarm collaboration, the Swarm conversation views on desktop an
Messages, pane marks, and Swarm's views and setting removed.
3. Cleanup: the phone's Swarm views, the backend's `tab_channels`, the core's prompt scopes. The phone shows
no message log: the owner dropped it (October 11, 2026).
+4. One switch (owner, 2026-10-12): the daemon and `harness settings` read Settings ▸ Agents' `agentMessages`, on
+ by default, and no tab's flag; the desktop drops the tab's 💬 and its **Agent Messages** menu item, keeps
+ **Show Agent Messages**, and shows the switch in Settings ▸ Agents. The backend's per-tab records stay, unread,
+ for older windows.
## Verification
-- Unit: the service, directory, store, mailbox and both delivery routes at 100% (`npm run test:core`); the
- hook script; the backend routes.
-- End to end on the real daemon with the fake engines (`e2e/agentMessages.e2e.ts`): off until used, on by saved
- state; `send` from a pane through a signed-in daemon whose directory the fake backend answers; an idle recipient
- gets a typed prompt; working Claude Code and Codex agents get the hook's context at the next tool call with
- nothing typed; flag off refuses; a hand-over from a process on this machine is refused.
+- Unit: the service, directory, store, mailbox and both delivery routes (`messages/*.spec.ts`); which experiments
+ start with the core, by saved state or setting, at 100% (`npm run test:core`); the hook script; the backend routes.
+- End to end on the real daemon with the fake engines (`e2e/agentMessages.e2e.ts`): on by default, a fresh daemon
+ starts it with no request and gives two agents in one tab their note; turned off, no process until used, or until
+ Settings ▸ Agents turns it on (an older window's tab switch starts nothing); on by saved state; `send` from a pane
+ through a signed-in daemon whose directory the fake backend answers; an idle recipient gets a typed prompt;
+ working Claude Code and Codex agents get the hook's context at the next tool call with nothing typed; turned off
+ in Settings ▸ Agents, it refuses; a hand-over from a process on this machine is refused.
- In unit tests (`messages/*.spec.ts`): drafts, dialogs and refusals that may have typed; parking; restarts and a
new core giving attempts back; a moved, stopped or restarted harness; the hand-over to another machine and its
status over a fake relay. Not yet end to end: two daemons over the real relay.
diff --git a/docs/design/2026-10-11-agent-client.md b/docs/design/2026-10-11-agent-client.md
index ea7cdff55..cd6dea03d 100644
--- a/docs/design/2026-10-11-agent-client.md
+++ b/docs/design/2026-10-11-agent-client.md
@@ -33,7 +33,8 @@ Harness is for:
and resumes later.
4. **The person sees it**: what an agent starts appears as a pane on the desktop and the phone, where the person
can watch, answer or stop it. Sub-agents are invisible.
-5. **Existing peers**: harnesses the person started, in a tab with Agent Messages on.
+5. **Existing peers**: harnesses the person started, in the agent's tab, while Agent Messages are on (Settings ▸
+ Agents, on by default).
Claude Code itself now has `ListAgents`, `SendMessage` and `notify_when_idle` for its own sessions on one
machine. The verbs below take the same shape on purpose; what Harness adds is every engine, every machine,
@@ -46,7 +47,7 @@ harness ps [--all] # the harnesses here: state,
harness new [agent] [@machine] [folder] --name N -- <task> # exists; now knows when an agent runs it
harness show <name> [--chars N] # its state, the last ask and the answer
harness wait <name>[,<name>…] [--any] [--timeout 30m]
-harness send <name>[,<name>…] "text" # exists (Agent Messages): teammates in a tab with it on, only
+harness send <name>[,<name>…] "text" # exists (Agent Messages): teammates in its tab, while it is on, only
harness close <name> [--now] # save its screen and stop it; resumable
```
@@ -94,10 +95,10 @@ itself: it is a capable model and knows its own task better than any router. It
which `harness ps` gives it (name, what it is about, state, engine, machine, folder, how long ago it stopped),
and one rule, in its startup note:
-1. **Ownership first.** An agent may give work only to a harness it started, or to one in a tab with Agent
- Messages on. A harness a person is driving is read-only to agents: `show` and `wait` it, never `send`.
+1. **Ownership first.** An agent may give work only to a harness it started, or to a teammate in its tab while
+ Agent Messages are on. A harness a person is driving is read-only to agents: `show` and `wait` it, never `send`.
2. **Then sameness.** If a harness it may use is on the same work on the same subject (the router's question),
- is idle or resumable, and is its teammate in a tab with Agent Messages on, send there: it holds the context.
+ is idle or resumable, and is its teammate in its tab while Agent Messages are on, send there: it holds the context.
Otherwise `new`: a follow-up with the fuller task, unrelated work, work to run in parallel, another engine or
machine, or the matching harness is busy with something else. Starting a harness gives no way to message it
(below, "Agent Messages off means off").
@@ -187,7 +188,7 @@ server's environment as it removes harnessd's own (`lib/agentSessionEnv.ts`).
`harness mcp` serves the verbs as MCP tools on stdin and stdout, for agents that reach tools through MCP rather
than a shell (Claude Desktop, Cursor, Windsurf; Claude Code and Codex with the Harness plugin): `harness_list`,
`harness_start`, `harness_wait`, `harness_read`, `harness_close`, and `harness_send` only in a harness's own pane,
-since nothing can message an agent outside one, and then only to teammates in a tab with Agent Messages on. Each
+since nothing can message an agent outside one, and then only to teammates in its tab while Agent Messages are on. Each
call runs the verb as `harness` in a process of its own, so the rules above decide what it may do, and the tool's
answer is the text the verb prints. `initialize` carries the when-to-use rules as the server's instructions.
@@ -233,7 +234,8 @@ its launch contract (`EngineLaunch.attribution`) and applied by `engines/kit/att
The person turns it off per computer with `harness settings pull-request-line off`: `pullRequestLine` in
`<data>/agent-settings.json`, beside `agentsStartAgents`, on by default and read at each launch, so a harness running
then keeps its line until it restarts. `/api/agent-settings` reads and writes it too; Settings ▸ Agents does not show it
-yet, as a setting in the apps needs an agreed mockup first. Not covered yet: the other eleven engines (no contract),
+yet, as a setting in the apps needs an agreed mockup first. The same file keeps `agentMessages` since October 12:
+Agent Messages within a tab, on by default (`harness settings agent-messages on|off`, 2026-10-10-agent-messages.md). Not covered yet: the other eleven engines (no contract),
the orchestrator's harnesses, and a machine whose daemon predates `startedBy`, which ignores it.
## Limits
@@ -259,7 +261,7 @@ spends the person's tokens. Every limit refuses with a clear error; nothing is d
"No asking. Just do. The best UX." Every verb needs the daemon, which Codex's sandbox cannot reach, so Codex asked
the person before each one: about four questions for one hand-off (new, wait, show, close). In its auto mode it
answered itself, but only after a failed try inside the sandbox. The safety is Harness's own, above: the switch for
-agents starting agents, the limits, closing only what you started, and Agent Messages per tab. So the engines run
+agents starting agents, the limits, closing only what you started, and Agent Messages only within a tab. So the engines run
the verbs without asking.
- **Codex, shell.** `<CODEX_HOME>/rules/harness.rules`, which Harness owns whole (written at every daemon start and
@@ -378,8 +380,8 @@ No core change, no new service.
holds is asked after by its creation id for up to a minute, so a held launch is not left running with an agent's
task and no record. `new` also stopped printing "Created" for a launch the daemon refused or could not confirm.
Two starts at the same moment from one harness can both pass the limits: they count what was recorded before.
-- **`send`**: nothing of its own. A harness messages another only where the person turned Agent Messages on in a
- tab the two share, like any teammate (`harness send` also takes the start of an id there).
+- **`send`**: nothing of its own. A harness messages another only in a tab the two share, while Agent Messages are
+ on, like any teammate (`harness send` also takes the start of an id there).
- **Another machine.** `new @mini` works as before; `show`, `wait` and `close` find a harness the caller started
there through its record and reach it over the paired relay.
@@ -389,18 +391,21 @@ The first version let a harness and the harnesses it started message each other
machine (the lineage exception), kept in a `started` log beside the tabs' logs, and the new harness's header invited
it to. With CLI 0.3.75 live, the owner found agents messaging each other before turning Agent Messages on
anywhere, and decided: **Agent Messages off means off; a harness started by another gets no exception.** A harness
-may message another only where the person turned Agent Messages on (the tab's chat icon), like any teammate.
+may message another only where the person turned Agent Messages on, like any teammate: then a tab's chat icon,
+since October 12 one switch per computer, on by default, within a tab the two share (Settings ▸ Agents,
+2026-10-10-agent-messages.md).
- `messages/service.ts` reads who started what only to keep another machine's record (`started`, for limits and
depth); `send`, `harness send` alone and delivery go through the tabs alone. A send to a harness one started, with
- no shared tab on, is refused with the same words as any other recipient: `MESSAGES_OFF` in a tab with it off,
- `UNKNOWN_RECIPIENT` ("No teammate named …") otherwise.
+ no shared tab, is refused with the same words as any other recipient: `MESSAGES_OFF` while Agent Messages are off
+ on the computer, `NO_TEAMMATES` for a harness alone in its tab or in none, `UNKNOWN_RECIPIENT` ("No teammate named
+ …") otherwise.
- A message an older version queued under `started` is never delivered: it is failed and its inbox file withdrawn
as the service starts, before the directory is read (the hook takes what waits in an inbox without asking, and a
- directory that cannot be read would have left it there), even between two that now share a tab with it on.
+ directory that cannot be read would have left it there), even between two that now share a tab.
- The record (`agent-client/started.jsonl`) stays: `ps`, the limits, the depth and `close` read it.
-- For a follow-up to a harness it started, an agent starts it with everything in the task, or, where Agent Messages
- are on in its tab, sends.
+- For a follow-up to a harness it started, an agent starts it with everything in the task, or, where the two share
+ a tab and Agent Messages are on, sends.
### Verified
diff --git a/docs/naming-system.md b/docs/naming-system.md
index ef57ff37d..5c63f6ad4 100644
--- a/docs/naming-system.md
+++ b/docs/naming-system.md
@@ -73,9 +73,9 @@ existing action name.
A pane is a view, so closing a pane or tab closes views. **Stop Harness** ends the
running harness. Adding harnesses to a tab groups them without a separate team
-setup. Turning on **Agent Messages** for a tab lets its harnesses message each
-other (`harness send`); it is off by default, per tab, and **Show Agent Messages**
-opens the tab's log. The word *tab* can also name the keyboard key or a
+setup. **Agent Messages** lets the harnesses in a tab message each other
+(`harness send`); it is one setting per computer, in Settings ▸ Agents, on by
+default, and **Show Agent Messages** opens a tab's log. The word *tab* can also name the keyboard key or a
browser tab; context distinguishes them.
A project belongs to a computer; identical paths on different computers do not
diff --git a/plugins/harness/skills/harness/SKILL.md b/plugins/harness/skills/harness/SKILL.md
index 0f0330ebc..017742575 100644
--- a/plugins/harness/skills/harness/SKILL.md
+++ b/plugins/harness/skills/harness/SKILL.md
@@ -7,7 +7,8 @@ description: Harness runs coding agents (Claude Code, Codex and others) as harne
Harness runs coding agents in sessions of their own, called harnesses, and shows each one to the person in its
desktop, web and phone apps. With the `harness` command (or Harness's MCP tools) you can start harnesses, read
-them, wait for them and close them, and message teammates in a tab where the person turned Agent Messages on.
+them, wait for them and close them, and message your teammates: the harnesses in your tab, while Agent Messages are
+on (Settings ▸ Agents, on by default).
## Is it here?
@@ -51,12 +52,12 @@ the person can watch and step in.
1. List first: `harness ps`. It shows the harnesses here: state, who started each (`you` for yours), and what each
is about.
-2. You may give work only to a harness **you started**, or to a teammate in a tab with Agent Messages on
+2. You may give work only to a harness **you started**, or to a teammate in your tab while Agent Messages are on
(`harness send` alone lists them). Never give work to, or close, a harness you did not start: those are the
person's. You may `show` and `wait` on them.
3. Put everything in the task when you start a harness: starting it does not let you message it. A follow-up
- for the same work goes to it with `harness send` only if it is your teammate in a tab where the person turned
- Agent Messages on (the tab's chat icon); otherwise start a new harness with the fuller task. Start a new one
+ for the same work goes to it with `harness send` only if it is your teammate in your tab while Agent Messages are
+ on (Settings ▸ Agents, on by default); otherwise start a new harness with the fuller task. Start a new one
too for unrelated work, for work to run in parallel, or for another agent or machine.
## The verbs
@@ -66,7 +67,7 @@ harness ps [--all] # the harnesses here
harness new [agent] [@machine] [folder | project] --name <name> -- <task>
harness wait <name>[,<name>…] [--any] [--timeout 30m]
harness show <name> [--chars N] # its state, the last ask and its answer
-harness send <name> "text" # a teammate in this tab, when Agent Messages are on there
+harness send <name> "text" # a teammate in this tab, while Agent Messages are on
harness close <name> [--now] # when you are done with one you started
```
@@ -90,9 +91,10 @@ harness close <name> [--now] # when you are done with one
## Inside a harness, or outside
-- **In a harness** (Harness made your terminal pane): `harness send` works only to teammates in a tab where the
- person turned Agent Messages on. A harness you started, or the one that started you, is no exception: with
- Agent Messages off, put everything in the task and read the answer with `show`.
+- **In a harness** (Harness made your terminal pane): `harness send` works only to teammates in your tab, while
+ Agent Messages are on (Settings ▸ Agents, on by default). A harness you started, or the one that started you, is
+ no exception: outside your tab, or with Agent Messages off, put everything in the task and read the answer with
+ `show`.
- **Outside Harness** (Claude Code or Codex in a terminal app, an editor or the person's own tmux): Harness tells
you by your session. `harness ps` says "You are Claude Code, outside Harness." and marks what this session
started as `you`; the limits below apply; and you may close only what this session started. Nothing can
diff --git a/website/public/agents/index.html b/website/public/agents/index.html
index d0db9a39f..600668ec4 100644
--- a/website/public/agents/index.html
+++ b/website/public/agents/index.html
@@ -130,9 +130,9 @@ curl -fsSL https://raw.githubusercontent.com/autonomous-ai/openharness/main/plug
takes.</td></tr>
<tr><td><code>harness show NAME [--chars N]</code></td><td>Its state, the last thing it was asked, and its answer:
the text after its last tool call, the first 4,000 characters by default.</td></tr>
- <tr><td><code>harness send NAME "text"</code></td><td>A message to a teammate in your tab, only when the person
- has turned Agent Messages on there (the tab's chat icon). A harness you started is no exception. Works from
- inside a harness.</td></tr>
+ <tr><td><code>harness send NAME "text"</code></td><td>A message to a teammate in your tab, while Agent Messages
+ are on (Settings ▸ Agents, on by default). A harness you started is no exception. Works from inside a
+ harness.</td></tr>
<tr><td><code>harness close NAME [--now]</code></td><td>Save its screen and stop it. Its conversation is kept, and
the person can resume it. Refused while it is working, unless <code>--now</code>.</td></tr>
</tbody>
@@ -200,7 +200,7 @@ harness close reviewer</code></pre>
harness ps # is it still working?
harness wait reviewer &amp;&amp; harness show reviewer</code></pre>
<p>Starting a harness does not let you message it, so put everything in the task. For a follow-up, start a new
- harness with the fuller task. Only where the person has turned Agent Messages on in the tab you share can you
+ harness with the fuller task. Only in a tab you share, while Agent Messages are on, can you
ask it from inside a harness, with <code>harness send reviewer "…"</code>, then wait and show again.</p>
<h2 id="machines">Run on another machine</h2>
@@ -212,8 +212,8 @@ harness new codex @mini ~/code/app --name train -- "Run the training script and
<h2 id="where">Inside a harness, or outside Harness</h2>
<ul>
<li><strong>In a harness</strong> (Harness made your terminal pane): <code>harness send</code> works only to
- teammates in a tab where the person turned Agent Messages on. A harness you started, or the one that started
- you, is no exception.</li>
+ teammates in your tab, while Agent Messages are on (Settings ▸ Agents, on by default). A harness you started,
+ or the one that started you, is no exception.</li>
<li><strong>Outside Harness</strong> (Claude Code or Codex in a terminal app, an editor or the person's own tmux):
Harness tells you by your session, from what your agent sets in its shell. <code>harness ps</code> says
"You are Claude Code, outside Harness." and marks what this session started as <code>you</code>; the limits
@@ -241,7 +241,7 @@ harness new codex @mini ~/code/app --name train -- "Run the training script and
<tr><td><code>harness_read</code></td><td><code>name</code>, <code>chars?</code></td><td><code>harness show</code></td></tr>
<tr><td><code>harness_close</code></td><td><code>name</code>, <code>now?</code></td><td><code>harness close</code></td></tr>
<tr><td><code>harness_send</code></td><td><code>to</code>, <code>text</code>; offered only when the server runs
- inside a harness, and only to teammates in a tab with Agent Messages on</td><td><code>harness send</code></td></tr>
+ inside a harness, and only to teammates in its tab while Agent Messages are on</td><td><code>harness send</code></td></tr>
</tbody>
</table>
</div>
diff --git a/website/public/llms.txt b/website/public/llms.txt
index 06f87ace6..261c0bf9e 100644
--- a/website/public/llms.txt
+++ b/website/public/llms.txt
@@ -18,13 +18,13 @@ harness ps [--all] # the harnesses here: state,
harness new [agent] [@machine] [folder | project] --name NAME -- TASK
harness wait NAME[,NAME…] [--any] [--timeout 30m] # exits 0 idle, 3 needs the person, 4 stopped or gone, 124 timed out
harness show NAME [--chars N] # its state, the last ask and its answer
-harness send NAME "text" # a teammate in this tab, only when Agent Messages are on there
+harness send NAME "text" # a teammate in this tab, while Agent Messages are on
harness close NAME [--now] # save its screen and stop it; the conversation is kept
```
Once Harness runs on a computer, Claude Code and Codex there run these commands and Harness's MCP tools without asking: Harness adds them to their permission rules, and Codex runs them outside its sandbox. Run each `harness` command by itself or join them with `&&`; piped or joined with other commands, the rule no longer matches. Where Harness has not set an agent up, run `harness` outside its sandbox, which cannot reach Harness's local daemon.
-`harness mcp` serves the same as MCP tools over stdio (command `harness`, arguments `["mcp"]`): `harness_list`, `harness_start`, `harness_wait`, `harness_read`, `harness_close`, and `harness_send` inside a harness (teammates in a tab with Agent Messages on only). For clients that start servers with npx, `npx -y @autonomous-ai/harness-mcp` runs `harness mcp`, or, where Harness is not installed, offers one tool, `harness_setup`, that says how to install it.
+`harness mcp` serves the same as MCP tools over stdio (command `harness`, arguments `["mcp"]`): `harness_list`, `harness_start`, `harness_wait`, `harness_read`, `harness_close`, and `harness_send` inside a harness (teammates in its tab only, while Agent Messages are on: Settings ▸ Agents, on by default). For clients that start servers with npx, `npx -y @autonomous-ai/harness-mcp` runs `harness mcp`, or, where Harness is not installed, offers one tool, `harness_setup`, that says how to install it.
Every harness spends the person's tokens. Start one only for work that can run in parallel with yours, needs another model's view (a review, a second opinion from Codex), takes long, or belongs in its own folder; do quick work yourself. For scratch or new work, give a project name (`harness new codex review -- …`) rather than a folder of your own: Claude Code and Codex ask the person to trust a folder Harness did not make. List first, name every harness, then wait, read it, and close it once you have its answer. An agent may have at most 4 live harnesses it started, and a harness another agent started may not start harnesses itself. Harness cleans up after agents: closing a harness closes the harnesses it started, and one another agent started is closed once it has sat idle 30 minutes after its last answer, unless the person typed into it; its conversation is kept. Give work only to harnesses you started, and close only those; starting one does not let you message it, so put everything in the task; never answer a harness's question or permission prompt, and never ask one to publish, deploy, delete or push. An agent outside Harness (Claude Code or Codex in a terminal app or editor) is recognized by its session: it gets the same limits, may close only what its session started, and cannot be messaged.