Skip to main content
Workflow state persists data across the entire workflow execution. Use state for counters, accumulators, configuration, or any data that multiple steps need to access and modify.

Defining workflow state

Create a schema for state using WorkflowState:

When to use state

Use state for:
  • ✅ Counters and accumulators
  • ✅ Progress tracking
  • ✅ Configuration set during execution
  • ✅ Data shared across multiple steps
Don’t use state for:
  • ❌ Large data (state has 1MB limit)
  • ❌ Temporary variables (use local variables)
State is saved when the workflow completes or fails.

Setting initial state during workflow invocation

You can set the initial workflow state when invoking it:
Invoke parent workflow with some initial values for its state:

Best practices

  • Do not use state to store large objects. Polos enforces a limit of 1MB (serialized JSON) on state size.
  • Use default values