1. Orchestration
  2. Control flow

A workflow is a fixed graph, but three things change at run time: how many times a step runs, whether it runs, and which other workflows it starts.

NeedUse
Run a step for each item of a liststep.map(...)
Leave a step out of this runava.skip(...)
Run another workflow and use its resultava.call(...)
Start another workflow and move onava.start_run(...)

​
Map

step.map(items) runs the step once per item, side by side, and gives the next step the list of results in order.

@ava.workflow
def articles():
    jobs = select_jobs()                    # returns a list
    drafts = write_article.map(jobs)        # one agent per job
    return publish_batch(drafts)            # receives the list of drafts
Rendering diagram…
OptionDefaultMeaning
max_items8Most items allowed. Raise it up to 64. A longer list fails the run; it is never cut short.
fail_fastTrueStop at the first failed item. False lets the other items finish first.
keyword argumentsPassed unchanged to every item: write_article.map(jobs, tone="formal").

Works on every kind of step. For an agent declared in the workflow: ava.agent.step.map(Signature, items).

​
Skip

Call ava.skip inside a step that has nothing to do. The step ends as skipped, with the reason shown. It is not a failure, and the run still succeeds.

@ava.step
def score(lead: Lead) -> Score:
    if not lead.qualified:
        ava.skip("Lead is not qualified")
    ...


@ava.step
def decide(score: Score | None) -> str:     # accepts None: still runs
    return "pass" if score is None else "review"
The next step’s parameterWhat happens
Accepts None (Score | None)It runs and receives None
Does not accept NoneIt is skipped too

In a map, a skipped item is left out of the list.

​
Call another workflow

@ava.workflow
def onboard():
    customer = load_customer()
    report = ava.call(credit_check, customer)        # wait for its result
    ava.start_run(send_welcome, customer)            # start it, do not wait
    return decide(report)
ava.callava.start_run
Waits for the other workflowYesNo
Gives youIts resultIts run ID
Optionstimeout=, when=when=

when= takes a step’s boolean output. When it is False, nothing starts and the step shows as skipped.

ava.start_run(send_welcome, customer, when=is_new(customer))