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
feat(agents): a refused agent asks the person, then turns the setting on (#1719)
lingrd2295e3133226
diff --git a/cli/src/agentClient/commands.spec.ts b/cli/src/agentClient/commands.spec.tsindex 595c14ed5..a6131b04f 100644--- a/cli/src/agentClient/commands.spec.ts+++ b/cli/src/agentClient/commands.spec.ts@@ -929,7 +929,10 @@ describe('harness new, run by an agent', () => {rmSync(agentSettingsPath(dir))const inPane = (await agentOrigin(harness(d).deps))!await expect(inPane.check()).rejects.toMatchObject({ code: 'TURNED_OFF', message: AGENTS_START_AGENTS_OFF })- expect(AGENTS_START_AGENTS_OFF).toBe('Agents may not start harnesses: the person turns on "Agents can start other agents" in Harness Settings ▸ Experimental, or runs `harness settings agents-start-agents on`. Until then, do the work yourself.')+ // The agent asks the person with its own tool, and turns it on only after their yes: people do not open a terminal.+ expect(AGENTS_START_AGENTS_OFF).toMatch(/^Agents may not start harnesses yet\. agents-start-agents is off\. Ask the person, with your tool for asking them \(Claude Code: AskUserQuestion; Codex: request_user_input\)/)+ expect(AGENTS_START_AGENTS_OFF).toContain('Only if they say yes, run `harness settings agents-start-agents on --person-said-yes`')+ expect(AGENTS_START_AGENTS_OFF).toMatch(/Never answer it for them\. If they say no: do the work yourself\.$/)const outside = (await agentOrigin(harness(d, { pane: undefined, env: { CODEX_THREAD_ID: 't' } }).deps))!await expect(outside.check()).rejects.toThrow(AGENTS_START_AGENTS_OFF)expect(await agentOrigin(harness(d, { pane: undefined }).deps)).toBeNull()@@ -1630,7 +1633,7 @@ describe('harness whoami', () => {const h = harness(d)expect(await whoamiCommand(['--json'], h.deps)).toBe(EXIT.ok)const { context } = JSON.parse(h.out.join('\n'))- expect(context.canStart).toEqual({ ok: false, reason: 'SWITCH_OFF', message: 'The person has not turned on "Agents can start other agents".', fix: 'harness settings agents-start-agents on', fixBy: 'person' })+ expect(context.canStart).toEqual({ ok: false, reason: 'SWITCH_OFF', message: 'The person has not turned on "Agents can start other agents".', fix: 'harness settings agents-start-agents on --person-said-yes', fixBy: 'person' })expect(context.machines).toEqual([])})diff --git a/cli/src/agentClient/commands.ts b/cli/src/agentClient/commands.tsindex c2ced40eb..0a37ee395 100644--- a/cli/src/agentClient/commands.ts+++ b/cli/src/agentClient/commands.ts@@ -18,7 +18,7 @@ import { randomBytes } from 'node:crypto'import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'import { hostname } from 'node:os'import { join } from 'node:path'-import { readAgentSettings } from '../lib/agentSettings.js'+import { askThePersonFirst, readAgentSettings } from '../lib/agentSettings.js'import { MAX_FIRST_PROMPT_CHARS } from '../lib/engineLaunch.js'import { NewUsageError, resolveNewMachine, type NewMachine, type NewOrigin } from '../lib/newCommand.js'import { engineName, MessageError } from '../messages/model.js'@@ -139,7 +139,7 @@ class UsageError extends Error {}/** What an agent's `harness new` (and MCP's `harness_start`) says while the person has not let agents start agents: an* account experiment, off by default (lib/agentSettings.ts), so it says where the person turns it on, as `harness send`* does. */-export const AGENTS_START_AGENTS_OFF = 'Agents may not start harnesses: the person turns on "Agents can start other agents" in Harness Settings ▸ Experimental, or runs `harness settings agents-start-agents on`. Until then, do the work yourself.'+export const AGENTS_START_AGENTS_OFF = `Agents may not start harnesses yet. ${askThePersonFirst('agents-start-agents', 'do the work yourself.')}`const ORPHAN = 'This pane\'s harness is no longer running, so nothing here may close or start harnesses. Only the person can.'diff --git a/cli/src/agentClient/context.spec.ts b/cli/src/agentClient/context.spec.tsindex 606bcf61a..ae733c3d6 100644--- a/cli/src/agentClient/context.spec.ts+++ b/cli/src/agentClient/context.spec.ts@@ -26,7 +26,8 @@ describe('the context block', () => {it('the switch off: the person turns it on, and how; checked before the limits', () => {const c = buildContext(input({ switchOn: false, check: { reason: 'DEPTH', message: 'x' } }))- expect(formatContext(c).split('\n')[1]).toBe('Can start harnesses: no. The person has not turned on "Agents can start other agents". Ask them to run, in their own terminal: harness settings agents-start-agents on')+ // The agent asks them with its own tool, and runs it only after their yes: people do not open a terminal for this.+ expect(formatContext(c).split('\n')[1]).toBe('Can start harnesses: no. The person has not turned on "Agents can start other agents". Ask them, with your tool for asking them (Claude Code: AskUserQuestion; Codex: request_user_input) or in your reply; only after their yes, run: harness settings agents-start-agents on --person-said-yes')expect(c.canStart).toMatchObject({ ok: false, reason: 'SWITCH_OFF', fixBy: 'person' })})diff --git a/cli/src/agentClient/context.ts b/cli/src/agentClient/context.tsindex a60b0eeae..b4a72c852 100644--- a/cli/src/agentClient/context.ts+++ b/cli/src/agentClient/context.ts@@ -2,6 +2,7 @@* Where an agent is and what it may do, said before it acts (docs/design/2026-10-15-agent-experience.md, part 1).* Pure: commands.ts gathers what it says.*/+import { PERSON_SAID_YES } from '../lib/agentSettings.js'import type { NewMachine } from '../lib/newCommand.js'import { engineName } from '../messages/model.js'import type { Caller } from './model.js'@@ -41,6 +42,8 @@ export interface Context {}const TURN_ON = 'harness settings agents-start-agents on'+/** What the agent runs itself once the person said yes (agentClient/settings.ts). */+const TURN_ON_ONCE_ASKED = `${TURN_ON} ${PERSON_SAID_YES}`/** Other machines named on line 3; the rest are counted. */const MACHINES_SHOWN = 4const oneLine = (text: string, max = 40): string => {@@ -72,7 +75,7 @@ export function buildContext(i: ContextInput): Context {const canStart: NonNullable<Context['canStart']> =i.orphan && !i.caller ? no('ORPHAN', 'This pane\'s harness is no longer running. Only the person can start or close harnesses here.', null, 'person'): !i.signedIn ? no('SIGNED_OUT', 'This computer is signed out of Harness, and starting is the account\'s choice.', `harness login, then ${TURN_ON}`, 'person')- : !i.switchOn ? no('SWITCH_OFF', 'The person has not turned on "Agents can start other agents".', TURN_ON, 'person')+ : !i.switchOn ? no('SWITCH_OFF', 'The person has not turned on "Agents can start other agents".', TURN_ON_ONCE_ASKED, 'person'): i.check?.reason === 'DEPTH' ? no('DEPTH', 'An agent started you, and only one level is allowed. Do the work yourself, or say in your answer what else is needed.'): i.check?.reason === 'OPEN_LIMIT' ? no('OPEN_LIMIT', `You have ${quota?.open ?? i.limits.livePerHarness} open, the most.`, i.closeStep, 'you'): i.check?.reason === 'MACHINE_LIMIT' ? no('MACHINE_LIMIT', i.check.message)@@ -91,8 +94,11 @@ export function formatContext(c: Context): string {: `You: ${c.caller.agent}, outside Harness, on ${c.caller.machine}. Nothing can message you here.`if (!c.canStart) return whoconst s = c.canStart- // The person's own terminal: an agent asked to run it itself is refused (settings.ts `settingsOnlyThePerson`).- const asking = s.fixBy === 'you' ? 'To free a place' : s.reason === 'SWITCH_OFF' ? 'Ask them to run, in their own terminal' : 'Ask the person to run, in their own terminal'+ // The switch is the person's yes: the agent asks them with its own tool for it, and runs the command only after it+ // (settings.ts). Signing in is theirs alone: a code on their phone.+ const asking = s.fixBy === 'you' ? 'To free a place'+ : s.reason === 'SWITCH_OFF' ? 'Ask them, with your tool for asking them (Claude Code: AskUserQuestion; Codex: request_user_input) or in your reply; only after their yes, run'+ : 'Ask the person to run, in their own terminal'const can = s.ok ? 'Can start harnesses: yes.': s.reason === 'START_RATE' && c.quota?.nextStartAt ? `Can start harnesses: not until ${hhmm(c.quota.nextStartAt)} (${s.message.replace(/\.$/, '')}).`: `Can start harnesses: no. ${s.message}${s.fix ? ` ${asking}: ${s.fix}` : ''}`diff --git a/cli/src/agentClient/help.ts b/cli/src/agentClient/help.tsindex c9aa1a3d3..27417ac21 100644--- a/cli/src/agentClient/help.ts+++ b/cli/src/agentClient/help.ts@@ -6,6 +6,7 @@ import { CLOSE_USAGE, EXIT, PS_USAGE, SHOW_USAGE, SPAWN_LIMITS, TELL_USAGE, WAITimport { NEW_USAGE } from '../lib/newCommand.js'import { SEND_USAGE } from '../messages/command.js'import { outsideCaller } from './model.js'+import { PERSON_SAID_YES } from '../lib/agentSettings.js'const synopsis = (usage: string): string => usage.split('\n')[0].replace(/^Usage: /, '')const sendLine = (): string => (SEND_USAGE.split('\n').find((l) => l.includes('harness send <name>[,<name>]')) ?? '').trim().split(/\s{2,}/)[0]@@ -38,8 +39,10 @@ export function agentsHelp(): string {+ `${EXIT.stopped} stopped or gone · ${EXIT.refused} refused (do not retry) · ${EXIT.timeout} still working when the wait ended.`,`Limits: ${SPAWN_LIMITS.livePerHarness} of yours open at once, ${SPAWN_LIMITS.perWindow} starts in ${SPAWN_LIMITS.windowMs / 60_000} minutes;`,'a harness another agent started may not start harnesses.',- 'Rules: name every harness. Put the whole task in it: more work later goes only by harness tell,',- 'which the person turns on (harness settings agents-tell-agents).',+ 'Rules: name every harness. Put the whole task in it: more work later goes only by harness tell.',+ 'A setting that refuses you is the person\'s to give: ask them with your tool for asking them',+ '(Claude Code: AskUserQuestion; Codex: request_user_input) or in your reply, and only after their yes run',+ `harness settings <name> on ${PERSON_SAID_YES}. Never answer it for them.`,'Close what you started once you have its answer. Never close one you did not start.','When a harness needs the person, tell the person: only they answer it.','Never ask a harness to publish, deploy, delete or push.',diff --git a/cli/src/agentClient/mcp.spec.ts b/cli/src/agentClient/mcp.spec.tsindex b96012ceb..c9f6695a0 100644--- a/cli/src/agentClient/mcp.spec.ts+++ b/cli/src/agentClient/mcp.spec.ts@@ -52,7 +52,7 @@ describe('harness mcp', () => {it('lists send only to a harness in its own pane: an agent outside Harness has nothing to be answered at', async () => {const names = async (inPane: boolean) => ((await answer({ jsonrpc: '2.0', id: 1, method: 'tools/list' }, deps({ inPane })))!.result as { tools: Array<{ name: string; argv?: unknown }> }).toolsconst outside = await names(false)- expect(outside.map((t) => t.name)).toEqual(['harness_whoami', 'harness_list', 'harness_search', 'harness_machines', 'harness_start', 'harness_wait', 'harness_read', 'harness_close'])+ expect(outside.map((t) => t.name)).toEqual(['harness_whoami', 'harness_list', 'harness_search', 'harness_machines', 'harness_start', 'harness_wait', 'harness_read', 'harness_settings', 'harness_close'])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 } })@@ -81,13 +81,18 @@ describe('harness mcp', () => {const listed = ((await answer({ jsonrpc: '2.0', id: 1, method: 'tools/list' }, deps({ inPane: true })))!.result as { tools: Array<{ name: string; annotations?: Record<string, unknown> }> }).toolsexpect(Object.fromEntries(listed.map((tool) => [tool.name, codexAsks(tool.annotations)]))).toEqual({harness_whoami: false, harness_list: false, harness_search: false, harness_machines: false, harness_start: false, harness_wait: false, harness_read: false, harness_tell: false, harness_send: false, harness_close: false,+ // Turning a setting on widens what agents may do: an engine that asks before an unmarked tool asks the person too.+ harness_settings: true,})})it('runs only the verbs Harness allows agents to run without asking, each as the tool the rules name', () => {// The engines' permission rules (facets/hooks.ts HARNESS_AGENT_TOOLS) allow each verb, and its tool by name.- const runs = Object.fromEntries(TOOLS.map((tool) => [tool.argv({ name: 'x', names: ['x'], task: 't', to: 'x', text: 't' }, '/work')[0], tool.name]))+ // But `settings`, which the engine asks the person about (a setting widens what agents may do).+ const runs = Object.fromEntries(TOOLS.filter((tool) => tool.name !== 'harness_settings')+ .map((tool) => [tool.argv({ name: 'x', names: ['x'], task: 't', to: 'x', text: 't' }, '/work')[0], tool.name]))expect(runs).toEqual(HARNESS_AGENT_TOOLS)+ expect(Object.keys(HARNESS_AGENT_TOOLS)).not.toContain('settings')})it('runs each tool as its verb', async () => {@@ -110,6 +115,10 @@ describe('harness mcp', () => {await answer(call('harness_read', { name: 'a', chars: 99.9 }), d)await answer(call('harness_send', { to: 'a', text: 'also the footer' }), d)await answer(call('harness_tell', { name: 'a', text: '--now: add tests\ntoo' }), d)+ await answer(call('harness_settings'), d)+ await answer(call('harness_settings', { name: 'agents-tell-agents', on: true }), d)+ await answer(call('harness_settings', { name: 'agents-tell-agents', on: true, person_said_yes: true }), d)+ await answer(call('harness_settings', { name: 'agent-messages', on: false }), d)await answer(call('harness_close', { name: 'a' }), d)await answer(call('harness_close', { name: 'a', now: true }), d)expect(r.calls.map((c) => c.argv)).toEqual([@@ -125,6 +134,8 @@ describe('harness mcp', () => {['send', 'a', 'also the footer'],// After `--`, words that look like options are the work, not flags.['tell', 'a', '--', '--now: add tests\ntoo'],+ ['settings'], ['settings', 'agents-tell-agents', 'on'], ['settings', 'agents-tell-agents', 'on', '--person-said-yes'],+ ['settings', 'agent-messages', 'off'],['close', 'a'], ['close', 'a', '--now'],])})diff --git a/cli/src/agentClient/mcp.ts b/cli/src/agentClient/mcp.tsindex 071a92c83..e6c950cc2 100644--- a/cli/src/agentClient/mcp.ts+++ b/cli/src/agentClient/mcp.ts@@ -17,6 +17,7 @@ import { VERSION } from '../version.js'import { AGENT_SESSION_ENV } from './model.js'import { EXIT, VIA_MCP_ENV } from './commands.js'import { ENGINES, TERMINAL_ENGINE } from '../engines/types.js'+import { AGENT_SETTING_NAMES, PERSON_SAID_YES } from '../lib/agentSettings.js'/** Newest first: the client's own when it is one of these, else the newest. */export const PROTOCOL_VERSIONS = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'] as const@@ -30,7 +31,7 @@ Call harness_whoami first: it says whether you may start harnesses now. Then lisName 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.-Each answer ends with Next: the call to make next. A refusal is final: do not retry it; tell the person, or do the work yourself.`+Each answer ends with Next: the call to make next. A refusal is final: do not retry it; tell the person, or do the work yourself. One that says a setting is off is the person's to give: ask them with your tool for asking them, or in your reply, and only after their yes turn it on (harness_settings with person_said_yes), then try again. Never answer it for them.`/** How long `harness_wait` waits when not told: within what MCP clients allow a call. Codex ends one at 60 s unless its* config says otherwise (`tool_timeout_sec`, developers.openai.com/codex/mcp), so 120 s ended every long wait as an@@ -156,6 +157,19 @@ export const TOOLS: Tool[] = [annotations: { destructiveHint: false, openWorldHint: false },argv: (a) => ['send', str(a.to), typeof a.text === 'string' ? a.text : ''],},+ {+ name: 'harness_settings',+ description: 'What agents may do here, the person\'s settings: with no name, each one and whether it is on. With a name, turn it on or off. Turning one on is the person\'s yes to give: ask them first, with your tool for asking them or in your reply, and set person_said_yes only after they said yes. Turning one off needs no one\'s yes.',+ inputSchema: schema({+ name: { type: 'string', enum: Object.keys(AGENT_SETTING_NAMES), description: 'The setting, as a refusal names it.' },+ on: { type: 'boolean', description: 'true to turn it on, false to turn it off.' },+ person_said_yes: { type: 'boolean', description: 'The person said yes to turning it on, just now, when you asked them.' },+ }),+ // Not marked safe: a setting widens what agents may do, so an engine that asks before an unmarked tool (Codex) asks+ // the person too. Harness's verbs are allowed without asking; this one is not among them (facets/hooks.ts).+ argv: (a) => !str(a.name) ? ['settings']+ : ['settings', str(a.name), a.on === false ? 'off' : 'on', ...(a.person_said_yes === true ? [PERSON_SAID_YES] : [])],+ },{name: 'harness_close',description: 'Close a harness you started, once it is done. Its conversation is kept: the person can resume it. Refused while it works, unless now is true.',diff --git a/cli/src/agentClient/settings.spec.ts b/cli/src/agentClient/settings.spec.tsindex 4517df6f4..bbca76759 100644--- a/cli/src/agentClient/settings.spec.ts+++ b/cli/src/agentClient/settings.spec.ts@@ -71,12 +71,15 @@ describe('harness settings', () => {expect(down.out).toEqual([])})- it('lets only the person turn one on: an agent is refused, and may still turn one off or read them', async () => {+ it('has an agent ask the person before it turns one on, with its own tool for asking them', async () => {for (const agent of [{ CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: 's' }, { CODEX_THREAD_ID: 't' }, { AI_AGENT: 'cursor' }]) {const d = daemon((method, body) => ({ status: 200, body: { ...OFF, ...(body as object), signedIn: true } }), agent)expect(await d.run('agents-start-agents', 'on')).toBe(5)- expect(d.err).toEqual(['Only the person turns this on: it is their consent to what agents may do. Ask them to run '- + '`harness settings agents-start-agents on` in their own terminal, or to turn it on in Harness Settings ▸ Experimental.'])+ expect(d.err).toEqual(['agents-start-agents is off. Ask the person, with your tool for asking them (Claude Code: AskUserQuestion; '+ + 'Codex: request_user_input), or in your reply, and wait for their answer: "May I start other agents (Claude Code, Codex) in '+ + 'harnesses of their own, for work that can run beside mine?" Only if they say yes, run `harness settings agents-start-agents '+ + 'on --person-said-yes` (through MCP: harness_settings with person_said_yes), then try again. Never answer it for them. '+ + 'If they say no: leave it as it is, and do the work another way.'])// Nothing was asked of the daemon.expect(d.asked).toEqual([])expect(await d.run('agent-messages', 'off')).toBe(0)@@ -84,12 +87,24 @@ describe('harness settings', () => {}})+ it('turns one on for an agent once the person said yes, and says who did in what it sends', async () => {+ const agent = { CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: 's' }+ const d = daemon((method, body) => ({ status: 200, body: { ...OFF, ...(body as object), signedIn: true } }), agent)+ expect(await d.run('agents-tell-agents', 'on', '--person-said-yes')).toBe(0)+ expect(d.out.at(-1)).toBe('agents-tell-agents is on for your account. The person said yes; tell them they can turn it off any time by asking you.')+ expect(d.asked.at(-1)!.body).toEqual({ agentsTellAgents: true, byAgent: 'Claude Code' })+ // The person's own: no word of an agent.+ const person = daemon((method, body) => ({ status: 200, body: { ...OFF, ...(body as object), signedIn: true } }))+ expect(await person.run('agents-tell-agents', 'on', '--person-said-yes')).toBe(0)+ expect(person.asked.at(-1)!.body).toEqual({ agentsTellAgents: true })+ expect(person.out.at(-1)).toBe('agents-tell-agents is on for your account.')+ })+it('refuses an agent the direction that widens sharing: for the inverted summary switch that is off, not on', async () => {const agent = { CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: 's' }const d = daemon((method, body) => ({ status: 200, body: { ...OFF, ...(body as object), signedIn: true } }), agent)expect(await d.run('agent-messages-hide-summary', 'off')).toBe(5)- expect(d.err).toEqual(['Only the person turns this off: it is their consent to what agents may do. Ask them to run '- + '`harness settings agent-messages-hide-summary off` in their own terminal, or to change it in Harness Settings ▸ Experimental.'])+ expect(d.err.join('\n')).toMatch(/^agent-messages-hide-summary is on\. Ask the person, .* "May Harness share a one-line summary of what your harnesses do with the people in your shared tabs\?" Only if they say yes, run `harness settings agent-messages-hide-summary off --person-said-yes`/)expect(d.asked).toEqual([])// Hiding the summary narrows what is shared: an agent may.expect(await d.run('agent-messages-hide-summary', 'on')).toBe(0)diff --git a/cli/src/agentClient/settings.ts b/cli/src/agentClient/settings.tsindex fa7bf6efe..81e4abc31 100644--- a/cli/src/agentClient/settings.ts+++ b/cli/src/agentClient/settings.ts@@ -8,7 +8,7 @@* It asks this computer's daemon (`/api/agent-settings`), which reads them as this computer keeps them and writes a* change through to the account (core/experiments.ts `createAgentSettingsSync`): the copy is the daemon's alone.*/-import { AGENT_SETTING_NAMES, type AgentSettings } from '../lib/agentSettings.js'+import { AGENT_SETTING_NAMES, askThePersonFirst, PERSON_SAID_YES, type AgentSettings } from '../lib/agentSettings.js'import { localCredentialHeaders } from '../lib/localCredential.js'import { env } from '../config/env.js'import { daemonUnreachableText } from '../lib/daemonState.js'@@ -17,16 +17,16 @@ import { outsideCaller } from './model.js'/** A refusal, as the agent verbs exit (commands.ts `EXIT.refused`): not a failure to retry. */const REFUSED = 5-/** Said to an agent that tries to turn a setting on: the person's consent is theirs to give. */+/** Said to an agent that tries to turn a setting on without the person's yes: the consent is theirs to give, and the+ * agent asks them for it (lib/agentSettings.ts `askThePersonFirst`). */export const settingsOnlyThePerson = (name: string, value: 'on' | 'off' = 'on'): string =>- `Only the person turns this ${value}: it is their consent to what agents may do. Ask them to run \`harness settings ${name} ${value}\` `- + `in their own terminal, or to ${value === 'on' ? 'turn it on' : 'change it'} in Harness Settings ▸ Experimental.`+ askThePersonFirst(name, 'leave it as it is, and do the work another way.', value)/** The value of a setting that widens what is shared or allowed, which only the person gives. Every setting is granted by `on`* but the summary switch, which is stored inverted: it widens sharing when it is turned off. */const GRANTING: Partial<Record<keyof AgentSettings, 'off'>> = { agentMessagesHideSummary: 'off' }-export const SETTINGS_USAGE = `Usage: harness settings [<name> on|off]+export const SETTINGS_USAGE = `Usage: harness settings [<name> on|off [${PERSON_SAID_YES}]]What agents may do, as Settings ▸ Experimental shows it: experiments of your account, the same on each of itscomputers, and each off until you turn it on:@@ -37,7 +37,11 @@ computers, and each off until you turn it on:agent-messages agents in the same tab may message each other with harness sendagent-messages-hide-summarykeep the one-line summary of what a harness does from a shared tab's other accounts- (on hides it; it is shared while this is off)`+ (on hides it; it is shared while this is off)++An agent turns one on only for the person: it asks them first, with its tool for asking them (Claude Code:+AskUserQuestion; Codex: request_user_input) or in its reply, and adds ${PERSON_SAID_YES} once they said yes.+Turning one off needs no one's yes.`const ABOUT: Record<keyof AgentSettings, string> = {agentsStartAgents: 'agents may start, wait for and close harnesses of their own',@@ -67,16 +71,26 @@ export async function settingsCommand(argv: readonly string[], deps: SettingsDepconst out = deps.out ?? console.logconst err = deps.err ?? console.errorif (argv.includes('--help') || argv.includes('-h')) { out(SETTINGS_USAGE); return 0 }- let change: Record<string, boolean> | null = null+ let change: Record<string, unknown> | null = null+ let saidYes = falseif (argv.length) {- const [name, value, ...rest] = argv+ const yes = argv.includes(PERSON_SAID_YES)+ const [name, value, ...rest] = argv.filter((word) => word !== PERSON_SAID_YES)const key = AGENT_SETTING_NAMES[name]if (!key || (value !== 'on' && value !== 'off') || rest.length) { err(SETTINGS_USAGE); return 2 }change = { [key]: value === 'on' }// An agent refused a start would otherwise turn on the setting that refused it, and the person's say would be its- // own. Its shell says it is one (Claude Code, Codex, AI_AGENT), in a Harness pane or not. Turning one off is safe, but for the one stored inverted.+ // own. Its shell says it is one (Claude Code, Codex, AI_AGENT), in a Harness pane or not. Turning one off is safe,+ // but for the one stored inverted. It may once it asked the person and they said yes: people ask their agent for+ // the work and never open a terminal for this (2026-10-26). The yes is the agent's word, so it is named in the+ // daemon's log with the agent that gave it.const granting = GRANTING[key] ?? 'on'- if (value === granting && outsideCaller(deps.env ?? process.env, '')) { err(settingsOnlyThePerson(name, granting)); return REFUSED }+ const agent = outsideCaller(deps.env ?? process.env, '')+ if (value === granting && agent) {+ if (!yes) { err(settingsOnlyThePerson(name, granting)); return REFUSED }+ saidYes = true+ change.byAgent = agent.name+ }}let answer: Answertry {@@ -98,9 +112,9 @@ export async function settingsCommand(argv: readonly string[], deps: SettingsDepreturn 1}if (change) {- const [key] = Object.keys(change) as Array<keyof AgentSettings>+ const [key] = Object.keys(change).filter((each) => each !== 'byAgent') as Array<keyof AgentSettings>const name = Object.keys(AGENT_SETTING_NAMES).find((each) => AGENT_SETTING_NAMES[each] === key)!- out(`${name} is ${answer.body[key] === true ? 'on' : 'off'} for your account.`)+ out(`${name} is ${answer.body[key] === true ? 'on' : 'off'} for your account.${saidYes ? ' The person said yes; tell them they can turn it off any time by asking you.' : ''}`)return 0}out(Object.entries(AGENT_SETTING_NAMES)diff --git a/cli/src/core/experiments.spec.ts b/cli/src/core/experiments.spec.tsindex 2ac721777..27bac55f9 100644--- a/cli/src/core/experiments.spec.ts+++ b/cli/src/core/experiments.spec.ts@@ -319,6 +319,26 @@ describe('the account\'s agent experiments, kept for this computer', () => {expect(t.want).toHaveBeenCalledOnce()})+ it('names in its log the agent that turned one on with the person\'s yes, which is only its word', async () => {+ const lines: string[] = []+ const t = setup({ log: (line) => lines.push(line) })+ answer(account({}))+ answers.push(async () => account({ agents_tell_agents: true }))+ expect(await t.sync.settingsWrite({ agentsTellAgents: true, byAgent: 'Claude Code' }))+ .toEqual({ status: 200, body: { ...OFF, agentsTellAgents: true, signedIn: true } })+ expect(lines).toEqual(['[settings] agentsTellAgents on by Claude Code, which says the person said yes'])+ // The summary switch grants by turning off: the agent's word is named for it too.+ answer(account({ agent_messages_hide_summary: true }))+ answers.push(async () => account({}))+ await t.sync.settingsWrite({ agentMessagesHideSummary: false, byAgent: 'Codex' })+ expect(lines.at(-1)).toBe('[settings] agentMessagesHideSummary off by Codex, which says the person said yes')+ // Not for the person's own write, nor for a name that says nothing.+ answer(account({ agents_tell_agents: true }))+ answers.push(async () => account({}))+ await t.sync.settingsWrite({ agentsTellAgents: false, byAgent: ' ' })+ expect(lines).toHaveLength(2)+ })+it('refuses a write with nothing in it, signed out, or with the account out of reach, and says why', async () => {const t = setup()for (const body of [null, 'on', { other: true }, { agentMessages: 'yes' }]) {diff --git a/cli/src/core/experiments.ts b/cli/src/core/experiments.tsindex 7bf73c2c3..9359c964a 100644--- a/cli/src/core/experiments.ts+++ b/cli/src/core/experiments.ts@@ -179,6 +179,11 @@ export function createAgentSettingsSync(deps: {const written = heard(await deps.backend('PATCH', EXPERIMENTAL_SETTINGS, { accountId, feature, enabled }), asked)if (!agentSettingsFromAnswer(written)) return failed(written)}+ // Turned on by an agent on the person's yes (agentClient/settings.ts): Harness has only its word for that yes.+ const byAgent = (body as Record<string, unknown>).byAgent+ if (typeof byAgent === 'string' && byAgent.trim()) {+ log(`[settings] ${changes.map(([key, enabled]) => `${key} ${enabled ? 'on' : 'off'}`).join(', ')} by ${byAgent.trim().slice(0, 40)}, which says the person said yes`)+ }return { status: 200, body: { ...readAgentSettings(deps.dataDir, deps.session()), signedIn: true } }},}diff --git a/cli/src/lib/agentSettings.ts b/cli/src/lib/agentSettings.tsindex 3888390f2..288593c63 100644--- a/cli/src/lib/agentSettings.ts+++ b/cli/src/lib/agentSettings.ts@@ -45,6 +45,34 @@ export const AGENT_SETTING_NAMES: Record<string, keyof AgentSettings> = { 'agent/** Each setting's account experiment, as the backend names it (lib/experimentalSettings.ts `experimentalFeatures`). */export const AGENT_SETTING_EXPERIMENTS: Record<keyof AgentSettings, string> = { agentsStartAgents: 'agents_start_agents', pullRequestLine: 'agent_pull_request_line', agentMessages: 'agent_messages', agentMessagesHideSummary: 'agent_messages_hide_summary', agentsTellAgents: 'agents_tell_agents' }+/** The flag an agent adds to `harness settings <name> on` once the person said yes to it (agentClient/settings.ts). */+export const PERSON_SAID_YES = '--person-said-yes'++/** What an agent asks the person before it turns each setting on: one question they can answer yes or no. */+export const AGENT_SETTING_QUESTIONS: Record<keyof AgentSettings, string> = {+ agentsStartAgents: 'May I start other agents (Claude Code, Codex) in harnesses of their own, for work that can run beside mine?',+ agentsTellAgents: 'May I give more work to the harnesses I started, in the conversations they already have?',+ pullRequestLine: 'May a harness another agent started say so in the pull requests it opens?',+ agentMessages: 'May agents in the same tab message each other?',+ agentMessagesHideSummary: 'May Harness share a one-line summary of what your harnesses do with the people in your shared tabs?',+}++/**+ * What an agent refused by a setting that is off is told to do: ask the person with its own tool for questions, and turn+ * the setting on only after their yes. People do not run `harness settings` themselves: they ask their agent for the work,+ * and a refusal that sent them to a terminal, or to a Settings switch the app does not show, left the work undone+ * (2026-10-26). Harness takes the agent's word for the yes (the `--person-said-yes` flag), so the words say plainly that+ * the person answers it, never the agent. [otherwise] is what to do if they say no. [value] is the one that grants:+ * `off` for the summary switch, which is stored inverted.+ */+export function askThePersonFirst(name: string, otherwise: string, value: 'on' | 'off' = 'on'): string {+ const key = AGENT_SETTING_NAMES[name]+ const question = key ? AGENT_SETTING_QUESTIONS[key] : `May I turn ${value} ${name}?`+ return `${name} is ${value === 'on' ? 'off' : 'on'}. Ask the person, with your tool for asking them (Claude Code: AskUserQuestion; Codex: request_user_input), `+ + `or in your reply, and wait for their answer: "${question}" Only if they say yes, run \`harness settings ${name} ${value} ${PERSON_SAID_YES}\` `+ + `(through MCP: harness_settings with person_said_yes), then try again. Never answer it for them. If they say no: ${otherwise}`+}+/** Whom a copy is for: the account, and this computer's machine in it. A machine is one account's, so a sign-in to* another account on this computer has another. */export interface AgentSettingsOwner { accountId: string; machineId: string }diff --git a/cli/src/messages/service.spec.ts b/cli/src/messages/service.spec.tsindex c9c6ae931..5ac0d316c 100644--- a/cli/src/messages/service.spec.ts+++ b/cli/src/messages/service.spec.ts@@ -283,7 +283,9 @@ describe('harness send', () => {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 switch of the account replaced each tab's chat icon, which the owner hit by mistake (2026-10-12).- const refused = { error: 'MESSAGES_OFF', detail: 'Agent Messages are off. The person turns on "Agents in the same tab can message each other" in Settings ▸ Experimental, or runs `harness settings agent-messages on`.' }+ // The agent asks the person, and turns it on only after their yes (lib/agentSettings.ts `askThePersonFirst`).+ const refused = { error: 'MESSAGES_OFF', detail: MESSAGES_OFF_TEXT }+ expect(MESSAGES_OFF_TEXT).toMatch(/^Agent Messages are off\. agent-messages is off\. Ask the person, .*"May agents in the same tab message each other\?" Only if they say yes, run `harness settings agent-messages on --person-said-yes`.* If they say no: work on without messaging your teammates\.$/)// An account that never said: off by default, so nothing is sent and no one is told of teammates.rmSync(agentSettingsPath(root))const fresh = setup()diff --git a/cli/src/messages/service.ts b/cli/src/messages/service.tsindex b8293680a..118db5c7e 100644--- a/cli/src/messages/service.ts+++ b/cli/src/messages/service.ts@@ -35,7 +35,7 @@ import { basename, join } from 'node:path'import { SHARED_ACTIVITY_WINDOW_FRAME, SHARED_TABS_WINDOW_FRAME, type CoreApi, type ServiceRequests, type TabFrame, type TurnDelivery } from '../core/api.js'import { env } from '../config/env.js'import { agentProject } from '../lib/agentProject.js'-import { agentSettingsPath, readAgentSettings } from '../lib/agentSettings.js'+import { agentSettingsPath, askThePersonFirst, readAgentSettings } from '../lib/agentSettings.js'import type { RegisteredSession } from '../lib/registry.js'import { primaryRuntime, sessionForPaneId, terminalRouteKey } from '../lib/terminalRuntime.js'import { type DirectoryTab, MessageDirectory, POLL_MS, type Member } from './directory.js'@@ -137,7 +137,7 @@ export const WHO_WAIT_MS = 4_000/** How long `harness send` alone waits for the tasks before it gives the roster without them. */export const TASKS_WAIT_MS = 4_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. The person turns on "Agents in the same tab can message each other" in Settings ▸ Experimental, or runs `harness settings agent-messages on`.'+export const MESSAGES_OFF_TEXT = `Agent Messages are off. ${askThePersonFirst('agent-messages', 'work on without messaging your teammates.')}`/** How long the windows' `shared_tabs_changed` waits for more of the same change. */export const SHARES_COALESCE_MS = 250diff --git a/cli/src/messages/tell.ts b/cli/src/messages/tell.tsindex 2e60dd27e..41e847ab6 100644--- a/cli/src/messages/tell.ts+++ b/cli/src/messages/tell.ts@@ -14,14 +14,14 @@* Its messages are kept under the pseudo-tab `told`: no tab carries them, and nothing that reads a tab's log shows them.*/import type { Ledger, LedgerMember } from '../agentClient/ledger.js'+import { askThePersonFirst } from '../lib/agentSettings.js'import { engineName, shown, type Message } from './model.js'/** The tab id a told message is kept under. No desk tab has it: ids there are the backend's. */export const TOLD_TAB = 'told'-/** Said when the person has not allowed it. The agent should not retry: it starts a new harness or does the work itself. */-export const TELL_OFF_TEXT = 'Agents may not give more work to harnesses they started: the person turns on "agents-tell-agents" '- + '(`harness settings agents-tell-agents on`). Until then, start a new harness with the whole task, or do the work yourself.'+/** Said when the person has not allowed it: the agent asks them, and retries only after their yes. */+export const TELL_OFF_TEXT = `Agents may not give more work to harnesses they started yet. ${askThePersonFirst('agents-tell-agents', 'start a new harness with the whole task, or do the work yourself.')}`export interface TellRefusal { code: 'TELL_OFF' | 'NOT_YOURS' | 'NOT_RUNNING'; message: string }