<Task> produces structured output validated against a schema and persisted to SQLite.
Schema-Driven Output
deps:
The outputSchema Prop
When a<Task> child is a React or MDX element, Smithers auto-injects a schema prop — a JSON example derived from the Zod schema:
outputSchema prop still participates in validation and cache key computation.
Validation Flow
- JSON extraction — Tries structured output, raw JSON, code-fenced JSON, then balanced-brace extraction. If none found, a follow-up prompt requests the JSON.
-
Auto-populated column stripping —
runId,nodeId,iterationare stripped before validation. The agent need not include them. - Schema validation — Extracted JSON is validated against Zod schema (if set) and Drizzle table schema.
-
Auto-retry — On failure, up to 2 retry prompts with Zod error details:
-
Persistence — On success, the row is written with
runId,nodeId,iterationauto-populated.
Auto-Populated Columns
| Column | Type | Description |
|---|---|---|
runId | string | Current run ID |
nodeId | string | Task id prop |
iteration | integer | Loop iteration (0 for non-loop tasks) |
createSmithers, stripped from agent responses, and auto-populated on write. Zod schemas should only describe business fields:
Static Mode
Tasks without anagent prop write children directly to the database, still validated against the table schema:
JSON Mode Columns
WithcreateSmithers, Zod arrays and objects are automatically stored as JSON text columns:
Combining Zod and Drizzle Schemas
With the manual Drizzle API (withoutcreateSmithers), pair a Drizzle table with a Zod outputSchema for double validation:
outputSchema validates JSON structure (including the risk range); the Drizzle table validates column types and nullability.
Next Steps
- Error Handling — What happens when validation fails after all retries.
- Patterns — Schema organization for larger projects.
- Data Model — Required columns and primary key conventions.