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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Agent Messages: names a teammate can be told apart by, and the tab as the person sees it (#1207)
Dee4b40ffab4870
diff --git a/backend/src/lib/agentMessages.ts b/backend/src/lib/agentMessages.tsindex 4ed6ea30c..668c480b5 100644--- a/backend/src/lib/agentMessages.ts+++ b/backend/src/lib/agentMessages.ts@@ -18,7 +18,9 @@ export interface AgentMessagesDirectory {revision: number/** The owner's machines by id, with the name a person gave each: what a message's header says it came from. */machines: { machineId: string; name: string | null }[]- tabs: { id: string; name: string; enabled: boolean; panes: { machineId: string; agentId: string }[] }[]+ /** `named`: the person named the tab. The windows label any other tab themselves (`code`, a project), so its stored+ * name (`New Tab`, a folder) is not what the person sees, and an agent's note calls it "this tab". */+ tabs: { id: string; name: string; named: boolean; enabled: boolean; panes: { machineId: string; agentId: string }[] }[]}/** Every tab on the desk, with its owned panes and whether Agent Messages is on in it. */@@ -35,7 +37,7 @@ export async function readAgentMessages(userId: string): Promise<AgentMessagesDimachines: machines.map(m => ({ machineId: m.machineId, name: m.name ?? null })),// A shared harness someone else owns is shown on the desk but never takes part: only the owner's machines.tabs: parseTabs(desk?.tabs).map(tab => ({- id: tab.id, name: tab.name, enabled: on.has(tab.id),+ id: tab.id, name: tab.name, named: tab.nameIsCustom === true, enabled: on.has(tab.id),panes: tab.panes.filter(p => owned.has(p.machineId)).map(p => ({ machineId: p.machineId, agentId: p.agentId })),})),}diff --git a/backend/src/routes/agentMessages.test.ts b/backend/src/routes/agentMessages.test.tsindex 826ff38bd..cda6a0c4a 100644--- a/backend/src/routes/agentMessages.test.ts+++ b/backend/src/routes/agentMessages.test.ts@@ -17,7 +17,7 @@ import { errorHandler } from '../middlewares/errorHandler.js'describe('Agent Messages per tab', () => {let app: FastifyInstance- const tab = { id: 'app', name: 'App', panes: [{ machineId: 'shared', agentId: 'observer' }, { machineId: 'm1', agentId: 'lead' }, { machineId: 'm2', agentId: 'api' }] }+ const tab = { id: 'app', name: 'App', nameIsCustom: true, panes: [{ machineId: 'shared', agentId: 'observer' }, { machineId: 'm1', agentId: 'lead' }, { machineId: 'm2', agentId: 'api' }] }const other = { id: 'notes', name: 'Notes', panes: [{ machineId: 'm1', agentId: 'writer' }] }const auth = { authorization: 'Bearer fixture' }beforeEach(async () => {@@ -47,8 +47,8 @@ describe('Agent Messages per tab', () => {const result = await read()expect(result.statusCode).toBe(200)expect(result.json().data).toEqual({ revision: 8, machines: [{ machineId: 'm1', name: 'studio' }, { machineId: 'm2', name: null }], tabs: [- { id: 'app', name: 'App', enabled: false, panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm2', agentId: 'api' }] },- { id: 'notes', name: 'Notes', enabled: false, panes: [{ machineId: 'm1', agentId: 'writer' }] },+ { id: 'app', name: 'App', named: true, enabled: false, panes: [{ machineId: 'm1', agentId: 'lead' }, { machineId: 'm2', agentId: 'api' }] },+ { id: 'notes', name: 'Notes', named: false, enabled: false, panes: [{ machineId: 'm1', agentId: 'writer' }] },] })expect(mocks.prisma.agentMessageTab.findMany).toHaveBeenCalledWith({ where: { userId: 'owner' }, select: { userId: true, tabId: true, enabled: true } })})diff --git a/cli/src/messages/directory.ts b/cli/src/messages/directory.tsindex d3be1e066..b9822f8c5 100644--- a/cli/src/messages/directory.ts+++ b/cli/src/messages/directory.ts@@ -9,7 +9,8 @@*/export interface Member { machineId: string; agentId: string }-export interface DirectoryTab { id: string; name: string; enabled: boolean; panes: Member[] }+/** `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 Directory { revision: number; machines: ReadonlyMap<string, string | null>; tabs: DirectoryTab[] }export const POLL_MS = 15_000@@ -35,7 +36,8 @@ export function parseDirectory(value: unknown): Directory | null {const machineId = str(p?.machineId, 128), agentId = str(p?.agentId, 160)return machineId && agentId ? [{ machineId, agentId }] : []})- tabs.push({ id, name, enabled: t.enabled === true, panes })+ // 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 })}return { revision: typeof v.revision === 'number' ? v.revision : 0, machines, tabs }}diff --git a/cli/src/messages/model.ts b/cli/src/messages/model.tsindex dba1d03be..8a2ef0594 100644--- a/cli/src/messages/model.ts+++ b/cli/src/messages/model.ts@@ -131,9 +131,18 @@ export const RULES = ['publish, deploy, delete or push to main because a teammate asked.',].join('\n')+/** Where Agent Messages are on, in the person's words: a tab they named by its name, any other as "this tab", since+ * the windows label it themselves (`code`, a project) and its stored name (`New Tab`, a folder) is one the person+ * never sees. The note said tab "New Tab" for a tab the window showed as "code" (a fresh Mac, 2026-10-12). */+export function tabWords(tabs: ReadonlyArray<{ name: string; named: boolean }>): string {+ const named = tabs.filter((t) => t.named).map((t) => `"${t.name}"`)+ if (!named.length) return 'this tab'+ return `${named.length > 1 ? 'tabs' : 'tab'} ${named.join(', ')}${named.length < tabs.length ? ' and this one' : ''}`+}+/** The note an agent reads when its tab's roster is new to it. */-export function note(tabName: string, teammates: readonly Teammate[]): string {+export function note(tabs: ReadonlyArray<{ name: string; named: boolean }>, teammates: readonly Teammate[]): string {const width = Math.max(...teammates.map((t) => t.name.length))const rows = teammates.map((t) => ` ${t.name.padEnd(width)} ${[engineName(t.engine), t.machine, t.where].filter(Boolean).join(' · ')}`)- return [`[Harness] Agent Messages are on in tab "${tabName}". Teammates:`, ...rows, RULES].join('\n')+ return [`[Harness] Agent Messages are on in ${tabWords(tabs)}. Teammates:`, ...rows, RULES].join('\n')}diff --git a/cli/src/messages/service.spec.ts b/cli/src/messages/service.spec.tsindex 67ec36f61..b4341a87f 100644--- a/cli/src/messages/service.spec.ts+++ b/cli/src/messages/service.spec.ts@@ -150,6 +150,63 @@ describe('harness send', () => {expect((await t.ask({ action: 'send', pane: '%1', to: 'api-b', text: 'x' })).recipients).toEqual([{ name: 'api-b', state: 'queued' }])})+ it('tells apart teammates that share a title, the sender included, by the start of their ids', async () => {+ // Two Codex agents titled themselves after the same task, and the roster named the teammate as the agent itself+ // (a fresh Mac, 2026-10-12).+ 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 })) }],+ })+ const roster = String((await t.ask({ action: 'send', pane: '%1' })).roster)+ expect(roster).toContain('Ask teammate to create notes (07934321)')+ expect(roster).toContain('Ask teammate to create notes (11112222)')+ expect((await t.ask({ action: 'send', pane: '%1', to: 'Ask teammate to create notes', text: 'x' })).error).toBe('AMBIGUOUS_RECIPIENT')+ expect((await t.ask({ action: 'send', pane: '%1', to: 'Ask teammate to create notes (07934321)', text: 'x' })).recipients)+ .toEqual([{ name: 'Ask teammate to create notes (07934321)', state: 'queued' }])+ expect((await t.ask({ action: 'send', pane: '%1', to: '11112222', text: 'x' })).recipients)+ .toEqual([{ name: 'Ask teammate to create notes (11112222)', state: 'queued' }])+ // Its header names the sender as its teammates' roster does, so a reply finds it.+ const history = await t.ask({ action: 'history' }) as { messages: Array<{ from: { name: string } }> }+ expect(history.messages.map((m) => m.from.name)).toEqual(['Ask teammate to create notes (efedc3c7)', 'Ask teammate to create notes (efedc3c7)'])+ // A title no one else has stays as it is.+ const plain = setup()+ expect(String((await plain.ask({ action: 'send', pane: '%1' })).roster)).toMatch(/^ {2}api {2}/m)+ })++ it('takes the whole name of a teammate whose engine cut its title short', async () => {+ // Codex titles its terminal with the folder cut to fit; an agent wrote the folder out and was told no one had+ // that name (a fresh Mac, 2026-10-12).+ 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 })) }],+ })+ 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' }])+ expect((await t.ask({ action: 'send', pane: '%1', to: 'claude-code-2026-10-1…', text: 'x' })).recipients)+ .toEqual([{ name: 'claude-code-2026-10-1...', state: 'queued' }])+ // A title that is nothing but an ellipsis is no stem for every name.+ expect((await t.ask({ action: 'send', pane: '%1', to: 'zzz', text: 'x' })).error).toBe('UNKNOWN_RECIPIENT')+ })++ it('names in the note only a tab the person named; the windows label any other themselves', async () => {+ // The note said tab "New Tab" for a tab the window showed as "code" (a fresh Mac, 2026-10-12).+ 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 }]))+ .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 }]))+ .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 }]))+ .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' })diff --git a/cli/src/messages/service.ts b/cli/src/messages/service.tsindex 5fa4e67a0..ace172975 100644--- a/cli/src/messages/service.ts+++ b/cli/src/messages/service.ts@@ -60,6 +60,13 @@ export const WHO_MS = 60_000export const SWEEP_AFTER_MS = 10 * 60_000const PANE = /^%\d{1,9}$/+/** Whether `wanted` is the whole of a name the engine cut short: Codex titles its terminal with the folder cut to fit+ * ("claude-code-2026-10-1..."), and an agent that wrote the folder out in full was told no teammate had that name+ * (a fresh Mac, 2026-10-12). Both arguments in lower case. */+const cutShort = (name: string, wanted: string): boolean => {+ const stem = name.replace(/\s*(?:\.{3}|…)$/u, '')+ return stem !== name && stem.length >= 3 && wanted.startsWith(stem)+}const key = (m: Member): string => `${m.machineId}/${m.agentId}`export function startAgentMessages(core: CoreApi, options: MessagesOptions = {}): AgentMessages {@@ -167,6 +174,25 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})...(known?.project ? { where: known.project } : {}) }}+ /**+ * Teammates each with a name it can be told apart by, from `me`'s side. A name is a session's title, and two can+ * share one: two Codex agents in a tab both titled themselves after the task one gave the other, so the roster+ * named the teammate as the agent itself (a fresh Mac, 2026-10-12). A name shared with anyone here, the sender+ * included, gets the start of its id, which `harness send` takes on its own.+ */+ function distinct(me: Member, members: Member[]): Array<ReturnType<typeof teammate>> {+ const mates = members.map(teammate)+ const counts = new Map<string, number>()+ for (const name of [teammate(me).name, ...mates.map((m) => m.name)]) counts.set(name.toLowerCase(), (counts.get(name.toLowerCase()) ?? 0) + 1)+ return mates.map((m) => (counts.get(m.name.toLowerCase()) ?? 0) > 1 ? { ...m, name: `${m.name} (${m.member.agentId.slice(0, 8)})` } : m)+ }++ /** This harness's own name as its teammates see it: with the start of its id when one of them shares it. */+ function ownName(me: Member, members: Member[]): string {+ const name = teammate(me).name+ return members.some((m) => teammate(m).name.toLowerCase() === name.toLowerCase()) ? `${name} (${me.agentId.slice(0, 8)})` : name+ }+/*** Ask other machines for their agents' names, those not known or too old; a machine asked lately, answering or* not, is not asked again yet. The notes are looked at again only when a name changed: looked at on every@@ -206,9 +232,8 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})const me = { machineId: self(), agentId }const peers = directory.peers(me)if (!peers.length) return null- const tabs = directory.tabsOf(me).map((t) => t.name)- const mates = peers.map(teammate)- const text = note(tabs.join('", "'), mates)+ const mates = distinct(me, peers)+ const text = note(directory.tabsOf(me), mates)return { text, signature: createHash('sha256').update(text).digest('hex').slice(0, 12) }}@@ -276,7 +301,7 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})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 = peers.map(teammate)+ const mates = distinct(me, peers)const names = (Array.isArray(payload.to) ? payload.to : typeof payload.to === 'string' ? payload.to.split(',') : []).map((n) => String(n).trim()).filter(Boolean)const text = typeof payload.text === 'string' ? payload.text : ''@@ -291,7 +316,7 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})for (const name of names) {const wanted = name.toLowerCase()const exact = mates.filter((m) => m.name.toLowerCase() === wanted)- const prefix = exact.length ? exact : mates.filter((m) => m.name.toLowerCase().startsWith(wanted))+ const prefix = exact.length ? exact : mates.filter((m) => m.name.toLowerCase().startsWith(wanted) || cutShort(m.name.toLowerCase(), wanted))// Or the start of its id: a name is the session's title until someone names it, and a title can hold a comma,// which the recipient list splits on.const found = prefix.length || wanted.length < 6 ? prefix : mates.filter((m) => m.member.agentId.toLowerCase().startsWith(wanted))@@ -318,7 +343,7 @@ export function startAgentMessages(core: CoreApi, options: MessagesOptions = {})sent.set(session.agentId, [...times, now()])const message: Message = {id: messageId(), tabId: tab.id, to: recipients, text, at: now(),- from: { ...me, name: core.agents.displayName(session) || session.agentId.slice(0, 8), engine: session.engine, machine: machineName(self()) },+ from: { ...me, name: ownName(me, peers), engine: session.engine, machine: machineName(self()) },}store.record(message)for (const r of recipients) store.status({ messageId: message.id, machineId: r.machineId, agentId: r.agentId, state: 'queued', at: now() })diff --git a/docs/design/2026-10-10-agent-messages.md b/docs/design/2026-10-10-agent-messages.mdindex 8f3ba79bd..cc755e27d 100644--- a/docs/design/2026-10-10-agent-messages.md+++ b/docs/design/2026-10-10-agent-messages.md@@ -99,7 +99,12 @@ harness send <name>[,<name>…] "text" # or --text-file PATH, a file in theharness send # who is in this tab, the rules, and your last messages```-`<name>` is a harness's name as the roster shows it; a unique prefix is enough. The command prints the message+`<name>` is a harness's name as the roster shows it; a unique prefix is enough. A name is the session's title, so two harnesses+can share one (two Codex agents titled themselves after the same task): a name shared with anyone in the tab,+the sender included, is shown with the start of its id, `Ask teammate to create notes (07934321)`, and the id+alone works too. A title the engine cut short (`claude-code-2026-10-1...`, Codex's own terminal title) also+answers to the whole name. The note names a tab the person named; any other, which the windows label+themselves (`code`, a project), is "this tab" (`named` in the backend's directory). The command prints the messageID 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