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.

Super Tab: the Lead answers each message once, briefly (#1452)

0xken1515ae3a4d43d7
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.ts
index 1848ddbaf..c0adc1d65 100644
--- a/backend/integration/superTabs.test.ts
+++ b/backend/integration/superTabs.test.ts
@@ -368,6 +368,35 @@ describe('Super Tabs on a real Mongo replica set', () => {
await expect(store.read({ ...owner, autonomousEnv: 'stag' }, tab)).rejects.toMatchObject({ code: 'NOT_FOUND' })
})
+ it('closes the replying agent\'s own deliveries of a message as answered, and nobody else\'s', async () => {
+ const { tab, lead } = await fixture()
+ const helper = (await run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'test-host', harnessId: randomUUID(),
+ name: 'Helper', configuration: config, lead: false })).result.agentId as string
+ await invite(tab)
+ const asked = await run(tab, { type: 'message.send', conversationId: 'lead', text: 'What is the status?', replyTo: null,
+ recipientIds: [lead, helper] }, peer)
+ const messageId = asked.result.messageId as string
+ const held = (await store.deliveries(host, tab, lead))[0]!
+ const claimId = randomUUID()
+ // A claimed delivery closes too, not only a queued one.
+ await store.delivery(host, tab, lead, held.id, { type: 'claim', claimId })
+ const other = (await store.deliveries(host, tab, helper))[0]!
+ // A person's reply closes nothing.
+ await run(tab, { type: 'message.send', conversationId: 'lead', text: 'Also, soon please.', replyTo: messageId, recipientIds: [] })
+ expect(await store.deliveryReceipt(host, tab, lead, held.id)).toEqual({ id: held.id, status: 'claimed' })
+ await run(tab, { type: 'message.send', conversationId: 'lead', text: 'It is done.', replyTo: messageId, recipientIds: [] }, host, lead)
+ expect(await store.deliveryReceipt(host, tab, lead, held.id)).toEqual({ id: held.id, status: 'answered' })
+ expect((await store.deliveries(host, tab, lead)).map(d => d.messageId)).not.toContain(messageId)
+ expect(await store.deliveryReceipt(host, tab, helper, other.id)).toEqual({ id: other.id, status: 'queued' })
+ await expect(store.delivery(host, tab, lead, held.id, { type: 'claim', claimId })).rejects.toMatchObject({ code: 'DELIVERY_RESOLVED' })
+ await expect(store.delivery(host, tab, lead, held.id, { type: 'ack', claimId, receipt: 'late', uncertain: false }))
+ .rejects.toMatchObject({ code: 'DELIVERY_RESOLVED' })
+ const next = await run(tab, { type: 'message.send', conversationId: 'lead', text: 'And the tests?', replyTo: null, recipientIds: [lead] }, peer)
+ const queued = (await store.deliveries(host, tab, lead)).find(d => d.messageId === next.result.messageId)!
+ await run(tab, { type: 'message.send', conversationId: 'lead', text: 'They pass.', replyTo: next.result.messageId as string, recipientIds: [] }, host, lead)
+ expect(await store.deliveryReceipt(host, tab, lead, queued.id)).toEqual({ id: queued.id, status: 'answered' })
+ })
+
it('durably resumes a claim, never steals it on timeout, and does not resurrect revoked messages on rejoin', async () => {
const { tab, lead } = await fixture()
await invite(tab)
diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.ts
index 0f3daa259..76af85d4e 100644
--- a/backend/src/superTabs/store.ts
+++ b/backend/src/superTabs/store.ts
@@ -308,6 +308,12 @@ export class SuperTabStore {
await closeAssignment(tx, tabId, command.assignmentId, command.status, context.now)
}
await this.writeMessages(tx, tabId, effects.state, effects.messages, revision)
+ // On 2026-10-20 a Lead answered a message it had already read, then answered it again when the held
+ // delivery was finally typed. An agent's reply settles that agent's own deliveries of the message.
+ if (command.type === 'message.send' && command.replyTo && actor.kind === 'agent') {
+ await tx.superTabDelivery.updateMany({ where: { tabId, messageId: command.replyTo, agentId: actor.agentId,
+ status: { in: ['queued', 'claimed', 'uncertain'] } }, data: { status: 'answered' } })
+ }
const revoked = [
...original.people.filter(p => !effects.state.people.some(n => n.id === p.id && n.generation === p.generation))
.map(p => ({ authorKind: 'person', authorId: p.id, authorGeneration: p.generation })),
@@ -567,6 +573,7 @@ export class SuperTabStore {
const delivery = await tx.superTabDelivery.findFirst({ where: { id: deliveryId, tabId, agentId } })
if (!delivery || !this.deliveryAllowed(state, delivery) || delivery.status === 'cancelled' ||
!await this.senderAllowed(tx, state, delivery)) fail('DELIVERY_REVOKED', 'This instruction is no longer authorized.', 403)
+ if (delivery.status === 'answered') fail('DELIVERY_RESOLVED', 'This message was already answered.')
if (delivery.status === 'confirmed' || delivery.status === 'superseded') {
fail('DELIVERY_RESOLVED', 'A person has already resolved this delivery.')
}
diff --git a/cli/src/superTabs/command.spec.ts b/cli/src/superTabs/command.spec.ts
index 502425750..5f2ca64e3 100644
--- a/cli/src/superTabs/command.spec.ts
+++ b/cli/src/superTabs/command.spec.ts
@@ -58,3 +58,11 @@ it('routes through the caller and prints the decision, or the parse failure as a
expect(await superTabCommand(['--tab', 'tab', 'route', 'g1', '{nope'], deps)).toBe(1)
expect(JSON.parse(print.mock.calls.at(-1)![0]).error).toMatch(/JSON/)
})
+it('posts a reply to one message with --reply-to, and rejects a bad id', () => {
+ expect(parseSuperTabArgs([...prefix, 'post', 'lead', 'Ready', 'op-1', '--reply-to', 'msg-1'], where).payload.command)
+ .toMatchObject({ type: 'message.send', conversationId: 'lead', text: 'Ready', replyTo: 'msg-1' })
+ expect(parseSuperTabArgs([...prefix, 'post', 'lead', 'Ready', 'op-1'], where).payload.command).toMatchObject({ replyTo: null })
+ for (const tail of [['--reply-to'], ['--reply-to', '../x'], ['--reply-to', ''], ['--reply-to', 'a', 'b'], ['--reply', 'a']]) {
+ expect(() => parseSuperTabArgs([...prefix, 'post', 'lead', 'Ready', 'op-1', ...tail], where)).toThrow('harness super-tab')
+ }
+})
diff --git a/cli/src/superTabs/command.ts b/cli/src/superTabs/command.ts
index 556b6f41f..7af6e3aa4 100644
--- a/cli/src/superTabs/command.ts
+++ b/cli/src/superTabs/command.ts
@@ -5,7 +5,7 @@ import { openDaemon, whereFor, type Daemon, type Where } from '../agentClient/da
import { callerOf, type Frame } from '../agentClient/model.js'
import { identifier } from './host.js'
-const USAGE = 'harness super-tab --tab ID [--agent ID] [--port N --machine ID] status | messages GROUP | message GROUP MESSAGE_ID | post GROUP TEXT OPERATION_ID | command OPERATION_ID JSON | start OPERATION_ID JSON | resume START_ID | capacity MACHINE_ID JSON | route GROUP JSON | help'
+const USAGE = 'harness super-tab --tab ID [--agent ID] [--port N --machine ID] status | messages GROUP | message GROUP MESSAGE_ID | post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] | command OPERATION_ID JSON | start OPERATION_ID JSON | resume START_ID | capacity MACHINE_ID JSON | route GROUP JSON | help'
export function parseSuperTabArgs(argv: readonly string[], where: Where) {
const positional: string[] = []
let tabId = '', agentId = ''
@@ -26,9 +26,10 @@ export function parseSuperTabArgs(argv: readonly string[], where: Where) {
else if (action === 'message' && identifier(first) && identifier(second) && positional.length === 3) {
Object.assign(payload, { conversationId: first, messageId: second })
}
- else if (action === 'post' && identifier(first) && second?.trim() && identifier(third) && positional.length === 4) {
+ else if (action === 'post' && identifier(first) && second?.trim() && identifier(third)
+ && (positional.length === 4 || (positional.length === 6 && positional[4] === '--reply-to' && identifier(positional[5])))) {
Object.assign(payload, { action: 'command', operationId: third,
- command: { type: 'message.send', conversationId: first, text: second, replyTo: null, recipientIds: [] } })
+ command: { type: 'message.send', conversationId: first, text: second, replyTo: positional[5] ?? null, recipientIds: [] } })
} else if (action === 'command' && identifier(first) && second && positional.length === 3) {
Object.assign(payload, { operationId: first, command: JSON.parse(second) })
} else if (action === 'start' && identifier(first) && second && positional.length === 3) {
diff --git a/cli/src/superTabs/host.spec.ts b/cli/src/superTabs/host.spec.ts
index 0e5069162..6e25737ca 100644
--- a/cli/src/superTabs/host.spec.ts
+++ b/cli/src/superTabs/host.spec.ts
@@ -113,6 +113,78 @@ describe('Super Tab native delivery handoff', () => {
expect(t.saved().entries).toEqual({})
expect(t.core.turns.deliver).toHaveBeenCalledTimes(1)
})
+ it('never types a held delivery that was answered meanwhile, and retires its journal entry', async () => {
+ const t = setup(), host = t.open()
+ await host.tick(); t.event('rejected', 'team_waiting_busy')
+ expect(t.saved().entries.delivery.stage).toBe('prepared')
+ // The Lead read the question during its turn and replied; the backend now lists nothing and says answered.
+ const original = vi.mocked(t.core.account.backend).getMockImplementation()!
+ vi.mocked(t.core.account.backend).mockImplementation(async (method, path, body) => {
+ if (path.endsWith('/deliveries/delivery')) return { status: 200, body: { success: true, data: { id: 'delivery', status: 'answered' } } }
+ if (path.endsWith('/deliveries')) return { status: 200, body: { success: true, data: [] } }
+ return original(method, path, body)
+ })
+ await host.tick(); await host.reconcileReceipts()
+ expect(t.core.turns.deliver).toHaveBeenCalledTimes(1)
+ expect(t.saved().entries).toEqual({})
+ })
+ it('drops the lease of a held delivery answered while its lease was being granted', async () => {
+ const t = setup(), host = t.open()
+ await host.tick(); t.event('rejected', 'team_waiting_busy')
+ const original = vi.mocked(t.core.account.backend).getMockImplementation()!
+ vi.mocked(t.core.account.backend).mockImplementation(async (method, path, body) => {
+ if (method === 'GET' && path.endsWith('/deliveries/delivery')) return { status: 200, body: { success: true, data: { id: 'delivery', status: 'answered' } } }
+ return original(method, path, body)
+ })
+ vi.mocked(t.core.turns.leaseDeliveries).mockImplementationOnce(async () => { await host.reconcileReceipts(); return true })
+ await host.tick()
+ expect(t.core.turns.deliver).toHaveBeenCalledTimes(1)
+ expect(t.saved().entries).toEqual({})
+ // A kept lease id would count toward the core's limit until the host restarts.
+ expect(vi.mocked(t.core.turns.leaseDeliveries).mock.lastCall?.[1]).toEqual({})
+ })
+ it('retires an entry quietly when its claim is refused as answered, and still delivers the next one', async () => {
+ const t = setup(), host = t.open()
+ const original = vi.mocked(t.core.account.backend).getMockImplementation()!
+ vi.mocked(t.core.account.backend).mockImplementation(async (method, path, body) => {
+ if (method === 'GET' && path.endsWith('/deliveries')) {
+ return { status: 200, body: { success: true, data: [{ id: 'delivery', claimId: null, status: 'queued' }, { id: 'second', claimId: null, status: 'queued' }] } }
+ }
+ if (method === 'POST' && path.endsWith('/deliveries/delivery')) {
+ return { status: 409, body: { success: false, error: { code: 'DELIVERY_RESOLVED', message: 'This message was already answered.' } } }
+ }
+ if (method === 'POST') return { status: 200, body: { success: true, data: { delivery: { id: 'second' }, message: { id: 'message', conversationId: 'lead', text: 'Next.', author: { name: 'Collaborator' } } } } }
+ return original(method, path, body)
+ })
+ await host.tick()
+ expect(Object.keys(t.saved().entries)).toEqual(['second'])
+ expect(t.saved().entries.second.stage).toBe('submitting')
+ expect(t.core.turns.deliver).toHaveBeenCalledTimes(1)
+ expect(t.core.turns.deliver).toHaveBeenCalledWith('harness', expect.any(String), 'team:service:superTabs:second')
+ expect(t.core.turns.cancelDelivery).not.toHaveBeenCalled()
+ })
+ it('keeps a held delivery that is still open when its receipt is checked', async () => {
+ const t = setup(), host = t.open()
+ await host.tick(); t.event('rejected', 'team_waiting_busy')
+ const original = vi.mocked(t.core.account.backend).getMockImplementation()!
+ vi.mocked(t.core.account.backend).mockImplementation(async (method, path, body) => {
+ if (path.endsWith('/deliveries/delivery') && method === 'GET') return { status: 200, body: { success: true, data: { id: 'delivery', status: 'claimed' } } }
+ return original(method, path, body)
+ })
+ await host.reconcileReceipts()
+ expect(Object.keys(t.saved().entries)).toEqual(['delivery'])
+ })
+ it('tells the agent how to reply to this exact message, in short plain words', async () => {
+ const t = setup({ author: { kind: 'person', id: 'p1', name: '[email protected]' }, text: 'How is it going?' })
+ await t.open().tick()
+ const prompt = vi.mocked(t.core.turns.deliver).mock.calls[0]![1] as string
+ expect(prompt).toContain('Message message from [email protected]:\nHow is it going?')
+ expect(prompt).toContain("post 'lead' 'your message' UNIQUE_OPERATION_ID --reply-to 'message'")
+ expect(prompt).toContain('Ask questions and post results in this conversation.')
+ expect(prompt).toContain('Answer each message once')
+ expect(prompt).not.toContain('email addresses')
+ expect(prompt).not.toContain('Report exact revisions')
+ })
it('persists before typing, keeps one native delivery during polls, and acknowledges the exact receipt', async () => {
const t = setup(), host = t.open()
vi.mocked(t.core.turns.deliver).mockImplementation(() => expect(t.saved().entries.delivery.stage).toBe('submitting'))
diff --git a/cli/src/superTabs/host.ts b/cli/src/superTabs/host.ts
index f8e1771a9..1d271f815 100644
--- a/cli/src/superTabs/host.ts
+++ b/cli/src/superTabs/host.ts
@@ -54,6 +54,15 @@ const writeJournal = (file: string, journal: Journal) => {
renameSync(temporary, file)
}
+/** The same rules the launch prompt gives (desktop/lib/super_tabs/launch.dart). On 2026-10-20 a Lead answered one
+ * question twice, once in a long technical report. */
+const SUPER_TAB_REPLY_STYLE = 'Write to the people in this tab like a helpful colleague. Answer first, in plain words and in the language they used. '
+ + 'Keep it short: a few sentences, under about 150 words, unless they ask for detail. '
+ + 'Do not show commands, message or sequence ids, field names or error codes. '
+ + 'Do not describe your own tools or permission prompts unless that blocks what they asked. '
+ + 'Answer each message once: post with --reply-to MESSAGE_ID. If you have already answered a message, do not post again. '
+ + 'When you hand over finished work, give the result with the revision and links they need.'
+
/** Owns only the handoff between a durable backend claim and the core's native input.
* A process restart never interprets a lost acknowledgement as permission to type twice. */
export class SuperTabHost {
@@ -192,14 +201,18 @@ export class SuperTabHost {
}).finally(() => { this.receiptsRunning = null; this.nextReceiptsAt = this.now() + 5_000 })
}
private async checkReceipts(): Promise<void> {
- const pending = Object.values(this.journal.entries).filter(e => e.stage === 'uncertain' || e.stage === 'delivered')
+ // A held entry (the terminal was busy) is also checked: if the agent answered the message meanwhile, it is not typed.
+ const pending = Object.values(this.journal.entries).filter(e => e.stage === 'uncertain' || e.stage === 'delivered'
+ || (e.stage === 'prepared' && !this.active.has(typedId(e))))
for (let i = 0; i < Math.min(pending.length, 20); i++) {
if (this.stopped) return
const entry = pending[(this.receiptCursor++) % pending.length]
try {
const result = object(await backend(this.core, 'GET', `/api/super-tabs/${entry.tabId}/agents/${entry.agentId}/deliveries/${entry.deliveryId}`))
if (this.stopped) return
- if (result.id !== entry.deliveryId || !['delivered', 'confirmed', 'superseded', 'cancelled'].includes(String(result.status))) continue
+ // Held input is retired only by an answer. A cancelled one leaves the roster, so the claim path never sees it again; it stays in the journal.
+ const terminal = entry.stage === 'prepared' ? ['answered'] : ['delivered', 'confirmed', 'superseded', 'cancelled', 'answered']
+ if (result.id !== entry.deliveryId || !terminal.includes(String(result.status))) continue
if (this.journal.entries[entry.deliveryId] !== entry || this.active.has(typedId(entry))) continue
delete this.journal.entries[entry.deliveryId]
this.persist()
@@ -251,7 +264,12 @@ export class SuperTabHost {
const delivery = object(item)
if (!identifier(delivery.id)) continue
seen.add(delivery.id)
- await this.accept(target, delivery, path)
+ try { await this.accept(target, delivery, path) } catch (error) {
+ // Answered (or resolved by a person) between the roster read and this call: nothing is owed, and the
+ // agent's other deliveries go on.
+ if (!(error instanceof SuperTabHostError) || error.code !== 'DELIVERY_RESOLVED') throw error
+ this.retire(delivery.id as string)
+ }
}
} catch (error) {
// Authority checks and network failures both withhold input. A later fresh read may grant it again.
@@ -274,6 +292,16 @@ export class SuperTabHost {
await this.leases()
}
+ private retire(deliveryId: string): void {
+ const entry = this.journal.entries[deliveryId]
+ if (!entry) return
+ const id = typedId(entry)
+ delete this.journal.entries[deliveryId]
+ this.authorized.delete(id)
+ if (this.active.delete(id)) this.core.turns.cancelDelivery(id)
+ this.persist()
+ }
+
private async accept(target: HostAgent, delivery: Json, path: string): Promise<void> {
const deliveryId = delivery.id as string
let entry = this.journal.entries[deliveryId]
@@ -312,12 +340,14 @@ export class SuperTabHost {
return
}
const result = object(await backend(this.core, 'POST', `${path}/${deliveryId}`, { type: 'claim', claimId: entry.claimId }))
- if (this.stopped) return
+ // The receipt check may have retired this held entry while the claim was in flight.
+ if (this.stopped || this.journal.entries[deliveryId] !== entry) return
const message = object(result.message)
if (typeof message.text !== 'string' || !identifier(message.conversationId)) throw new Error('The delivery has no message.')
this.authorized.set(id, this.now() + 2_500)
if (!(await this.leases()) || this.stopped) { this.authorized.delete(id); return }
if (this.active.has(id)) return
+ if (this.journal.entries[deliveryId] !== entry) { this.authorized.delete(id); return }
// The durable intent must exist before the core can write. A thrown disk write must not deliver.
entry.stage = 'submitting'
this.persist()
@@ -349,9 +379,9 @@ export class SuperTabHost {
: ''
return `You are participating in a shared Super Tab conversation (${group}). Other humans and agents see messages posted there.\n`
+ `Read its state: ${command} status\nRead this conversation: ${command} messages ${shellQuote(group)}\n`
- + `Reply there: ${command} post ${shellQuote(group)} 'your message' UNIQUE_OPERATION_ID\n`
+ + `Reply there: ${command} post ${shellQuote(group)} 'your message' UNIQUE_OPERATION_ID --reply-to ${shellQuote(String(message.id))}\n`
+ `Manage agreed work and delegation: ${command} help. Leads: route before starting or assigning: ${command} route GROUP JSON. Use independently verifiable outcomes; local helper subagents need no separate group.\n`
- + `Ask questions and post results in this conversation. Include the exact revision, evidence and usable output links. Replies to these delivered instructions must be posted here explicitly.\n\n`
+ + `Ask questions and post results in this conversation. ${SUPER_TAB_REPLY_STYLE} Replies to these delivered instructions must be posted here explicitly.\n\n`
+ native + reply + `Message ${String(message.id)} from ${String(object(message.author).name ?? 'a collaborator')}:\n${message.text}`
}
diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.ts
index 7946975b1..73101099e 100644
--- a/cli/src/superTabs/service.spec.ts
+++ b/cli/src/superTabs/service.spec.ts
@@ -59,7 +59,7 @@ it('resolves a native caller to its exact contribution and rechecks it before ev
expect(await t.ask({ action: 'command', tabId: 'tab', agentId: t.agentId, operationId: 'op', command }, owner)).toMatchObject({ ok: true, operationId: 'op' })
expect(t.call).toHaveBeenLastCalledWith('POST', '/api/super-tabs/tab/commands', { operationId: 'op', command, asAgentId: t.agentId })
expect(await t.ask({ action: 'message', tabId: 'tab', agentId: t.agentId, conversationId: 'lead', messageId: 'old-question' }, owner)).toMatchObject({ ok: true })
- expect(t.call).toHaveBeenLastCalledWith('GET', `/api/super-tabs/tab/conversations/lead/messages?asAgentId=${t.agentId}&messageId=old-question`, undefined)
+ expect(t.call).toHaveBeenCalledWith('GET', `/api/super-tabs/tab/conversations/lead/messages?asAgentId=${t.agentId}&messageId=old-question`, undefined)
t.agent.machineId = 'another-machine'
expect(await t.ask({ action: 'status', tabId: 'tab', agentId: t.agentId }, owner)).toMatchObject({ error: 'AGENT_UNAVAILABLE' })
t.agent.machineId = 'machine-1'; vi.mocked(t.core.agents.byAgent).mockReturnValue(undefined)
@@ -299,3 +299,54 @@ it('prepares machines only for their owner and clears setup receipts on disconne
await t.ask(request, owner)
expect(prepareContribution).toHaveBeenCalledTimes(2)
})
+
+describe('which messages still need an answer', () => {
+ const person = { kind: 'person', id: 'p1', name: '[email protected]' }
+ const rows = (agentId: string) => [
+ { id: 'm1', sequence: 1, author: person, recipientIds: [agentId], replyTo: null },
+ { id: 'm2', sequence: 2, author: person, recipientIds: [agentId], replyTo: null },
+ { id: 'm3', sequence: 3, author: person, recipientIds: ['someone-else'], replyTo: null },
+ { id: 'm4', sequence: 4, author: { kind: 'agent', id: agentId, name: 'Lead' }, recipientIds: [], replyTo: 'm1' },
+ { id: 'm5', sequence: 5, author: { kind: 'agent', id: 'someone-else', name: 'Other' }, recipientIds: [agentId], replyTo: 'm2' },
+ ]
+ it('marks messages addressed to the caller as answered or not, and leaves the rest unmarked', async () => {
+ const t = setup()
+ vi.mocked(t.core.account.backend).mockImplementation(async (_method, path) => ({ status: 200, body: { success: true,
+ data: path.includes('/messages') ? { messages: rows(t.agentId), next: null } : { state: { agents: [t.agent] } } } }))
+ const value = (await t.ask({ action: 'messages', tabId: 'tab', agentId: t.agentId, conversationId: 'lead' }, owner) as { value: { messages: Record<string, unknown>[] } }).value
+ expect(value.messages.map(m => m.answered)).toEqual([true, false, undefined, undefined, false])
+ // A person's email is passed as the backend sent it.
+ expect((value.messages[0]!.author as { name: string }).name).toBe('[email protected]')
+ })
+ it('reads the later messages of one exact message to tell whether it was answered', async () => {
+ const t = setup()
+ vi.mocked(t.core.account.backend).mockImplementation(async (_method, path) => {
+ const all = rows(t.agentId)
+ const data = path.includes('messageId=m1') ? { messages: [all[0]] } : path.includes('after=1') ? { messages: all.slice(1) } : { state: { agents: [t.agent] } }
+ return { status: 200, body: { success: true, data } }
+ })
+ const value = (await t.ask({ action: 'message', tabId: 'tab', agentId: t.agentId, conversationId: 'lead', messageId: 'm1' }, owner) as { value: { messages: Record<string, unknown>[] } }).value
+ expect(value.messages).toHaveLength(1)
+ expect(value.messages[0]!.answered).toBe(true)
+ })
+ it('skips the extra read for a message not addressed to the caller, and survives its failure', async () => {
+ const t = setup()
+ const reads: string[] = []
+ let failAfter = false
+ vi.mocked(t.core.account.backend).mockImplementation(async (_method, path) => {
+ reads.push(path)
+ const all = rows(t.agentId)
+ if (path.includes('after=') && failAfter) return { status: 500, body: { success: false, error: { code: 'DOWN', message: 'down' } } }
+ const data = path.includes('messageId=m3') ? { messages: [all[2]] } : path.includes('messageId=m1') ? { messages: [all[0]] }
+ : path.includes('after=') ? { messages: all.slice(1) } : { state: { agents: [t.agent] } }
+ return { status: 200, body: { success: true, data } }
+ })
+ const ask = (messageId: string) => t.ask({ action: 'message', tabId: 'tab', agentId: t.agentId, conversationId: 'lead', messageId }, owner) as Promise<{ ok?: boolean; value: { messages: Record<string, unknown>[] } }>
+ expect((await ask('m3')).value.messages[0]).not.toHaveProperty('answered')
+ expect(reads.some(path => path.includes('after='))).toBe(false)
+ failAfter = true
+ const failed = await ask('m1')
+ expect(failed.ok).toBe(true)
+ expect(failed.value.messages[0]).not.toHaveProperty('answered')
+ })
+})
diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.ts
index 65ce65e1c..676048555 100644
--- a/cli/src/superTabs/service.ts
+++ b/cli/src/superTabs/service.ts
@@ -14,7 +14,7 @@ const HELP = {
status: 'Read the shared tab roster and work.',
messages: 'messages GROUP: read recent messages in a conversation.',
message: 'message GROUP MESSAGE_ID: read one exact message, including an earlier question or result referenced by a reply.',
- post: 'post GROUP TEXT OPERATION_ID: reply in that conversation. Use a unique ID per message and reuse it after an interrupted request.',
+ post: 'post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID]: reply in that conversation. Use a unique ID per message and reuse it after an interrupted request. Answer a message once, with --reply-to its ID.',
start: 'start OPERATION_ID JSON: create one agent in a conversation on a machine you can access. Repeat exactly after an interruption; it follows the same native creation receipt. It does not assign work.',
resume: 'resume START_ID: finish a pending start without creating another agent.',
route: 'route GROUP JSON: before starting or assigning work, choose who does it. JSON: {"difficulty":"low|medium|high","risk":"low|medium|high","why":"one sentence","needs":{"tools":[],"devices":[],"cwd":"/absolute/repo"}}. Start or assign the pick with its routeDecisionId; to choose otherwise, pass overrideReason.',
@@ -36,6 +36,18 @@ const HELP = {
const list = (value: unknown) => Array.isArray(value) ? value.map(object) : []
+/** Tell the agent which messages sent to it it has already answered, so it posts once (a Lead answered one question twice on
+ * 2026-10-20). A message is answered when a later message of the agent's own replies to it. */
+function markAnswered(page: unknown, later: unknown[], agentId: string): unknown {
+ const body = object(page)
+ if (!Array.isArray(body.messages)) return page
+ const mine = new Set([...body.messages, ...later].map(object).filter(m => object(m.author).id === agentId && typeof m.replyTo === 'string').map(m => m.replyTo))
+ return { ...body, messages: body.messages.map(object).map(m => {
+ const asked = Array.isArray(m.recipientIds) && m.recipientIds.includes(agentId) && object(m.author).id !== agentId
+ return asked ? { ...m, answered: mine.has(m.id) } : m
+ }) }
+}
+
export interface SuperTabServiceOptions {
prepareContribution?: typeof prepareContribution
capacity?: typeof readCapabilities
@@ -177,10 +189,20 @@ export function superTabService(core: CoreApi, options: SuperTabServiceOptions =
}
}
if (payload.action === 'messages' && identifier(payload.conversationId)) {
- return { ok: true, value: await backend(core, 'GET', `${path}/conversations/${payload.conversationId}/messages?${identity}`) }
+ const page = await backend(core, 'GET', `${path}/conversations/${payload.conversationId}/messages?${identity}`)
+ return { ok: true, value: markAnswered(page, [], agentId) }
}
if (payload.action === 'message' && identifier(payload.conversationId) && identifier(payload.messageId)) {
- return { ok: true, value: await backend(core, 'GET', `${path}/conversations/${payload.conversationId}/messages?${identity}&messageId=${payload.messageId}`) }
+ const page = await backend(core, 'GET', `${path}/conversations/${payload.conversationId}/messages?${identity}&messageId=${payload.messageId}`)
+ // One exact message cannot show its own answer, so what came after it is read, but only for a question put to
+ // this agent. If that read fails the message is still returned, just without a verdict.
+ const sent = object(list(object(page).messages)[0])
+ const asked = Array.isArray(sent.recipientIds) && sent.recipientIds.includes(agentId) && object(sent.author).id !== agentId
+ if (!asked || !Number.isInteger(Number(sent.sequence))) return { ok: true, value: page }
+ try {
+ const later = object(await backend(core, 'GET', `${path}/conversations/${payload.conversationId}/messages?${identity}&after=${sent.sequence}`)).messages
+ return { ok: true, value: markAnswered(page, list(later), agentId) }
+ } catch { return { ok: true, value: page } }
}
if (payload.action === 'command' && identifier(payload.operationId) && payload.command && typeof payload.command === 'object' && !Array.isArray(payload.command)) {
return { ok: true, operationId: payload.operationId, value: await backend(core, 'POST', `${path}/commands`,
diff --git a/desktop/lib/super_tabs/launch.dart b/desktop/lib/super_tabs/launch.dart
index 4d2f62743..8dfa279c9 100644
--- a/desktop/lib/super_tabs/launch.dart
+++ b/desktop/lib/super_tabs/launch.dart
@@ -126,14 +126,19 @@ class SuperTabLaunch {
'First run `$command status`. Registration may still be finishing: if it reports AGENT_UNAVAILABLE, wait briefly and retry. '
'Do not start work or post until it confirms your participation.\n'
'Read the conversation: `$command messages ${saved['conversationId']}`. '
- 'Post explanations, questions and results with `$command post ${saved['conversationId']} "message" UNIQUE_OPERATION_ID`. '
+ 'Post explanations, questions and results with `$command post ${saved['conversationId']} "message" UNIQUE_OPERATION_ID [--reply-to MESSAGE_ID]`. '
'Reuse that operation ID and exact message after a lost reply. Your native terminal is not the shared conversation.\n'
'If sandbox restrictions block this local Harness command, request permission to run it outside the sandbox. '
'For work groups, assignments, acceptance evidence and messages to other agents, use `$command help`. '
'${saved['lead'] == true ? 'Before starting or assigning work, run `$command route GROUP JSON` with your difficulty and risk assessment, then start or assign its pick with the routeDecisionId it returns. To choose otherwise, pass overrideReason. If it answers NO_CANDIDATE, tell the person in the group why, using its reasons; do not guess another machine. ' : ''}'
'Use a group for an independently assignable outcome with acceptance checks. Reuse existing groups and agents. '
'Engine-native helper subagents do not need a group. Questions stay in the conversation where the work happens. '
- 'Report exact revisions, evidence and links appropriate to the project.\n\n'
+ 'Write to the people in this tab like a helpful colleague. Answer first, in plain words and in the language they used. '
+ 'Keep it short: a few sentences, under about 150 words, unless they ask for detail. '
+ 'Do not show commands, message or sequence ids, field names or error codes. '
+ 'Do not describe your own tools or permission prompts unless that blocks what they asked. '
+ 'Answer each message once: post with --reply-to MESSAGE_ID. If you have already answered a message, do not post again. '
+ 'When you hand over finished work, give the result with the revision and links they need.\n\n'
'The person’s request:\n${task.isEmpty ? 'Ask what they would like to work on.' : task}';
saved['launchPrompt'] = prompt;
await persist();
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 140978495..bd89c44b8 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -73,6 +73,12 @@ class _SuperTabViewState extends State<SuperTabView> {
String _authorName(SuperTabMessage message) =>
c.snapshot?.authorName(message) ?? message.authorName;
+ /// Your own message reads You, in the row and in the quote of it.
+ String _shownAuthor(SuperTabController c, SuperTabMessage message) =>
+ message.authorId == c.accountId && !message.fromAgent
+ ? 'You'
+ : _authorName(message);
+
@override
void initState() {
super.initState();
@@ -818,9 +824,7 @@ class _SuperTabViewState extends State<SuperTabView> {
return SuperTabMessageRow(
key: ValueKey('super-message-${message.id}'),
message: message,
- author: message.authorId == c.accountId && !message.fromAgent
- ? 'You'
- : _authorName(message),
+ author: _shownAuthor(c, message),
references: {
for (final g in c.snapshot?.conversations ?? <SuperTabConversation>[])
if (g.number != null) g.number!: g.id,
@@ -835,7 +839,7 @@ class _SuperTabViewState extends State<SuperTabView> {
machineName: agent == null ? null : widget.machineName(agent.machineId),
grouped: grouped,
reply: reply,
- replyAuthor: reply == null ? null : _authorName(reply),
+ replyAuthor: reply == null ? null : _shownAuthor(c, reply),
onReply: c.canWrite && c.selected?.archived == false
? () {
setState(() => _replies[c.selectedId] = message);
diff --git a/desktop/test/super_tab_chat_test.dart b/desktop/test/super_tab_chat_test.dart
index 17b892203..8251443b9 100644
--- a/desktop/test/super_tab_chat_test.dart
+++ b/desktop/test/super_tab_chat_test.dart
@@ -98,6 +98,28 @@ void main() {
},
);
+ testWidgets('the quote of your own message reads You, not your email', (
+ tester,
+ ) async {
+ final server = ConversationServer()
+ ..append('Where do we stand?')
+ ..append('Almost done.');
+ server.messages.last
+ ..['replyTo'] = 'message-1'
+ ..['author'] = {'kind': 'agent', 'id': 'builder', 'name': 'Builder'};
+ await show(tester, server);
+ final reply = find.byKey(const ValueKey('super-message-message-2'));
+ final quote = find.descendant(
+ of: reply,
+ matching: find.byType(SuperTabReplyPreview),
+ );
+ expect(
+ find.descendant(of: quote, matching: find.text('You')),
+ findsOneWidget,
+ );
+ expect(find.text('[email protected]'), findsNothing);
+ });
+
testWidgets(
'a keyboard reply keeps its quoted context after sending and refreshing',
(tester) async {
diff --git a/desktop/test/super_tab_launch_test.dart b/desktop/test/super_tab_launch_test.dart
index bd1dab541..35533c265 100644
--- a/desktop/test/super_tab_launch_test.dart
+++ b/desktop/test/super_tab_launch_test.dart
@@ -510,6 +510,24 @@ void main() {
expect(prompt, contains('NO_CANDIDATE'));
});
+ test('the lead prompt asks for short plain replies, answered once', () async {
+ final f = SuperTabLaunchFixture();
+ final box = await f.box(engine: 'claude');
+ expect(await box.create(), NewHarnessOutcome.created, reason: box.error);
+ final prompt =
+ f.connection.calls
+ .firstWhere((c) => c.$1 == 'agent_create')
+ .$2['prompt']
+ as String;
+ expect(prompt, contains('like a helpful colleague'));
+ expect(prompt, contains('under about 150 words'));
+ expect(prompt, contains('UNIQUE_OPERATION_ID [--reply-to MESSAGE_ID]`'));
+ expect(prompt, contains('post with --reply-to MESSAGE_ID'));
+ expect(prompt, contains('do not post again'));
+ expect(prompt, isNot(contains('Report exact revisions')));
+ expect(prompt, isNot(contains('email addresses')));
+ });
+
test('lost join acknowledgement retries the same contribution without a second native launch', () async {
final f = SuperTabLaunchFixture()..connection.loseJoin = true;
final box = await f.box();