- Agent —
agentprovided; children become the prompt. - Compute — children is a function, no
agent; function is called at execution time. - Static — children is a plain value, no
agent; value is written directly as output.
<Task needsApproval> pauses before execution. For explicit decision nodes, use <Approval>.
When needsApproval and async are both set, sequence traversal can continue past the gate, but anything that explicitly depends on this task or reads its output still waits for the approval to resolve.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | (required) | Stable node identity. Must be unique within the workflow. |
output | z.ZodObject | Table | string | (required) | Output destination. Zod schema from outputs (recommended), Drizzle table, or string key. |
outputSchema | z.ZodObject | undefined | Expected agent output structure. Inferred when output is a Zod schema. When provided with a React JSX element child, a schema prop containing a JSON example is auto-injected. |
agent | AgentLike | AgentLike[] | undefined | AI SDK agent or ordered array [primary, fallback1, ...]. Agents are tried in order on retries. |
fallbackAgent | AgentLike | undefined | Single retry fallback agent. Appended to the agent chain. |
dependsOn | string[] | undefined | Explicit dependency on other task IDs. Task waits until all complete. |
needs | Record<string, string> | undefined | Named dependencies. Keys become context keys, values are task IDs. |
deps | Record<string, OutputTarget> | undefined | Typed render-time dependencies. Each key resolves from the task with the same id, or from a matching needs entry. |
allowTools | string[] | undefined | CLI-agent tool allowlist override. Supported by ClaudeCodeAgent, PiAgent, and GeminiAgent. |
key | string | undefined | Standard React key. No effect on execution. |
skipIf | boolean | false | Skip this task. |
needsApproval | boolean | false | Pause and wait for approval before executing. |
async | boolean | false | Only applies with needsApproval. When true, unrelated downstream flow can continue while approval is pending. |
timeoutMs | number | undefined | Max execution time in ms. Task fails on timeout. |
retries | number | Infinity | Retry attempts on failure. Default: infinite with exponential backoff. Set to 0 to disable. |
noRetry | boolean | false | Disable retries entirely. Equivalent to retries={0}. |
retryPolicy | RetryPolicy | { backoff: "exponential", initialDelayMs: 1000 } | { backoff?: "fixed" | "linear" | "exponential", initialDelayMs?: number }. Delay capped at 5 minutes. |
continueOnFail | boolean | false | Workflow continues even if this task fails. |
cache | CachePolicy | undefined | { by?: (ctx) => unknown, version?: string }. Skip re-execution when a cached result with matching key/version exists. |
label | string | undefined | Human-readable label for UI and metadata. |
meta | Record<string, unknown> | undefined | Arbitrary metadata on the task descriptor. |
scorers | ScorersMap | undefined | Map of scorer configs to evaluate task output after execution. See Evals & Scorers. |
memory | TaskMemoryConfig | undefined | Per-task memory integration. { recall?: { namespace?, query?, topK? }, remember?: { namespace?, key? }, threadId? }. recall injects relevant memory fragments into the prompt before execution; remember persists the task output back to memory after success. |
heartbeatTimeoutMs | number | undefined | Heartbeat monitoring timeout in ms. If the executing task does not emit a heartbeat within this window the task is considered stale and fails. Useful for long-running agent tasks to detect hangs. |
children | string | Row | (() => Row | Promise<Row>) | ReactNode | ((deps) => Row | ReactNode) | (required) | Agent mode: prompt text or JSX rendered to markdown. Compute mode: callback. Static mode: output value. With deps, a render function receiving typed upstream outputs. |
Agent mode
Typed deps
CLI tool allowlists
allowTools narrows the tool surface for supported CLI agents on a per-task basis.
allowTools={[]}disables CLI tools entirely for supported agents.- When the workflow run is started with
cliAgentToolsDefault: "explicit-only", omittedallowToolsbehaves like[]for supported CLI agents. - Task-level
allowToolsalways wins over the run-level default.
deps with needs:
Structured output with outputSchema
WhenoutputSchema is provided and children are a React element, a schema prop containing a JSON example is auto-injected. The MDX template can reference {props.schema}.
Heartbeat monitoring
UseheartbeatTimeoutMs to detect stalled long-running agent tasks. The agent must emit heartbeats periodically; if none arrive within the timeout window, the task fails:
timeoutMs — timeoutMs caps total execution time, while heartbeatTimeoutMs detects hangs mid-execution.
Compute mode
Children is a function, noagent. Called at execution time; return value becomes output. Sync or async.
continueOnFail behavior.
Static mode
Noagent, children is not a function. Value is written directly as output. deps works in static mode.
Output resolution
Theoutput prop accepts three forms:
Zod schema from outputs (recommended) — type-checked at compile time; resolved to the correct table via zodToKeyName.
getTableName() to determine storage.
Full example
Schema-driven (recommended)
Custom Drizzle table output (advanced)
createSmithers(...) as usual.
Error handling
| Scenario | Behavior |
|---|---|
Duplicate id | Throws "Duplicate Task id detected: <id>" at render time. |
Missing output | Throws "Task <id> is missing output table." at render time. |
| Agent timeout | Fails after timeoutMs. Retries if retries > 0. |
| Agent failure | Fails. Retries if retries > 0. Continues if continueOnFail. |
| Callback throws | Same retry/continueOnFail behavior as agent failures. |
| Callback timeout | Fails after timeoutMs. Retries if retries > 0. |
Agent JSON Output Extraction
WhenoutputSchema is set, the engine extracts structured JSON from the agent’s text response using a multi-strategy pipeline:
- Code fence extraction — looks for
```jsonfenced blocks and parses the content. - Balanced brace extraction — finds the outermost
{...}using brace-depth counting, handling nested objects correctly. - Last balanced JSON — if multiple JSON objects appear, the last complete one is used (agents often produce the final answer last).
outputSchema. If validation fails:
- The engine sends a retry prompt back to the agent describing the schema violation and asking for corrected output.
- This schema-validation retry happens within the same attempt (it does not consume a
retriescount). - If the agent still fails to produce valid JSON after retries, the attempt fails.
Auth Failure Circuit Breaker
If an agent returns an authentication error (e.g., invalid API key, expired token), the engine short-circuits without retrying. Auth failures are terminal — retrying with the same credentials will not produce a different result.Non-Idempotent Tool Retry Warnings
When a task is retried (viaretries or manual retryTask()), the engine checks whether non-idempotent tools (tools with sideEffect: true and idempotent: false) were called in prior attempts. If so, a warning message is prepended to the agent’s prompt on the next attempt, alerting it that certain side effects may have already occurred.
Notes
- Custom Drizzle tables must include
runIdandnodeIdcolumns. Tasks inside<Loop>additionally neediteration.createSmithers(...)adds these automatically. idis thenodeIdin the task descriptor; uniqueness is enforced at render time.- In agent mode, JSX/MDX children are rendered to markdown (not HTML) before being sent to the agent.