Workflow runs
A workflow is a YAML file of stages, each stage one or more headless profile runs. agentihooks workflow run walks the stages from the head to the exit, saves the run state after every stage and prints that state as one JSON object. agentihooks workflow status reads the saved state without launching anything, and agentihooks workflow resume continues a saved run from the stage it stopped at.
Use it to chain profiles unattended, for example scouts, a judge, a planner and an engineer, with retry loops between them. list, show and validate read and check workflow files without running them.
Usage
agentihooks workflow list
agentihooks workflow show NAME
agentihooks workflow validate FILE|NAME
agentihooks workflow run NAME --case FILE [--run-id ID] [--harness auto|claude|codex]
agentihooks workflow status RUN
agentihooks workflow resume RUN
| Command | What it does |
|---|---|
list | Prints every loaded workflow as name, layer and file, tab separated; invalid files are reported on stderr and set exit 1 |
show NAME | Prints one workflow with every default filled in, headed by its layer and file |
validate FILE\|NAME | Checks a file path, or a loaded name; prints valid: <name> (<path>) or each error |
run NAME | Starts a new run of a loaded workflow and drives it to passed or exhausted |
status RUN | Prints the saved state of a run; never launches a profile |
resume RUN | Continues a saved run with its saved definition and harness |
run flags:
| Flag | Default | Meaning |
|---|---|---|
NAME | required | Workflow name, as list prints it |
--case FILE | required | Text file holding the case: the request every stage receives |
--run-id ID | 32 hex characters | Name of the run folder; one path component, never empty, ., .. or containing / |
--harness | auto | claude or codex for every stage; auto reads AGENTIHOOKS_TARGET and falls back to claude |
Examples
List what is loaded, check a draft and run it:
agentihooks workflow list
agentihooks workflow validate ./review.yaml
printf 'Add a --dry-run flag to the cleanup command.\n' > case.txt
agentihooks workflow run simple-workflow --case case.txt --run-id cleanup-dry-run
Read the result in a script:
if report=$(agentihooks workflow run simple-workflow --case case.txt --harness codex); then
jq '{run, runs}' <<<"$report"
else
jq -r '.error // "\(.status) \(.action)"' <<<"$report"
fi
Check on a run from another shell, and continue it after the process was killed:
agentihooks workflow status cleanup-dry-run | jq '{status, stage, runs}'
agentihooks workflow resume cleanup-dry-run
A live two stage run on Codex, recorded on the delivering pull request (#7785), with workflow, run, case and definition left out:
{"stage": null, "status": "passed", "iterations": 0, "visit": 1,
"runs": {"first": 1, "second": 1},
"outputs": {"first": ["{\"verdict\":\"pass\",\"proof\":\"workflow commands\"}"],
"second": ["{\"verdict\":\"pass\",\"proof\":\"workflow commands\"}"]},
"notes": null, "action": null, "harness": "codex"}
status and resume on that run both exited 0 and printed the same JSON; resume launched nothing because the run had already passed.
Workflow files
A workflow file is block style YAML with two keys, workflow and stages. Flow style ({...} or a non-empty [...]) and unknown keys are refused. The package ships simple-workflow:
workflow:
name: simple-workflow
intent: Build the change the case asks for, backed by scouted evidence and a blind verdict.
head: scout
max_iterations: 3
exit: build-verdict.pass
on_exhausted: block
stages:
scout:
profile: scouter
count: 3
input:
- case
iterations: 2
exit: every point of the case has cited evidence
next:
pass: evidence-verdict
evidence-verdict:
profile: judge
input:
- case
- scout
next:
pass: plan
retry: scout
enhance: scout
(The shipped file continues with plan, build and build-verdict, and writes every default out.)
workflow keys:
| Key | Default | Meaning |
|---|---|---|
name | required | Name used by show, validate and run |
intent | required | One line saying what the workflow is for |
head | required | First stage; every stage must be reachable from it |
exit | required | When the workflow passes: <stage>.pass, or a condition in plain words (see Exit conditions) |
max_iterations | 3 | retry and enhance edges counted per run; the edge that reaches this number is not followed and ends the run exhausted |
on_exhausted | block | block, escalate or keep-best; recorded as action in an exhausted run |
Stage keys:
| Key | Default | Meaning |
|---|---|---|
profile | required | Profile each run of the stage uses |
tier | high | Model tier, high or low (Model tiers) |
effort | medium | Effort passed to the profile run |
count | 1 | Profile runs started in parallel for this stage |
input | [] | Earlier stages whose outputs this stage receives; case may be listed and is always sent |
filters | [] | Filter names carried in the definition; the command line runner does not apply them |
iterations | 1 | Times the stage may run in a row while its own exit is not met |
exit | null | Stage condition; null takes the launch outcome as is |
next | all null | Target stage, exit or null for each outcome pass, retry and enhance |
validate refuses a head or next target that is not a stage, an input that is neither case nor a stage, a <stage>.pass exit naming no stage, and a stage the head cannot reach.
Layers
Workflows load from these folders, in order; a later file with the same name wins:
| Layer | Folder |
|---|---|
package | workflows/ in the installed package profiles (profiles/package/workflows) |
bundle, shared-bundle, user-bundle | workflows/ in each linked bundle |
profile:<name> | workflows/ in each profile of the active chain |
project | .agentihooks/workflows/ at the root of the git repository holding the current directory |
Files end in .yaml or .yml. list, show and validate read all six kinds of layer. run reads every layer except project, and refuses to start when any loaded file is invalid.
How a run works
runcreates<AGENTIHOOKS_HOME>/workflows/runs/<run>/with an emptyoutputs/, and savesworkflow.jsonholding the start state, the case text, the full definition and the harness.- The current stage receives one JSON object:
{"case": <case text>}plus, for each stage named in itsinputthat has run, that stage’s outputs under its id. The object is the--inputprompt ofcountparallel headless profile runs with the stage’s profile, tier and effort, a 900 second timeout and no schema. - The stage outcome is
passwhen every profile run reportsok, andretryotherwise. Its outputs are the list of each run’soutput. - The stage’s own
exit, when set, can turn the outcome intopass. When it is not met and the stage has iterations left, the same stage runs again. On its last iteration the launch outcome stands, so an unmet stageexitstill moves on when every profile run reportedok. - When the workflow
exitis met the run endspassed. Otherwise the outcome’snextedge picks the next stage; anexittarget ends the runpassed. Eachretryorenhanceedge counts one iteration and stores the outcome and outputs innotes; the edge that reachesmax_iterationsends the runexhaustedwithactionset toon_exhaustedinstead of being followed. The command line launcher only producespassandretry, soenhanceedges validate but are never taken. workflow.jsonis written after every stage through a temporary file, fsync and rename, so a crash never leaves a partial state file.
resume loads workflow.json and repeats steps 2 to 6 from the saved stage. It uses the definition and harness saved at run, so later edits to the workflow file or a deleted case file do not affect it. A stage that was interrupted before it finished runs again from the start. A finished run is printed as saved and launches nothing.
Exit conditions
| Expression | Met when |
|---|---|
<stage>.pass as the workflow exit | That stage’s outcome is pass |
Plain words as the workflow exit | A stage outcome is pass and a low tier headless classifier judges the condition true over every stage’s outputs so far |
Plain words as a stage exit | The classifier judges the condition true over that stage’s outputs |
The classifier is one sealed headless run per check at low tier and low effort, two when the first reply does not match its schema. It ignores --harness: it runs on AGENTIHOOKS_TARGET, else Claude, and falls back to Claude when Codex refuses the route.
Scheduled runs
agentihooks timer add, stopwatch start and cron add start a run when they fire with --workflow NAME --case FILE. The project is the folder the command ran in. The slot’s placement field says where the run starts:
| Placement | Set with | Where the run starts |
|---|---|---|
local | the default, or --placement local | a detached run on the machine that delivers the slot, in the project folder |
hive | --placement hive [--needs NAME,NAME] | a live hive that is not draining, lists the project repository and declares every name in needs; among those, the hive with the fewest unfinished run orders, ties by hive id |
A hive placement sends the chosen hive one run order and starts nothing locally. When no hive fits, the delivery sends nothing and records the reason under its delivery id in the run placement waits, `no live hive lists the repo