Skip to main content
Any Runnable works as a workflow step, including Agents. Use agents inside workflows when you want LLM reasoning at specific points in an otherwise deterministic pipeline, or when a classifier agent routes to specialist agents.

Agent as a single step

The agent’s output (typically a Message) is the workflow output.

Passing inputs through the workflow

Expose agent params as workflow-level inputs by leaving them unbound on the step:
Steps with fixed kwargs in .step(...) hide those params from the workflow schema. Steps without defaults for a param surface it on the workflow.

LLM routing (classify → specialist)

Use a lightweight classifier agent, then branch with when:
Only the matching specialist runs. See Conditional Routing for a function-based variant.

Agents + plain functions

Mix deterministic steps with agents in one pipeline:
See Sequential Steps for a full document pipeline.

Nested workflows with agents

An inner workflow can contain agents; the outer workflow treats it as one step:

When to use an agent vs a workflow

  • One agent with tools — the model picks tools dynamically; good for open-ended tasks.
  • Workflow with agent steps — you control which LLM runs when; good for staged pipelines, cost control, and auditability.
  • Workflow without agents — pure data/code; fastest and cheapest.

See also