Skip to main content

What is Agent Workflow?

A workflow is a sequence of steps. Each step does one thing — calls an LLM, runs a function, invokes an external agent. Steps pass data through a shared context (typed key-value pairs). The workflow compiles to a graph IR — a pure data structure that decouples definition from execution. Three runtimes are available: LocalStepRunner (in-process, zero overhead), CheckpointingStepRunner (JDBC crash recovery), and TemporalStepRunner (distributed durable execution) — same workflow code, swap a single @Bean.

Steps

Steps are the building blocks. Each takes input, does work, produces output.

Deterministic steps

Pure Java — no LLM, no cost:

LLM steps

Several flavors depending on what you’re calling:
Step typeWhat it wrapsTypical duration
ChatClientStepSingle Spring AI ChatClient callSeconds
ClaudeStepFull Claude CLI agent session (quick scripts, no trace capture)Minutes
AgentClientStepExternal agent runtime with trace capture (Claude, Gemini, etc.)Minutes
A2AStepRemote agent via Agent-to-Agent protocolMinutes
A ClaudeStep isn’t a single API call — it runs a complete agentic loop internally. The workflow sees it as one step:

Creating steps with ChatClientStep

For a single LLM call, ChatClientStep wraps a Spring AI ChatClient:

Context

Steps communicate through AgentContext — a typed key-value store that flows through the workflow:
The context is immutable — each step gets a snapshot, mutations produce a new instance. Parallel branches receive independent snapshots and merge at join points. The framework auto-populates Steps.outputOf("step-name") after each step, so any downstream step can read any prior step’s output by name. Sub-workflow context propagation: when a Workflow is used as a step inside another Workflow, its internal context mutations propagate back to the parent automatically. All updateContext() writes from nested steps are visible to downstream steps in the parent — no workarounds needed.

Your First Workflow

Output flows forward: write → editForAudience → editForStyle. Each step’s output is the next step’s input.

The Graph IR

The DSL doesn’t execute directly — it builds a WorkflowGraph. This separation enables:
  • Portable runtimes — the IR decouples workflow definition from execution. Three runners ship today: LocalStepRunner, CheckpointingStepRunner (JDBC), and TemporalStepRunner (distributed)
  • Tracing — every step transition is recorded (TraceRecorder)
  • Inspection — the graph is pure data (nodes + edges), not opaque lambdas
Control flow compiles to real graph structure: a branch is 4 nodes + 4 edges; a loop has a back-edge; parallel has fork/join nodes. All visible in traces.

Prerequisites

  • Java 21+
  • Spring AI 2.0

What’s Next

Step Parameterization

Constructor injection, input chaining, context keys — 4 patterns for getting data into steps

DSL Primitives

10+ composable patterns — branch, loop, parallel, decision, gate, supervisor

Durability

Crash recovery, checkpointing, and distributed execution

Complete Examples

9 runnable integration tests validated against GPT-4.1