Skip to main content
How execution is controlled at runtime.

Signals

Signals are user-initiated events that interrupt or redirect workflow execution. They let you intervene while agents are running.
Stops execution and switches to manual mode. Use when you need to review or intervene.
Switches between manual and auto mode.
Goes back to controller view (if controller exists).
Want to know the keyboard shortcuts for signals? Check the shortcuts reference →
Signals come from the user. Directives come from agents. Both control execution, but from different sources. Learn more →

Modes

Two modes determine who drives the workflow:
You control advancement. Agents wait for you to proceed between steps and prompts.Best for:
  • Learning how workflows behave
  • Debugging issues
  • High-stakes operations requiring review
You can switch modes at any time during execution.

Who Drives the Workflow?

The actual behavior depends on three factors:
  • Mode - Manual or Auto
  • Paused - Whether you’ve paused execution
  • Agent Interactivity - Whether the agent is configured to wait for input
Auto ModePausedAgent InteractiveWho Drives
OFFYesUser
OFFNoUser (forced, with warning)
ONYESAnyUser (pause overrides)
ONNOYesController
ONNONoSystem (auto advance)
The rule: Pausing always gives you control. Auto mode only takes over when not paused.

Four Behaviors

User drives

You send input. Agent waits for you.

Controller drives

Controller agent sends input. Agent waits for controller.

Auto advance

System auto-advances. No waiting.

Forced

Agent designed to auto-advance but mode is manual. Falls back to user control with a warning.

State

Workflows move through defined states during execution. State determines what actions are available and what the workflow is waiting for.
StateMeaning
idleWorkflow has not started
runningAn agent is actively executing
awaitingWorkflow is waiting for user input
delegatedWorkflow is waiting for controller to decide
completedAll steps finished successfully
stoppedUser exited the workflow view
errorAgent directive stopped the workflow or a fatal error occurred
Want to see how states look in the TUI? Check the Agent Status Icons.

How State Changes

Starting: idlerunning During execution:
  • Agent needs input: runningawaitingrunning
  • Controller involved: runningdelegatedrunning
Ending:
  • All steps complete: runningcompleted
  • Agent directive to stop: runningerror
  • User exits workflow view: runningstopped

Recovery

Workflows are designed to survive interruptions. If the process crashes, loses connection, or terminates unexpectedly, CodeMachine can resume from where it left off.

How Recovery Works

1

Detection

On startup, CodeMachine checks if a step was running but never completed.
2

Restoration

Previous state is loaded from the persisted session.
3

Resumption

Workflow continues based on mode:
  • Auto mode: Sends continuation prompt to agent
  • Manual mode: Pauses and waits for your input

What Gets Persisted

Workflow state is continuously saved to .codemachine/template.json:
  • Current step index
  • Prompt queue progress (for chained prompts)
  • Step completion status
  • Agent session IDs
  • Monitoring IDs for logs

Recovery Scenarios

Resumes from last checkpoint.
Resumes on next workflow start.
State preserved, resume anytime.
Reconnects if session is still valid.
Recovery depends on proper session configuration. Each agent needs a unique session ID for reliable resumption. Want to know how to control workflow progress? See Manipulating Workflow Progress.

Signals vs Directives

Both influence workflow execution, but they serve different purposes:

Signals

Source: UserWhen: Anytime during executionPurpose: User interventionExamples: Pause, Skip, Stop

Directives

Source: AgentWhen: After a step completesPurpose: Agent-controlled flowExamples: Loop, Checkpoint, Trigger
Signals let you take control. Directives let agents request what should happen next.

Next Steps