Fix: stopped persona/review sub-agent's play button doesn't restart it - #954
Closed
selfcontained wants to merge 3 commits into
Closed
Fix: stopped persona/review sub-agent's play button doesn't restart it#954selfcontained wants to merge 3 commits into
selfcontained wants to merge 3 commits into
Conversation
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.
Owner
Author
|
Closing — Brad reviewed and this didn't actually fix the reported problem. Reopening the idea in the inbox for another pass. |
selfcontained
deleted the
agt_ac7499dd6c6b/fix-review-sub-agent-restart
branch
August 14, 2026 02:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_eventagain. 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) aftercodex 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-promptinsideagentArgs, whichnormalizeAgentArgsForTypeextracts intoappendedSystemPromptfor 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 oncodex resume, matching the documentedcodex 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
--livedev stack: launched a realbackend-security-reviewpersona sub-agent (codex type) viadispatch_launch_persona, stopped it, and restarted it via the actual UI Resume button.› Implement {feature}placeholder — no persona, no review task, no activity.Also added/updated unit test coverage in
apps/server/test/tmux-command-builder.test.tsfor 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---liverun).🤖 Generated with Claude Code