Session Resumption
Related source files:
src/agentmux/sessions/state_store.py(infer_resume_phase),src/agentmux/workflow/phase_registry.py(per-phase resume checks)
When a pipeline is interrupted (e.g., connection loss, tmux session killed, or a user manually closes an agent pane with Ctrl-C), it can be restarted from where it left off using resume.
CLI usage
bash
agentmux resume # Interactive selection from existing sessions
agentmux resume <feature-dir-or-name> # Resume specific session by name or pathFlow
list_resumable_sessions(project_dir)scans.agentmux/.sessions/for all feature directories withstate.jsonand returns them sorted by recencyselect_session(sessions)presents an interactive menu (or auto-selects if only one exists)- For
resume <feature-dir-or-name>, non-absolute names are resolved against.agentmux/.sessions/<name>first, then<project>/<name>as a fallback infer_resume_phase(feature_dir, state)examines workflow artifacts (01_product_management/done,04_planning/plan.md,04_planning/execution_plan.yaml,06_implementation/done_*,07_review/review.md/07_review/review.yaml, etc.) together with persisted workflow state to determine the correct phase to resume into. Whenstate["phase"] == "failed", the registry walk treatsplanningas incomplete until04_planning/execution_plan.yamlexists — even if the planner already wrote04_planning/plan.yaml. That file is produced by the orchestrator only after it has successfully processedplan.yamland thesubmit_plansignal; resuming onplan.yamlalone would skip the planner and jump to later phases without a materialized execution schedule.- If
"product_manager": truein state and01_product_management/doneis missing, resume returnsproduct_management; oncedoneexists, resume falls through to normal04_planning/06_implementationinference execution_plan.yamlis used as planner-authored intent metadata during inference:needs_design: trueresumes intodesigningwhen05_design/design.mdis still missingneeds_docs/doc_filesremain planning metadata and do not create a dedicated resume phase- a passed review resumes directly into
completing
- Session identity is persisted in
state.jsonassession_name; resume reads that value and falls back todefaults.session_nameonly for legacy states that do not yet have the field - Resume hard-blocks if that recovered tmux session is still active (
tmux session <name> is still active. Detach or kill it before resuming.) - On resume, the phase is updated in
state.json,last_eventis set to"resumed", and in-flight research task statuses remain instate.jsonso they can be restarted from persisted workflow state - The launcher derives the initial tmux pane from the resumed phase via
PHASE_REGISTRYmetadata instead of reusing the original session entrypoint (product-managervsarchitect) - Orchestrator/monitor entrypoints infer the project directory from session paths under
.agentmux/.sessions/<id> - The background orchestrator explicitly re-enters the current phase before starting file/interruption sources, so resume prompt dispatch is deterministic and no longer depends on the first seeded file event
runtime_state.jsonis treated as advisory recovery data for panes/PIDs, whiletool_event_state.jsonpersists the last appliedtool_events.jsonlcursor so resume replays only unapplied tool signalsimplementingandfixingexplicitly clear the primarycoderpane before dispatch so resume never reuses an old shell after the prior coder CLI has exitedimplementation_single_coderis persisted on entering the implementing phase; on resume, the handler restores this setting so the same dispatch mode (whole-plan vs per-group) is used regardless of current agent configuration- After the resumed phase is entered and unapplied tool events are replayed, any still-dispatched research subtasks are restarted from their persisted
03_research/<type>-<topic>/prompt.mddirectories - If the prior run failed because a registered tmux agent pane disappeared, the interruption metadata in
state.jsonis cleared on resume and a fresh pane is created only when the resumed phase next needs that role