Skip to main content

Workflow Quickstart

Standalone smithers-orchestrator quickstart example. A planner task feeds a briefing task through persisted workflow output.

Source

/** @jsxImportSource smithers-orchestrator */
// workflows/quickstart.tsx
import { createSmithers } from "smithers-orchestrator";
import { ToolLoopAgent as Agent, Output } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";

const planSchema = z.object({
  summary: z.string(),
  steps: z.array(z.string()).min(3).max(8),
});

const briefSchema = z.object({
  brief: z.string(),
  stepCount: z.number().int().min(1),
});

const { Workflow, Sequence, Task, smithers, outputs } = createSmithers({
  plan: planSchema,
  brief: briefSchema,
});

const planAgent = new Agent({
  model: anthropic("claude-sonnet-4-5-20250929"),
  output: Output.object({ schema: planSchema }),
  instructions:
    "You are a planning assistant. Return a concise summary and 3-8 actionable steps.",
});

const briefAgent = new Agent({
  model: anthropic("claude-sonnet-4-5-20250929"),
  output: Output.object({ schema: briefSchema }),
  instructions:
    "You are a concise technical writer. Produce a 5-8 sentence brief.",
});

export default smithers((ctx) => {
  const planOutput = ctx.outputMaybe(outputs.plan, { nodeId: "plan" });

  return (
    <Workflow name="quickstart">
      <Sequence>
        <Task id="plan" output={outputs.plan} agent={planAgent}>
          {`Create a short plan for this goal:\n${ctx.input.goal}`}
        </Task>
        <Task id="brief" output={outputs.brief} agent={briefAgent}>
          {`Goal: ${ctx.input.goal}
Plan summary: ${planOutput?.summary ?? "pending"}
Steps: ${JSON.stringify(planOutput?.steps ?? [])}

Write a brief based on the plan. The "stepCount" must equal the number of steps.`}
        </Task>
      </Sequence>
    </Workflow>
  );
});

Running

bunx smithers-orchestrator up workflows/quickstart.tsx --input '{"goal": "Build a CLI tool for managing dotfiles"}'
[quickstart] Starting run def456
[plan] Done -> { summary: "Build a dotfile manager CLI", steps: ["Parse config", "Symlink files", "Add backup"] }
[brief] Done -> { brief: "This plan covers 3 steps...", stepCount: 3 }
[quickstart] Completed

Notes

  • Cross-task data flowctx.outputMaybe(outputs.plan, { nodeId: "plan" }) reads the planner’s persisted output. ctx.outputMaybe accepts either a schema key string like "plan" or the schema object from outputs.
  • Shared schemas — The same Zod schemas are reused by createSmithers(...) and Output.object({ schema }), so task persistence and agent output stay aligned.
  • Vercel AI SDKToolLoopAgent and Output are exported from ai, and the agent constructor accepts { model, output, instructions }.