<Task> is the fundamental unit of work in a Smithers workflow. Every task has a unique id and an output destination. Tasks operate in one of three modes:
- Agent mode — when
agentis provided, children are rendered to markdown text and sent as the prompt to the AI agent. - Compute mode — when children is a function (
() => Rowor() => Promise<Row>) and noagentis provided, the function is called at execution time and its return value is used as the output. - Static mode — when children is a plain value and no
agentis provided, children are treated as the literal output payload and written directly to the database.
Import
Props
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | (required) | Stable node identity. Must be unique within the workflow. Duplicate ids throw an error at render time. |
output | Table | string | (required) | Where to store the task’s result. Pass a Drizzle table object directly, or a string key that resolves via the schema registry. |
outputSchema | z.ZodObject | undefined | Optional Zod schema describing the expected agent output structure. When provided with a React element child, the schema example is auto-injected via a schema prop. |
agent | AgentLike | undefined | An AI SDK agent. When present, the task runs in agent mode and children become the prompt. |
key | string | undefined | React key for the element (standard React prop). |
skipIf | boolean | false | When true, the task is skipped during execution. |
needsApproval | boolean | false | When true, the runtime pauses before executing and waits for approval. |
timeoutMs | number | undefined | Maximum execution time in milliseconds. The task fails if it exceeds this duration. |
retries | number | 0 | Number of retry attempts on failure before the task is marked as failed. |
continueOnFail | boolean | false | When true, the workflow continues executing subsequent tasks even if this task fails. |
label | string | undefined | Human-readable label for UI display and metadata. |
meta | Record<string, unknown> | undefined | Arbitrary metadata attached to the task descriptor. |
children | string | Row | (() => Row | Promise<Row>) | ReactNode | (required) | In agent mode: the prompt text or JSX that renders to markdown. In compute mode: a callback function invoked at execution time. In static mode: the output object or value. |
Agent mode
When theagent prop is provided, the task sends its children as a prompt to the AI agent and stores the agent’s response in the output table.
Children can be a plain string, a template literal, or a React/MDX element. In all cases, children are rendered to plain markdown text before being passed to the agent.
Structured output with outputSchema
When you provideoutputSchema and your children are a React element, Smithers auto-injects a schema prop into the element containing a JSON example derived from the Zod schema. This lets your MDX prompt template reference {props.schema} to show the agent the expected output format.
AnalysisPrompt MDX component, props.schema is available as a JSON example string that matches the Zod schema shape.
Compute mode
When children is a function and noagent prop is provided, the function is called at execution time (not render time) and its return value becomes the task output. This is useful for running shell commands, calling APIs, performing data transformations, or any deterministic operation that doesn’t need an LLM.
The callback can be synchronous or asynchronous. All task props (timeoutMs, retries, continueOnFail, needsApproval, skipIf) work with compute callbacks.
timeoutMs is set, the callback is raced against a timeout.
Static mode
When noagent prop is provided and children is not a function, children are treated as the output payload and written directly to the database. This is useful for seeding data, passing constants between tasks, or producing computed output without calling an AI model.
staticPayload field of the task descriptor.
Output resolution
Theoutput prop accepts two forms:
Drizzle table object (manual API) — pass the table directly. The runtime calls getTableName() to determine the storage destination.
Full example
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 | Task fails after timeoutMs milliseconds. Retries if retries > 0. |
| Agent failure | Task fails. If continueOnFail is true, subsequent tasks still execute. If retries > 0, the task is retried up to that many times. |
| Compute callback throws | Task fails. Follows the same retry and continueOnFail behavior as agent failures. |
| Compute callback timeout | Task fails after timeoutMs milliseconds. Retries if retries > 0. |
Notes
- Output tables must include
runIdandnodeIdcolumns. Tasks inside a<Ralph>loop additionally need aniterationcolumn. - The
idprop is used as thenodeIdin the task descriptor and must be unique across all tasks in the workflow. This uniqueness is enforced at render time. - In agent mode, the prompt is the final rendered string after all JSX/MDX has been converted to markdown. The rendering uses custom markdown components that produce clean text output (not HTML).
- The
keyprop is a standard React prop and does not affect Smithers execution semantics.