The AI Lab · Lab Finding
Making Deterministic Workflows using Dynamic Workflows
The map
How I will present this
- 1 · What Are Dynamic Workflows?
- 2 · Conventional uses cases — how it was announced to be run
- 3 · Unconventional uses — caching + bending it into a state machine (aka deterministic-ish workflows)
Part 1
What are workflows?
- It's just plain JavaScript that gets executed
- Claude creates these on the fly
- It's basically a whole bunch of sub agents running to get a task done
What 'a whole bunch of subagents' looks like
One task, dozens of agents

A single run fanning out 45 survey agents in parallel (Sonnet 4.6) — then reduce, synthesize, build, integrate. 139 subagents across six phases.
meta first, then agents do the work
What the javascript looks like
export const meta = {
name: 'find-flaky-tests',
description: 'Reproduce, fix, and verify a flaky test',
phases: [{ title: 'Reproduce' }, { title: 'Fix' }, { title: 'Verify' }],
}
// the body runs in an async context — await directly
phase('Reproduce')
const theory = await agent('reproduce the flake, form a theory', { schema: THEORY })
phase('Fix')
const patch = await agent(`fix it: ${theory.cause}`, { schema: PATCH })
phase('Verify')
const ok = await agent(`run the test 50× against ${patch.sha} — still flaky?`) Type the keyword
How to activate it

Type the keyword
How to activate it /2

use /effort
Part 2 — Conventional
How Anthropic wants us to use it
You don't write the JavaScript — you ask. Or say `ultracode`.
Understand by the prompt /1
“Use a workflow to dig through #incidents in Slack for the past six months and find recurring root causes where nobody has filed a ticket.”
More examples
Understand by the prompt /2
“Here's a folder of 80 resumes, use a workflow to rank them for the backend role and double-check the top ten. Interview me using the AskUserQuestion tool for a rubric.”
The vocabulary
Six patterns Claude composes

Source: Thariq, Anthropic
Save it, share it
Put a workflow inside a skill

Drop the .workflow.js next to SKILL.md — anyone who installs the skill runs the same workflow. · Source: Thariq, Anthropic
Part 3
Making it deterministic (ish)
What the model is actually handed
What Claude Sees
const { runId } = Workflow({
script?: string,
scriptPath?: string, // Important
name?: string,
args?: any, // Important
resumeFromRunId?: string, // Important
}) meta first, then agents do the work
refresher on javascript file
export const meta = {
name: 'find-flaky-tests',
description: 'Reproduce, fix, and verify a flaky test',
phases: [{ title: 'Reproduce' }, { title: 'Fix' }, { title: 'Verify' }],
}
// the body runs in an async context — await directly
phase('Reproduce')
const theory = await agent('reproduce the flake, form a theory', { schema: THEORY })
phase('Fix')
const patch = await agent(`fix it: ${args.theory.cause}`, { schema: PATCH })
phase('Verify')
const ok = await agent(`run the test 50× against ${args.patch.sha} — still flaky?`) Run 1 — Claude calls the workflow
First call: scriptPath + args
Workflow({
scriptPath: "test.workflow.js",
args: {
theory: { cause: "test order dependency" },
patch: { sha: "9f2c1a4" },
},
})
// → runId: "wf_a1b2c3" (every agent() runs, results saved) Run 2 — same data, so the cache replays
Same params, plus the runId
Workflow({
scriptPath: "test.workflow.js",
args: {
theory: { cause: "test order dependency" },
patch: { sha: "9f2c1a4" },
},
resumeFromRunId: "wf_a1b2c3", // ← the only addition
}) Why any of this matters
What does this have to do with deterministic workflows?
A deterministic workflow is a human-engineered process — not the Claude-created one.
And an engineered process means you have to know how all of this actually works.
The demo — human in the loop
A workflow a marketer would (theoretically) run
Repurpose one post → draft every channel → you approve → finalize.
Way 1 — the cache holds memory
One workflow, resumed across the turn
In-session only · minimal plumbing — just append the answer.
Way 2 — the args carry the pack
Two workflows, handed off at the gate
Durable across sessions · more plumbing — you serialize the pack.
Why resume is cheap
How the cache decides
agent(data): same input replays from the journal (0 tokens) · changed input runs live.
Syntax — the prompt, then its options
agent()
const prompt = `blah blah ${args.context}`
const agentOutput = await agent(prompt, {
schema: SCHEMA, // JSON Schema → returns a validated object
model: 'opus', // 'opus' | 'sonnet' | 'haiku'
agentType: 'code-reviewer', // custom subagent persona — e.g. 'Explore'
isolation: 'worktree', // runs in its own git worktree
})