view source

Octomind Workflow Design & Syntax

skill

Octomind workflow .toml guide: pipeline design, sequential, parallel, loop and conditional steps, validation. Use when designing or debugging a workflow.

Apache-2.0 Requires: octomind CLI with the `workflow` subcommand. Workflows are stdin-driven; every referenced role must be an installed role or tap-agent tag.

agents that use this skill

instructions

Overview

octomind workflow <file.toml|name> is an external orchestrator: it chains octomind run --format jsonl subprocesses into a multi-step pipeline, passing outputs between steps by name. This skill covers pipeline design and the exact TOML syntax.

Mental model

A workflow is a predefined code path: you fix the steps at authoring time and the orchestrator executes them deterministically. If you cannot enumerate the steps in advance, use a single agent run instead.

Each step starts with a fresh context and knows only what its prompt template passes in. Every step name becomes a {{name}} variable holding that step's output; {{input}} is stdin.

Designing the workflow

Pattern selection

Use the fewest steps that work: every handoff is lossy.

Task shapePatternPrimitive
Fixed subtasks, each easier than the wholePrompt chainingSequential
Distinct input categories, accurate classifierRoutingConditional or graph edges
Independent subtasks known upfrontSectioningParallel
N similar items produced by an earlier stepFan-outDynamic parallel (source + match)
Output improves against clear criteriaEvaluator-optimizerLoop
Cycles or multi-way routingState machineGraph mode
Subtasks unknowable before runtimeOrchestrator-workersNot a workflow — single agent run

When to split a step

Split only when a different persona, a different model, a gate on the intermediate output, independent verifiability, or parallel speedup demands it. If a boundary's artifact is "the same content, slightly transformed", merge the steps.

Handoff contracts

Step output is an API. End every prompt with "Output only the — no preamble." Gates match substrings or regexes, so the emitting step must produce a machine-checkable sentinel:

  • Key:value tokens, never bare words: VERDICT: APPROVED, not APPROVED.
  • Both outcomes as distinct positive tokens (VERDICT: APPROVED / VERDICT: REVISE); never define one as the absence of the other.
  • Demand the exact last line in the emitting prompt and anchor with matches = '(?m)^VERDICT: APPROVED' when precision matters.
  • Test the gate on a known-good output (must match) and a known-bad one (must not).

Loops that converge

  • max_iterations 2–3; worst-case cost is iterations × calls each.
  • The critic gets a finite rubric and a binary verdict on the last line, and is told to approve when every rubric item passes.
  • With session = "continue", iteration 2+ replaces the templated prompt with the previous step's raw output.
  • Hitting max_iterations exits with the last outputs and a warning; the workflow continues. Gate on the verdict afterwards if an unapproved artifact must not ship.

Context and cost

  • Pass only the variables a step needs — usually the immediate predecessor.
  • Per-step model: cheap models for extraction, routing, formatting; strong ones for generation and evaluation. Set max_cost to bound runaway spend.

File format

toml
name        = "my-workflow"        # required
description = "Optional description"
# max_cost  = 2.5                  # USD cap, checked between steps

[[steps]]                          # sequential (default kind)
name    = "outline"                # unique across the file
role    = "writer"                # installed role or tap agent name
prompt  = """
{{input}}

Produce a structured outline. Output only the outline.
"""
session = "fresh"                  # "fresh" (default) | "continue"
timeout = 0                        # seconds, 0 = none
retries = 0                        # extra attempts on failure
# readonly = true                  # starts the agent with --readonly: no shell, no file writes, no delegation
# model = "<provider>:<model>"     # forwarded as --model
# workdir = "path"                 # resolved against the orchestrator cwd at run time
# skills = ["skill-name"]          # forwarded as OCTOMIND_SKILLS
# capabilities = ["websearch"]     # forwarded as OCTOMIND_CAPABILITIES

Unknown keys are ignored silently, so check spelling against this reference.

Step types

A [[steps]] table is sequential unless it sets exactly one of parallel, loop, or conditional to true.

KindRequiredBehaviour
Sequentialname, role, promptOne octomind run
Parallelname, ≥2 [[steps.run]]Sub-steps run concurrently; the next step waits for all
Loopname, ≥1 [[steps.run]], exit_whenSub-steps repeat until exit_when matches or max_iterations (default 10)
Conditionalname, condition, ≥1 [[steps.run]], on_match and/or on_no_matchRuns the listed sub-steps; skipped ones resolve to empty strings

Sub-steps accept the same optional fields as sequential steps; the block itself takes none, and readonly on a parallel, loop or conditional step is a parse error, so set it on each sub-step. Parallel sub-steps cannot reference each other, and their session = "continue" is ignored.

Parallel extras: count = N (N ≥ 2) on a sub-step replicates it; max_parallel caps concurrency; min_success (1..total replicas) relaxes the all-must-succeed default. Dynamic fan-out: exactly one template sub-step plus source = "<earlier step>" and match = "<regex with one capture group>". Each match spawns a branch; inside it {{<block name>}} is that branch's captured item, and the accumulated output lands under the sub-step's name.

Graph mode

Setting entry = "<step>" or any [[edges]] switches to explicit routing. Edges have from, to, and optional when (condition shape); the first matching conditional edge wins, and each node needs exactly one unconditional edge declared last. max_transitions (required) bounds total hops, and routing ends at $end. Nodes are top-level steps, never sub-steps; every step must be reachable from entry and at least one route must reach $end. Referencing an output that the current route never produced fails at run time.

Condition shape

exit_when, condition, and edge when take output (a step name; default the previous step, or the edge's from node) plus contains (substring) or matches (Rust regex); if both are set, either one passes. A condition without output on the first step fails at run time.

Variables

  • {{input}} — stdin; {{step_name}} — output of an earlier step. Names match [A-Za-z_][A-Za-z0-9_-]*; input and $end are reserved. A parallel block's name holds its joined sub-step outputs; a loop's or conditional's own name is not a variable in ordered mode, so read its sub-steps (graph mode allows both).
  • Built-in placeholders also expand: {{DATE}}, {{CWD}}, {{SHELL}}, {{OS}}, {{BINARIES}}, {{ROLE}}, {{SYSTEM}}, {{CONTEXT}}, {{GIT_STATUS}}, {{GIT_TREE}}, {{README}}.
  • A <context>path</context> or <context>path:start:end</context> block in a prompt is replaced with that file's contents.

Validation rules

Checked before any step runs: valid TOML with at least one step; unique, non-empty step names; every {{var}} resolves; each block has the shape above; regexes compile; model/workdir non-empty when set; count only on parallel sub-steps; max_cost positive. Not checked: role existence for local files (a bad role fails when its subprocess spawns) and workdir existence.

Workflows fetched from a tap may use public tap agents only. A step role is an agent tag, <ns> or <ns>:<variant>; this tap has no variants, so its workflows name base agents such as developer. A variant saved with tap(action="persist") goes to the personal tap and is a valid role in a local workflow file. A step that needs a specialty preloads its skills by bare name: role = "developer", skills = ["spec-authoring"]. --dry-run does not check skills: one that does not resolve for the step's role is dropped silently and the step still runs.

Tap workflow lint

A workflow in this tap is workflows/<name>.toml. bash scripts/lint-workflows.sh reports these codes:

  • INVALID_TOML, DRY_RUN: the file parses and passes octomind workflow <file> --dry-run.
  • NAME_MISMATCH, DESCRIPTION_LENGTH, MISSING_TITLE, TITLE_LENGTH: name equals the file stem; description is 120–155 characters; a # Title: comment of 5–60 characters.
  • NOT_LISTED: workflows/README.md lists the file; a full run also checks that the root README.md counts match the files.
  • NO_STEPS, EMPTY_STEP_NAME, RESERVED_NAME, DUPLICATE_STEP, MIXED_KIND: at least one step; unique non-empty names, none input; one kind flag per step.
  • MISSING_PROMPT, MISSING_ROLE, ROLE_FORMAT, ROLE_NOT_FOUND: each step has a prompt and a lowercase role without : that names an existing agent.
  • SKILL_NOT_FOUND, SKILL_DOMAIN_MISMATCH: each preloaded skill exists and is bound to the step's role (owned by that namespace, or listing it in domains:; a shared skill with no domains: fits any role).
  • UNKNOWN_VAR, ROUTE_VAR: each {{var}} is input, a step name or an uppercase placeholder; in graph mode its producer runs on every route to the reader.
  • CONDITION_MISSING, CONDITION_SHAPE, REGEX, CONDITION_OUTPUT: each condition sets exactly one of contains/matches, a compiling regex, and an output naming a step.
  • PARALLEL_SIZE, BRANCH_REF, MAX_ITERATIONS, MAX_TRANSITIONS, MAX_COST, READONLY_INVALID: a parallel block has two or more sub-steps; branches name sub-steps; every loop sets max_iterations of 1–3; graph mode sets max_transitions of at least 1; max_cost is positive; readonly is true or false.

CLI

bash
octomind workflow                                  # list tap workflows
octomind workflow myflow.toml --dry-run            # validate + print plan, no spawn, no stdin
echo "notes..." | octomind workflow myflow.toml    # run a local file
echo "..." | octomind workflow <name>              # run a tap workflow
echo "..." | octomind workflow myflow.toml --format jsonl   # assistant event per step + final cost event on stdout

An existing path is a local file; a missing argument containing / or ending in .toml is a file-not-found error; any other name is fetched from the taps' workflows/. stdin is required and must be non-empty unless --dry-run. Without --format jsonl stdout is empty: each step's reply, progress, and the totals go to stderr. To consume the final result programmatically, use --format jsonl and take the last assistant event; end the workflow on a sequential step, since after a parallel block the last event is one sub-step.

Inside a session: /workflow <name> <input> runs a tap workflow; agents with the orchestration capability can use tap(action="workflow").

Retries rerun the whole step — keep retries = 0 on steps whose role writes files or calls external APIs unless they are idempotent. A step fails on a non-zero exit, a timeout or an empty reply; once its retries are used the workflow stops and exits non-zero, as it does when max_cost is exceeded or a dynamic fan-out's match finds no item.

Set readonly = true on a step that only reads and reports: a scout, a judge, a verifier that opens files without running anything. A step that runs git or tests, saves a file, or stores memory keeps the default.

Examples

Generator ↔ critic loop with a sentinel contract

toml
name = "report-with-review"

[[steps]]
name   = "draft"
role   = "writer"
prompt = "<input>\n{{input}}\n</input>\n\nWrite the report. Output only the report."

[[steps]]
name           = "refine"
loop           = true
max_iterations = 3
exit_when      = { output = "critic", matches = '(?m)^VERDICT: APPROVED' }

  [[steps.run]]
  name    = "reviser"
  role    = "writer"
  session = "continue"
  prompt  = "Improve this report:\n{{draft}}\n\nOutput only the report."

  [[steps.run]]
  name    = "critic"
  role    = "writer"
  session = "continue"
  prompt  = """
Review against this rubric only: claims sourced; structure follows brief; no filler.
Critique failing items specifically. If every item passes, approve — do not invent criteria.

<report>
{{reviser}}
</report>

End with exactly one line: VERDICT: APPROVED or VERDICT: REVISE.
"""

Checklist

  • Could a single octomind run do this? Every step justified by a splitting gate?
  • Every gate matches a key:value sentinel the emitting prompt demands on its last line?
  • Loops bounded with a binary verdict and an approve-when-passing critic?
  • Every role installed (octomind complete run) and each step tested standalone?
  • --dry-run clean; result consumed via --format jsonl when scripted?

References