Code holds the plan
Phases, branches, Barriers, retry limits, and stopping rules live in code, where they can be reviewed and tested.
Program stability × Agent initiative
Dynamic Workflow puts orchestration in TypeScript. Order, concurrency, and stopping rules become explicit; a complete Agent Loop runs only where the task needs understanding and judgment.
WHY DYNAMIC WORKFLOW
Skills carry knowledge and strategy. When mechanical steps also live in natural language, the Agent often has to interpret the plan again as it advances. Dynamic Workflow moves that control flow into code.
Phases, branches, Barriers, retry limits, and stopping rules live in code, where they can be reviewed and tested.
agent() starts a complete ReAct Loop with tools and its own Context—not a one-shot Prompt completion.
When code consumes an Agent result, JSON Schema validates its shape before the next step runs.
CREATE & RUN
Generate a Workflow from one sentence, or run the bundled Deep Research example from the repository root.
Open the exampleTHE WORKFLOW IS CODE
Use arrays, branches, loops, and concurrency for the mechanical work. Call agent() when a step needs understanding, exploration, or judgment.
Read the Workflow API contract01 import { agent, parallel, phase } from
02 "@deerwork-ai/deer-workflow";
03
04 export const meta = {
05 name: "research-synthesis",
06 description: "Researches and synthesizes a topic.",
07 phases: [
08 { title: "Map the territory" },
09 { title: "Synthesize" },
10 ],
11 };
12
13 export default async function run(args) {
14 phase("Map the territory");
15 const signals = await parallel([
16 () => agent(`Research ${args.topic}`),
17 () => agent("Challenge assumptions"),
18 ]);
19
20 phase("Synthesize");
21 return agent(
22 `Synthesize:\n${JSON.stringify(signals)}`,
23 );
24 }