- Building blocks
- Workflows
Building blocks
Workflows
A workflow is a graph of steps, declared in one Python function.
A workflow says which steps run and in what order. The function body only connects steps; the work happens inside them, when a run starts.
import avalanche as ava
@ava.workflow(input=InvoiceInput)
def process_invoice():
return (
(text := read_document(ava.input.text))
>> (extract_invoice(text) & categorize(text))
>> build_entry()
)
Rendering diagram…
Connect steps
| Write | Meaning |
|---|---|
a() >> b() | Run a, then b. b receives what a returned. |
a() & b() | Run a and b side by side. Always put the group in parentheses. |
x := a() | Name a step’s output to pass it to more than one step. |
b(x) | Pass a named output as an argument. |
ava.input.field | One field of the run input. |
Calling a step inside a workflow does not run it. It adds the step to the graph and returns a placeholder for its future output.
The steps you connect
| Step | Decorator | Use it for |
|---|---|---|
| Python step | @ava.step | Rules, calculations, API calls, saving results |
| Agent step | @ava.agent_step | Reading, research, drafting, extraction |
| Classifier step | @ava.classifier_step | Labels, yes/no probabilities, scores |
Options
@ava.workflow(
input=InvoiceInput, # typed run input
cron="0 6 * * 1", # run on a schedule
webhook=True, # start a run from an HTTP request
agent_defaults={...}, # one runtime for every agent step
classifier_defaults={...}, # one provider for every classifier step
)
def process_invoice(): ...
| Option | What it does |
|---|---|
input | A model that every run’s input is checked against. |
cron | A cron expression. The workflow then has a schedule. |
webhook | True, or ava.Webhook(path=...). The workflow then has a URL that starts runs. |
key | Input fields that identify a run, such as ("invoice_id",). One run per key. |
agent_defaults | The runtime agent steps use unless they set their own. |
classifier_defaults | The provider, model and timeout classifier steps use. |
In the UI

Each step is a card. Agent and classifier steps are labelled.
