Lesson 12 / 26
Structured Outputs Between Nodes
Contracts between steps prevent silent breakage.
Schemas as contracts
When node B depends on node A, the schema of A's output is a contract. Keep schemas small and specific: enumerations for categories, booleans for flags, numbers for amounts. Avoid free-text fields that later nodes must parse. When you change a schema, check every node that reads it, and version the workflow. Validate unusual values defensively: an enum blocks unknown categories, but a number may still be out of range.
A schema-first design
Write the contract before the prompt.
classifier output:
category: enum[billing, technical, other]
urgent: boolean
amount: number | null # parsed from text, null if absent
summary: string (<= 200 chars)
readers:
route (if/else) -> category, urgent, amount
specialist agent -> summary
logging / analytics -> all fieldsList the readers of each field
Before changing a field, look up which nodes read it; schema changes are the most common cause of broken workflows.
Quick check: Which field type is safest for a category used in routing?
- Free text
- An enumeration of allowed values
- An image
- A random number
Answer
An enumeration of allowed values — Enums make invalid values impossible.