Skip to content
deterministic · crash-safe · harness-agnostic

defineworkflow,
under the hood

A workflow is a plain JS/TS script that orchestrates coding-agent calls — agent(), parallel(), pipeline() — on any harness you choose. Run the same script on Claude, Codex, Copilot, or the raw API — and mix them in a single run, one agent on Codex, the next on Claude. Underneath, every result is journaled by sequence number, so a run replays from a checkpoint without re-invoking the model.

schemacoreadapterscli
research-bugs.workflow.ts
import { agent, defineWorkflow, parallel, phase } from "defineworkflow"

export default defineWorkflow({
  name: "research-bugs",
  description: "Find bugs across the codebase, then verify each one",
  harness: "claude",
  phases: [{ title: "Find" }, { title: "Verify" }],

  async run() {
    phase("Find")
    const found = await agent("List suspicious files.", { schema: BUGS })

    phase("Verify")
    const checked = await parallel(
      found.bugs.map((b) => () =>
        agent("Is this real? " + b.desc, { schema: VERDICT })),
    )

    return checked.filter(Boolean).filter((v) => v.real)
  },
})

Built from the source of @workflow/{schema,core,adapters,cli,ui}.