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
Codex pursuing a goal or browsing its transcript is no longer read as idle (#816)
Dee3ac2aea57f72
diff --git a/cli/e2e/ends.e2e.ts b/cli/e2e/ends.e2e.tsindex 0d0160f78..2ff1456c4 100644--- a/cli/e2e/ends.e2e.ts+++ b/cli/e2e/ends.e2e.ts@@ -205,6 +205,36 @@ describe('how an agent\'s life ends', () => {client.close()})+ it('codex: an agent between the turns of its goal is not closed after its task until the goal is done', async () => {+ const d = await fresh()+ const client = await LocalClient.connect(d)+ const agent = await create(d, client, 'codex', 'close-goal')+ // Codex 0.160 between the turns of a goal: its composer empty, `Pursuing goal` on its status line.+ await turn(client, agent.id, '!goal')+ expect(await close(client, agent, 'inspect')).toMatchObject({ activity: 'working' })+ expect(await close(client, agent, 'after_task')).toMatchObject({ deferred: true })+ // Two idle looks five seconds apart would have closed it by now.+ await new Promise((resolve) => setTimeout(resolve, 13_000))+ expect((await row(client, agent.id))?.status).toBe('active')+ await turn(client, agent.id, '!goal done')+ await stopped(client, agent.id, 60_000)+ client.close()+ })++ it('codex: browsing its transcript is someone at the pane, so a close only when idle waits', async () => {+ const d = await fresh()+ const client = await LocalClient.connect(d)+ const agent = await create(d, client, 'codex', 'close-browsing')+ await turn(client, agent.id, '!browse')+ expect(await close(client, agent, 'inspect')).toMatchObject({ activity: 'needs_input' })+ expect(await close(client, agent, 'idle')).toMatchObject({ error: 'SESSION_NOT_IDLE', activity: 'needs_input' })+ // Esc leaves it, as in Codex, and the agent reads idle again.+ await d.tmux.run('send-keys', '-t', agent.tmuxPane, 'Escape')+ await until('the agent to read idle again', async () => (await close(client, agent, 'inspect')).activity === 'idle' || null, 15_000, 500)+ expect((await row(client, agent.id))?.status).toBe('active')+ client.close()+ })+it('a close for an agent that is not the one asked about changes nothing', async () => {const d = await fresh()const client = await LocalClient.connect(d)diff --git a/cli/e2e/harness/fakeEngine.mjs b/cli/e2e/harness/fakeEngine.mjsindex d2e2673d8..ff5bea63e 100644--- a/cli/e2e/harness/fakeEngine.mjs+++ b/cli/e2e/harness/fakeEngine.mjs@@ -18,7 +18,9 @@// same pane as Claude Code's `/clear` and Codex's `/new` do, `!compact` compacts the conversation as// `/compact` does (and Claude Code then announces the same session again), `!compactmid` compacts in the// middle of a turn as an automatic compaction does, `!version` answers with the version this-// process is, `!exit` ends the process. Everything else is echoed as the answer.+// process is, `!goal` and `!goal done` (Codex) start and achieve a goal the way Codex 0.160 shows one+// under its composer, `!browse` (Codex) leaves Codex browsing its transcript, `!exit` ends the process.+// Everything else is echoed as the answer.//// Which release is installed is the config's business, so a test can update an engine in place by// rewriting its wrapper: `version` is what it reports and writes, `without` lists the flags and@@ -160,7 +162,25 @@ export async function run(engine, config) {}announceProcess()- const draw = (line = '') => process.stdout.write(`\r\x1b[2K› ${line}`)+ // What Codex 0.160 draws under its empty composer in the two states the daemon must read off the pane+ // (tui/src/bottom_pane): a goal it is pursuing, on the right of its status line, and the footer of+ // its transcript browser, with the composer dimmed whole. Null draws the composer alone, as before.+ let bottom = null+ const placeholder = '\x1b[1m›\x1b[0m \x1b[2mAsk Codex to do anything\x1b[0m'+ const goalBottom = (goal) => ({ composer: placeholder, footer: ` gpt-6 high · ${cwd} \x1b[35m${goal}\x1b[0m` })+ const browsingBottom = {+ composer: '\x1b[2m› Ask Codex to do anything\x1b[0m',+ footer: '\x1b[36mBrowsing transcript\x1b[0m\x1b[2m · \x1b[0m↑↓/jk\x1b[2m scroll · \x1b[0m←→/hl\x1b[2m prompts · \x1b[0m↵\x1b[2m rewind · \x1b[0mesc\x1b[2m back\x1b[0m',+ browsing: true,+ }+ const draw = (line = '') => {+ if (bottom && !line) {+ // The footer on the row under the composer, then the cursor back to the composer, after its glyph.+ process.stdout.write(`\r\x1b[2K${bottom.composer}\r\n\x1b[2K${bottom.footer}\x1b[1A\r\x1b[2C`)+ return+ }+ process.stdout.write(`\r\x1b[2K› ${line}`)+ }process.stdout.write(`\x1b[?2004h${engine === 'claude' ? '✻ Welcome to Claude Code (fake)' : '>_ OpenAI Codex (fake)'}\r\n`)process.stdout.write(` session ${sessionId}${resumed ? ' (resumed)' : ''}\r\n\r\n`)draw()@@ -287,7 +307,9 @@ export async function run(engine, config) {if (engine === 'claude') await hook('session-start', { hookEvent: 'UserPromptSubmit', prompt })turn++open = `turn-${turn}`- process.stdout.write(`\r\n`)+ // Onto the row under the composer, which holds a footer while one is drawn: cleared, as Codex redraws+ // its whole bottom pane rather than leave the old one in the history above.+ process.stdout.write(`\r\n\x1b[2K`)if (engine === 'claude') {claude({ type: 'user', message: { role: 'user', content: prompt } })claude({ type: 'assistant', message: { id: `msg_${turn}_t`, role: 'assistant', model: config.claudeModel ?? 'claude-opus-5-5', content: [{ type: 'thinking', thinking: `considering: ${prompt}` }], stop_reason: null } })@@ -384,6 +406,17 @@ export async function run(engine, config) {return}if (directive?.[1] === 'version') { finish(versionLine); return }+ if (engine === 'codex' && directive?.[1] === 'goal') {+ bottom = goalBottom(directive[2] === 'done' ? 'Goal achieved (1m)' : 'Pursuing goal (1m)')+ finish(`answer ${turn}: ${prompt}`)+ return+ }+ if (engine === 'codex' && directive?.[1] === 'browse') {+ // Reached in Codex by Esc twice on an empty composer; the directive goes straight there.+ bottom = browsingBottom+ finish(`answer ${turn}: ${prompt}`)+ return+ }if (directive?.[1] === 'slow') await new Promise((resolve) => setTimeout(resolve, Number(directive[2]) || 1000))finish(`answer ${turn}: ${prompt}`)}@@ -397,6 +430,14 @@ export async function run(engine, config) {let pasting = falseprocess.stdin.on('data', (chunk) => {if (dialog) { dialogKeys(chunk); return }+ if (bottom?.browsing) {+ // Keys move through the transcript there. Esc goes back to the composer; Enter rewinds the+ // conversation to the prompt in view, which is what a message typed into it would do.+ if (chunk.includes('\r') || chunk.includes('\n')) process.stdout.write('\r\n\x1b[2K(rewound to an earlier prompt)\r\n')+ else if (chunk.includes('\x1b')) process.stdout.write('\r\n\x1b[2K\x1b[1A')+ if (chunk.includes('\x1b') || chunk.includes('\r') || chunk.includes('\n')) { bottom = null; draw() }+ return+ }for (const part of chunk.split(/(\x1b\[20[01]~|\r|\n|\x03)/)) {if (part === '\x1b[200~') { pasting = true; continue }if (part === '\x1b[201~') { pasting = false; continue }diff --git a/cli/src/lib/closeAgentService.spec.ts b/cli/src/lib/closeAgentService.spec.tsindex 9bd9030df..73323db94 100644--- a/cli/src/lib/closeAgentService.spec.ts+++ b/cli/src/lib/closeAgentService.spec.ts@@ -224,6 +224,24 @@ it('uses a known empty composer, not inactivity, to establish idle', () => {expect(inspectCloseActivity({ ...row, engine: 'claude' }, '❯\n 2 background tasks', false, false)).toBe('working')})+it('reads Codex 0.160\'s goal indicator: pursuing one is working, every other state is not', () => {+ // As 0.160 draws it with its status line on: the composer empty with its dim placeholder, and the+ // goal in magenta at the right of the status line (tui/src/bottom_pane/footer.rs).+ const screen = (goal: string) => '\u001b[1m›\u001b[0m \u001b[2mAsk Codex to do anything\u001b[0m\n\n'+ + ` gpt-5.6-sol default · /tmp/project \u001b[35m${goal}\u001b[0m`+ expect(inspectCloseActivity(row, screen('Pursuing goal (41m)'), false, false)).toBe('working')+ expect(inspectCloseActivity(row, screen('Pursuing goal'), false, false)).toBe('working')+ for (const state of ['Goal paused (/goal resume)', 'Goal stalled (/goal resume)', 'Goal hit usage limits (/goal resume)',+ 'Goal unmet (41m)', 'Goal abandoned', 'Goal achieved (41m)', 'Goal achieved']) {+ expect(inspectCloseActivity(row, screen(state), false, false), state).toBe('idle')+ }+})++it('reads Codex browsing its transcript as someone at the pane, not as idle', () => {+ const browsing = '\u001b[2m› Ask Codex to do anything\u001b[0m\n\n\u001b[36mBrowsing\u001b[0m · ↵ rewind · esc back'+ expect(inspectCloseActivity(row, browsing, false, false)).toBe('needs_input')+})+const unusedScreens = {// Prompt/footer styling observed in the unused Companions terminal; path redacted.codex: '\u001b[1m\u001b[38;5;215m›\u001b[0m\u001b[48;5;234m \u001b[2mAsk Codex to do anything\u001b[0m\n\n GPT-6-Astra max · /tmp/companions\n ? for shortcuts · 1 warning · f2 to view',diff --git a/cli/src/lib/closeAgentService.ts b/cli/src/lib/closeAgentService.tsindex a729737bd..8245762a1 100644--- a/cli/src/lib/closeAgentService.ts+++ b/cli/src/lib/closeAgentService.ts@@ -37,8 +37,12 @@ export function inspectCloseActivity(session: CloseSession, screen: string | nulif (turnOpen === true) return 'working'if (!screen) return 'unknown'const footer = stripVTControlCharacters(screen).split('\n').slice(-16).join('\n')- // Codex can be between turns of an active goal; Claude can have background tasks.- if (/\bgoal\s+active\b|\b[1-9]\d*\s+background\s+(?:tasks?|agents?)\b/i.test(footer)+ // Codex can be between turns of an active goal, and Claude can have background tasks. Codex has+ // said an active goal two ways: `◎ /goal active (41m)` in its older footers, and `Pursuing goal (41m)`+ // on its status line since (0.160, tui/src/bottom_pane/footer.rs), where only the older wording was+ // known and an agent between the turns of its goal read as idle, for a close to take. Its other goal+ // states (paused, stalled, unmet, abandoned, achieved) are not work in progress.+ if (/\bgoal\s+active\b|\bpursuing goal\b|\b[1-9]\d*\s+background\s+(?:tasks?|agents?)\b/i.test(footer)|| terminalActivity(engine, screen)) return 'working'const hold = teamWriteHold(engine, screen)if (hold === 'team_waiting_draft') return 'draft'diff --git a/cli/src/lib/runtimeProfileController.spec.ts b/cli/src/lib/runtimeProfileController.spec.tsindex 6a3b8e473..8232300c5 100644--- a/cli/src/lib/runtimeProfileController.spec.ts+++ b/cli/src/lib/runtimeProfileController.spec.ts@@ -38,6 +38,27 @@ describe('runtime pane parsing', () => {)).toMatchObject({ idle: true, draft: false })})+ it('reads Codex browsing its transcript as a modal, at every width, with or without a draft dimmed under it', () => {+ // As 0.160 draws it (tui/src/app_backtrack/prompt_navigation.rs): the composer dimmed whole, and the+ // footer row naming the mode, its keys and their actions, cut down as the pane narrows.+ const composer = '\u001b[2m\u001b[1m›\u001b[0m\u001b[2m \u001b[2mAsk Codex to do anything\u001b[0m'+ const dot = '\u001b[2m · \u001b[0m'+ const footers = [+ `\u001b[36mBrowsing transcript\u001b[0m${dot}↑↓/jk\u001b[2m scroll\u001b[0m${dot}←→/hl\u001b[2m prompts\u001b[0m${dot}ctrl + t\u001b[2m details\u001b[0m${dot}↵\u001b[2m rewind\u001b[0m${dot}esc\u001b[2m back\u001b[0m`,+ `\u001b[36mBrowsing\u001b[0m${dot}↵\u001b[2m rewind\u001b[0m${dot}esc\u001b[2m back\u001b[0m`,+ `\u001b[36mBrowsing\u001b[0m${dot}esc`,+ '\u001b[36mBrowsing\u001b[0m',+ ]+ for (const footer of footers) {+ expect(inspectRuntimePane('codex', `${composer}\n\n${footer}`), footer).toMatchObject({ idle: false, dialog: true })+ }+ // A draft is dimmed with everything else in the composer while browsing: still not a pane to type into.+ expect(inspectRuntimePane('codex', `\u001b[2m› keep this draft\u001b[0m\n\n${footers[0]}`)).toMatchObject({ idle: false, dialog: true })+ // Other engines, and Codex's own transcript text, are not read for it.+ expect(inspectRuntimePane('claude', `\u001b[39m❯\u00a0\u001b[2mAsk about the codebase\u001b[0m\n Browsing · esc`)).toMatchObject({ idle: true, dialog: false })+ expect(inspectRuntimePane('codex', ` Browsing transcript · as before\n${composer}\n\n gpt-5.6-sol default · /tmp/project`)).toMatchObject({ dialog: false })+ })+it('reads hermes, which italicises its placeholder instead of dimming it', () => {// Copied byte-for-byte off a live pane. Hermes carries no SGR 2 at all: the placeholder is// italic (3) over a 256-colour gold, so a dim-only rule read every hermes pane as holding adiff --git a/cli/src/lib/runtimeProfileController.ts b/cli/src/lib/runtimeProfileController.tsindex ecffaf83a..36ae31a63 100644--- a/cli/src/lib/runtimeProfileController.ts+++ b/cli/src/lib/runtimeProfileController.ts@@ -307,7 +307,7 @@ export function inspectRuntimePane(engine: RegisteredSession['engine'], capture:// Old picker/plan text can remain in tmux history. Only UI below the latest prompt belongs to the// current interaction; if no prompt is visible, inspect the whole capture as a conservative fallback.const currentUi = stripAnsi((promptIndex >= 0 ? rawLines.slice(promptIndex) : rawLines).join('\n')).replace(/\u00a0/g, ' ')- const dialog = DIALOG_UI.test(currentUi)+ const dialog = DIALOG_UI.test(currentUi) || (engine === 'codex' && CODEX_TRANSCRIPT_BROWSING.test(currentUi))const plan = engine === 'codex' ? /\bplan mode\b/i.test(currentUi) : /\bplan mode on\b/i.test(currentUi)const marker = stripAnsi(prompt).search(marks)let visible = marker >= 0 ? stripAnsi(prompt).slice(marker + 1).replace(/\u00a0/g, ' ').trim() : ''@@ -328,6 +328,15 @@ export function inspectRuntimePane(engine: RegisteredSession['engine'], capture:*/const DIALOG_UI = /Select Model(?: and Effort)?|Select Reasoning Level|Advanced Reasoning|Available models|Models matching|Edit Parameters|Type to filter.*Tab to edit|Esc to go back|Press enter to confirm|Do you want to proceed|Allow this action|permission required|Starting MCP servers?/i+/**+ * Codex browsing its own transcript: Esc twice on an empty composer, and its footer row reads+ * `Browsing transcript · ↑↓/jk scroll · ←→/hl prompts · … · ↵ rewind · esc back`, down to a bare+ * `Browsing` as the pane narrows (0.160, tui/src/app_backtrack/prompt_navigation.rs). The composer is+ * dimmed meanwhile, its placeholder and any draft in it alike, so it read as empty and idle: a delivery+ * typed into it lands as keys that scroll, and its Enter rewinds the conversation. A modal, then.+ */+const CODEX_TRANSCRIPT_BROWSING = /^\s*Browsing(?: transcript)?(?:\s+·|\s*$)/m+/** The rule a gutter-box composer is closed with: `╹▀▀▀▀…`. */const GUTTER_BOX_RULE = /[─▀▁▔]{8,}/udiff --git a/cli/src/teams/preflight.spec.ts b/cli/src/teams/preflight.spec.tsindex ec8b777b7..1a4887a7b 100644--- a/cli/src/teams/preflight.spec.ts+++ b/cli/src/teams/preflight.spec.ts@@ -19,3 +19,8 @@ it('recognizes the native Codex placeholder above its configurable model and tasexpect(teamWriteHold('codex', `›\n a human draft\n${footer}`)).toBe('team_waiting_draft')expect(teamWriteHold('codex', `› Keep this draft\n${footer}`)).toBe('team_waiting_draft')})++it('holds a delivery while Codex browses its transcript, where its Enter would rewind the conversation', () => {+ const browsing = '\u001b[2m› Ask Codex to do anything\u001b[0m\n\n\u001b[36mBrowsing transcript\u001b[0m · ↑↓/jk scroll · ←→/hl prompts · ↵ rewind · esc back'+ expect(teamWriteHold('codex', browsing)).toBe('team_waiting_user')+})