Coding agentsBeta
Crew workflows: multi-step runs across restarts
A workflow is a list of steps the agents engine runs in order: send a message to a thread, wait for its turn, wait for a signal, sleep or watch a pull request. The engine keeps each run across restarts, so a workflow that waits overnight for your approval is still waiting after a reboot.
Use workflows in the app
- On the Crew page, switch to Threads.
- Press Workflows at the bottom of the sidebar.
- Press New workflow and paste the definition into Workflow JSON, then press Save. See Write a definition for the format.
- Right-click the workflow and choose Run…. Add Input JSON (optional) if the definition reads input, then press Run.
Selecting a workflow shows its Steps, its Triggers with Copy webhook path, and its Runs. Runs that wait on you are marked Needs you. Open one, fill in the Signal name and an optional payload under Send a signal, and press Send. Cancel run stops a run. Right-click a workflow for Edit…, Copy definition and Delete….
Write a definition
A definition is JSON with a name, an optional description and a list of steps. Every step has a type and a name.
{ "name": "fix-and-ship", "description": "Fix an issue, wait for review, then open a pull request", "steps": [ { "type": "send", "name": "fix", "provider": "codex", "cwd": "/Users/me/code/app", "text": "Fix {{input.issue}} and add a test" }, { "type": "wait_turn", "name": "fixed", "thread": "{{steps.fix.thread_id}}" }, { "type": "wait_signal", "name": "review", "signal": "approved" }, { "type": "send", "name": "ship", "thread": "{{steps.fix.thread_id}}", "text": "Commit and open a pull request" } ]}Text fields can use {{input.<key>}} for the run's input and {{steps.<name>.<field>}} for an earlier step's output. A send step without a thread starts a new thread and reports its thread_id.
Step types
| Type | Fields | What it does |
|---|---|---|
send |
text, optional thread, provider, cwd, title, output_schema |
Send a message to a thread, or start a new one |
wait_turn |
thread, optional timeout_ms |
Wait until that thread's turn ends |
wait_signal |
signal, optional channel, timeout_ms |
Wait until someone sends the named signal |
ask |
text, optional kind, schema, timeout_ms |
Ask a person a question and wait for the answer |
sleep |
ms |
Wait a fixed time |
pr_watch |
until, optional params, poll_ms, timeout_ms |
Watch a pull request until it is merged, closed, checks_passed, checks_failed or changed |
store_set |
key, value |
Keep a value between runs |
Start runs on their own
A definition can carry triggers that start runs without you: every with every_ms, daily with time_of_day and optional weekdays, or webhook with a name. List them with:
ed crew workflows hooksed crew workflows hooks fix-and-ship --jsonA webhook path holds its hook's secret, so share it only with the sender. For a single prompt on a timer, a schedule is simpler.
From the terminal
Everything above also works from the terminal, which suits scripts.
Register and start a workflow
ed crew workflows register fix-and-ship.jsoned crew workflows start fix-and-ship --input '{"issue":"the login redirect"}' --key login-fixed crew workflows start --file nightly.json --waitregister adds a definition, or replaces one with the same name. Runs already started keep the steps they started with.
start begins a run. Starting again with the same --key returns the same run instead of a second one, so a retried script never duplicates work. --file runs a definition without registering it. With --wait the command waits and exits 0 when the run completes, 1 when it fails, pauses or is cancelled, and 2 when it waits for a signal.
Watch runs
ed crew workflows lsed crew workflows ls --status waitinged crew workflows show run_01ed crew workflows wait run_01 --timeout 600ls lists runs newest first with what a live run waits on. show prints every step with its state, and the outputs once the run completes.
Answer a waiting run
ed crew workflows questionsed crew workflows signal run_01 approveded crew workflows signal run_01 choice '{"pick":"b"}'questions lists runs waiting for a signal and the signal each one needs. signal delivers it, with an optional JSON value. A signal sent before the run reaches its wait step is kept until it does.
Resume or cancel a run
A run pauses when an agent step fails. A paused run retries on its own, and resume retries the failed step now:
ed crew workflows resume run_01ed crew workflows cancel run_01cancel stops a running, waiting or paused run. A run that already ended is shown and left as it is.
Manage definitions
ed crew workflows defsed crew workflows def fix-and-ship --json > fix-and-ship.jsoned crew workflows unregister fix-and-shipunregister removes the definition and its triggers. Runs already started keep going.