Skip to content

Fix: stopped persona/review sub-agent's play button doesn't restart it - #954

Closed
selfcontained wants to merge 3 commits into
mainfrom
agt_ac7499dd6c6b/fix-review-sub-agent-restart
Closed

Fix: stopped persona/review sub-agent's play button doesn't restart it#954
selfcontained wants to merge 3 commits into
mainfrom
agt_ac7499dd6c6b/fix-review-sub-agent-restart

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Problem

Clicking the play (Resume) button on a stopped persona/review sub-agent (REVIEW badge) appeared to do nothing — the tmux session came back and the codex process reattached to its old session, but with no prompt, so the agent just sat idle at its input line, never calling dispatch_event again. From the UI it's indistinguishable from the click being a no-op.

Root cause

buildAgentCommand's Codex resume branch (apps/server/src/agents/tmux/command-builder.ts) only re-applied CLI flags (MCP config, model, passthrough args) after codex resume <sessionId> — it never rebuilt/appended the startup prompt, unlike the non-resume branch and unlike OpenCode/Cursor's resume branches, which both already re-send their startup prompt on resume.

A persona/review sub-agent's entire identity + task lives in --append-system-prompt inside agentArgs, which normalizeAgentArgsForType extracts into appendedSystemPrompt for non-Claude CLI types. Codex resume dropped that content entirely.

This also silently affected regular (non-persona) Codex sub-agents in the same way — they lost launchGuidance/personality on every resume too, just less visibly, since they already have full conversation context and don't strictly need a fresh instruction to keep going.

Fix

Build the same startupPrompt (launchGuidance + appendedSystemPrompt + personalityPrompt + initialPrompt) used by the non-resume branch, and append it as the trailing [PROMPT] positional after the session id on codex resume, matching the documented codex resume [OPTIONS] <SESSION_ID> [PROMPT] syntax and mirroring how OpenCode/Cursor already handle resume.

Also updates the Personalities docs page, which previously described "Codex on resume doesn't get a new prompt" as expected behavior.

Verification

Reproduced live against an isolated --live dev stack: launched a real backend-security-review persona sub-agent (codex type) via dispatch_launch_persona, stopped it, and restarted it via the actual UI Resume button.

  • Before the fix: resumed tmux pane showed only the bare › Implement {feature} placeholder — no persona, no review task, no activity.
  • After the fix: same restart re-sends the full persona/review prompt; the resumed agent immediately re-reads its review assignment and continues working (confirmed via screenshot + tmux pane capture).

Also added/updated unit test coverage in apps/server/test/tmux-command-builder.test.ts for the resume-with-prompt behavior.

All checks pass: pnpm run check, pnpm run finalize:web, pnpm run test (2733+842+60 tests), pnpm run test:e2e (180 passed, 12 skipped as expected for non---live run).

🤖 Generated with Claude Code

Codex's resume branch in buildAgentCommand only re-applied flags
(MCP config, model, passthrough args) after `codex resume <sessionId>`
— it never rebuilt or appended the startup prompt the way the
non-resume branch, and OpenCode/Cursor's resume branches, already do.

For a persona/review sub-agent, its entire identity and task live in
`--append-system-prompt` inside agentArgs, which normalizeAgentArgsForType
extracts into appendedSystemPrompt for non-Claude CLI types. On restart,
Codex resume dropped that content entirely: the process came back alive
and attached to its old session, but sat at a blank input prompt with no
persona, no review target, and no instruction of any kind — indistinguishable
from "the play button did nothing" to anyone watching the UI, since the
agent never calls dispatch_event again without a new prompt to act on.

Confirmed live: launched a real backend-security-review persona agent
(codex type), stopped it, and restarted it. Before the fix the resumed
tmux pane showed only the bare `› Implement {feature}` placeholder — no
persona, no task. After the fix, the same restart re-sends launchGuidance
+ appendedSystemPrompt + personalityPrompt, and the resumed agent
immediately re-reads its review assignment and continues.

This also fixes regular (non-persona) Codex sub-agents in the same way
— they were silently losing launchGuidance/personality on every resume
too, just less visibly since they don't need a fresh instruction to
have context to act on.

Updates the docs page that previously described this as expected
"Codex on resume doesn't get a new prompt" behavior, since it no longer
does.
…t to persona/review agents only

Two review findings from the initial fix:

1. (backend-security-review, release-readiness-review) Resuming a
   persona/review agent whose identity+task pushes the resume command
   past ~16KB now fails outright — tmux/imsg rejects a single argv
   entry over that size with "command too long". The restart path was
   the only launch path handing its command to tmux inline; fresh
   launch already avoided this by writing a setup script to disk and
   running `bash <path>`. Fixed at the root: `prepareLaunch` now writes
   both payload kinds (`setup-script` and `agent-command`) to disk and
   runs them the same way, removing the size limit entirely rather than
   just shrinking what gets sent.

2. (release-readiness-review) Resending the full launch prompt on every
   Codex resume was too broad: it silently submitted a new turn on
   every ordinary restart (re-processing launch guidance/autoReview
   directives an agent already has), and specifically re-ran job agents
   against a stale job run id with no job MCP tools threaded through —
   job agents also carry their prompt via --append-system-prompt in
   agentArgs but are role "standard", not "review". Narrowed the resume
   gate from "has appendedSystemPrompt" to "role === 'review'", and
   trimmed the resent content to just the persona/review identity/task
   plus a short note not to redo already-finished work, dropping
   launchGuidance/personality/initialPrompt from the resume payload
   entirely.

Verified live: resumed a persona/review codex agent with a synthetic
20KB prompt (tmux session stayed alive, script file confirms the full
payload), and confirmed a simulated job-agent resume (role standard,
--append-system-prompt present) stays a no-op exactly as before this
fix.
Non-blocking follow-up from review 687/#1459: prepareLaunch now writes
the agent-command payload to /tmp/dispatch_setup_<id>.sh (same as
setup-script) instead of embedding it inline, but only the fresh-launch
path ever cleaned that file up (completeSetup, fired by the setup
script's own callback). A restart has no such callback, so every
resumed persona/review agent left its full identity/task prompt sitting
in world-readable /tmp indefinitely.

startAgent now unlinks the script right after runtime.launch() resolves
— by then the fast-fail check has already confirmed the pane didn't
die, meaning bash is already past reading the script into the
long-running CLI process.
@selfcontained

Copy link
Copy Markdown
Owner Author

Closing — Brad reviewed and this didn't actually fix the reported problem. Reopening the idea in the inbox for another pass.

@selfcontained
selfcontained deleted the agt_ac7499dd6c6b/fix-review-sub-agent-restart branch August 14, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant