The Problem
In traditional workflows, data must be passed explicitly from one step to the next:The Solution
Shared state lets members read and write to a common state object:How It Works
1. Define State Schema
2. Declare State Access
Each member declares what it needs:3. Access State in Members
State Features
Immutability
StateManager returns new instances on every mutation:- Predictable state transitions
- No accidental mutations
- Easy to debug
- Time-travel debugging possible
Selective Access
Members only see declared keys:- Principle of least privilege
- Clear dependencies
- Prevents accidental access
- Optimization opportunities
Access Tracking
Conductor tracks all state access:- Identify unused state keys
- Optimize state schema
- Debug data flow
- Performance profiling
State Patterns
Sequential Data Building
Build up state progressively:Parallel Data Gathering
Gather data in parallel, combine later:Incremental Refinement
Refine data through multiple passes:Conditional State Updates
Update state based on conditions:State vs Member Outputs
When to use state vs accessing member outputs directly:Use State When:
- Multiple members need the same data
- Data is shared across the workflow
- You want access tracking
Use Member Outputs When:
- Data flows linearly
- Data is only used once
- Workflow is simple
State Initialization
Default Values
Dynamic Initialization
State Schema Validation
Define strict schemas with Zod validation:State Size Limits
State is stored in memory during execution:| Environment | Limit |
|---|---|
| Development | Unlimited |
| Production | 128 KB recommended |
| Maximum | 10 MB (practical limit) |
- Store references, not large payloads
- Use KV/D1/R2 for large data
- Keep state lean and structured

