Skip to main content
Workflows are the foundation of Polos. They’re durable functions that survive failures, maintain state, and resume exactly where they stopped.

What is a workflow?

A workflow is a function that can contain steps, call other workflows, wait for events, and use normal programming constructs like loops and conditionals.
What makes workflows special:
  • Durable - Survive crashes and resume from the last completed step
  • Stateful - Maintain context across execution
  • Composable - Call other workflows and wait for results
  • Observable - Track execution with real-time events

Why workflows?

Traditional functions fail completely when something goes wrong. Workflows persist progress at each step: Without workflows:
With workflows:

Workflow context

Every workflow receives a context object with execution metadata and methods:

Key concepts

Steps

Steps are the unit of durability. Each step’s output is persisted when the step completes.
See Steps for details.

Workflow composition

Workflows can call other workflows or agents. They can wait for those to complete or simply trigger them as fire-and-forget.

Control flow

Use normal control flow:

Waits and events

Workflows can pause and resume:
See Waits and Events for details.

Starting workflows

Workflows can be started in three ways:

1. Invoke using API or SDK

You can also invoke multiple workflows or agents in parallel:
Note: Batch invoke cannot be called from within a workflow. Use ctx.step.batch_invoke() or ctx.step.batch_agent_invoke() when calling from within workflows. See Steps for details.

2. Scheduled execution

3. Event-triggered

Key takeaways

  • Workflows are durable functions - They survive failures and resume from the last completed step
  • Steps are the unit of durability - Each step’s output is persisted
  • WorkflowContext provides execution metadata - Access IDs, timestamps, and step methods
  • Compose workflows - Call other workflows and wait for results
  • Use normal control flow - Conditionals, loops, and parallel execution
  • Start workflows - Via API, schedule, or events