1. Agent steps
  2. Agent steps

An agent step hands a task to an agent inside a workflow. You declare what goes in and what must come out. The agent does the work; Avalanche checks the output’s types and records what the agent did.

import avalanche as ava


class ExtractInvoice(ava.Signature):
    """Extract the invoice fields from the text. Convert the total to integer cents."""

    text: str = ava.InputField()
    invoice: Invoice = ava.OutputField()


@ava.agent_step(ExtractInvoice)
async def extract_invoice(text: str, *, agent: ava.Agent) -> Invoice:
    result = await agent(text=text)
    return result.outputs.invoice
Rendering diagram…

​
Signature

The signature is the contract with the agent. The docstring is the instruction. Fields say what the agent receives and what it must return.

PartWritten as
InstructionsThe class docstring
Inputname: type = ava.InputField()
Outputname: type = ava.OutputField()

Output types can be Pydantic models, lists, files. An output that does not match its type fails the step; values are never coerced.

A one-line form exists for small tasks:

Summarize = ava.Signature("document: str -> summary: str", "Summarize the document.")

​
The step function

@ava.agent_step(ExtractInvoice)
async def extract_invoice(text: str, *, agent: ava.Agent) -> Invoice:
    result = await agent(text=text)       # one call, inputs by name
    return result.outputs.invoice         # outputs by name
NameWhat it is
agentSupplied by Avalanche. Call it once per step.
result.outputsOne attribute per output field, already validated.
result.traceWhat the agent did. See Traces and evals.

The function is ordinary Python, so you can prepare inputs before the call and check the result after it.

​
Without a function

When there is nothing to prepare or check, declare the agent directly in the workflow:

@ava.workflow
def summarize_flow():
    return load_document() >> ava.agent.step(Summarize)

​
Options

@ava.agent_step(
    ExtractInvoice,
    runtime=ava.runtimes.ClaudeAgent(model="claude-haiku-5-5"),
    tools=[lookup_vendor],
    skills=[house_style],
    integrations=[crm],
    evaluations=quality,
    retries=2,
)
OptionWhat it sets
runtimeWhich agent engine and model run the step. See Runtimes.
toolsYour functions the agent may call. See Tools and skills.
skillsReusable instructions the agent can load.
integrationsOutside services the agent can use. See Integrations.
evaluationsQuality scores for the output. See Traces and evals.
retries, on_uncertainThe same as on a Python step.

​
In the UI

The agent step's definition panel

Before a run: the instructions, the fields and the model of an agent step.

The Run I/O tab of an agent step after a run

After a run: what went in and what came out, under Run I/O.