What is a workflow?
A workflow is a Python function decorated with@workflow. It receives a WorkflowContext (ctx) and your input data.
ctx.step.run("search_web", search_web, input.topic) tells Polos to execute search_web (a regular Python function) as a durable step. If the workflow crashes and replays, completed steps are skipped.
Step: The unit of durability
Steps are how Polos achieves durability. Each step has a unique step key (like"search_web" or "generate_report"). When a workflow replays after a failure, Polos checks which steps already completed and skips them.
What should be a step?
- ✅ External API calls (OpenAI, Stripe, databases)
- ✅ Non-deterministic operations (LLM calls,
time.time(),random()) - ✅ Side effects (sending emails, charging cards, writing to DB)
Workflow composition
Workflows can invoke other workflows. The parent suspends while children execute - no compute is consumed during waits.Waiting
Workflows can pause for time or events. Workers suspend during waits consuming no compute.Starting workflows
Workflows can be triggered in three ways: 1. Direct invocationKey takeaways
- Workflows are durable - they survive failures and resume from the last completed step
- Steps are the unit of durability - use them for API calls, side effects, and non-deterministic operations
- Step keys must be unique per execution
- Workers suspend during waits (child workflows, events, timeouts) - no compute consumed