Skip to main content
If you know Spring Batch, you already know 80% of Agent Workflow. This page maps the concepts.

Concept Mapping

Spring BatchAgent WorkflowWhat it is
JobWorkflowThe top-level container — a named sequence of steps
StepStep<I, O>One unit of work with input and output
ItemProcessor<I, O>Step<I, O>.execute(ctx, input)Transform input to output
JobParametersConstructor injection on StepStatic configuration passed at build time
ExecutionContextAgentContextKey-value state that flows between steps
StepExecutionStepTransition (via TraceRecorder)Per-step execution metadata (duration, status)
JobExecutionWorkflow run (via RunOptions)Top-level execution with constraints
@StepScopeStep class instantiated per workflowPer-execution bean with injected params
ExecutionContext.put() + promotionSteps.outputOf() auto-propagationShare data between non-adjacent steps
ExecutionContext.put("key", value)updateContext()ctx.mutate().with(KEY, value).build()Publish typed metadata alongside primary output
StepRunnerStepRunnerSame name, same concept — substrate for step execution
JobRepository (JDBC)CheckpointingStepRunnerCrash recovery — resume from last completed step

Data Flow Patterns

JobParameters → Constructor Injection

Spring Batch: @Value("#{jobParameters['inputFile']}") on a @StepScope bean. Agent Workflow: Constructor args on a Step class.
// Spring Batch
@Bean @StepScope
public ItemProcessor<String, String> processor(
        @Value("#{jobParameters['language']}") String language) {
    return item -> translate(item, language);
}

// Agent Workflow
Step<Object, Object> translate = new TranslateStep(chat, "French");
Same idea: static configuration injected at creation time. Agent Workflow uses plain constructors instead of Spring scoping.

ExecutionContext → AgentContext

Spring Batch: chunkContext.getStepContext().getStepExecution().getExecutionContext().put("key", value), then promote to job context for cross-step visibility. Agent Workflow: Automatic — every step’s output is auto-propagated to AgentContext under the step name.
// Spring Batch — manual put + promotion
executionContext.put("story", generatedStory);
// ... then configure ExecutionContextPromotionListener

// Agent Workflow — automatic
// Step "generate-story" returns the story.
// Any downstream step reads it:
ctx.get(Steps.outputOf("generate-story"))
No promotion listener, no manual key management. The executor handles it.

ItemProcessor chain → Step chaining

Spring Batch: CompositeItemProcessor chains processors, or step-to-step flow with ExecutionContext. Agent Workflow: .step().then().then() — output of each step is the input of the next.
// Spring Batch
@Bean
public CompositeItemProcessor<String, String> compositeProcessor() {
    return new CompositeItemProcessorBuilder<String, String>()
            .delegates(generateProcessor, editProcessor, reviewProcessor)
            .build();
}

// Agent Workflow
Workflow.define("pipeline")
    .step(generate)
    .then(edit)
    .then(review)
    .run(input);

JobRepository → CheckpointingStepRunner

Spring Batch: JobRepository persists step execution state to JDBC. On restart, completed steps are skipped. Agent Workflow: CheckpointingStepRunner does the same thing — persists step outputs to JDBC, skips completed steps on restart. Same pattern as Spring Batch’s JobRepository, but for steps that cost $5 each instead of milliseconds. Swap one @Bean:
@Bean StepRunner stepRunner(AgentStepExecutionReadRepository readRepo,
                            AgentStepExecutionWriteRepository writeRepo) {
    return new CheckpointingStepRunner(readRepo, writeRepo);
}
See Durability for the full crash-and-resume example.

What’s Different

DimensionSpring BatchAgent Workflow
Step durationMilliseconds (item processing)Minutes (full LLM agent sessions)
Step costFree (CPU only)0.010.01-5.00 per step (LLM tokens)
Data modelChunk-oriented (read-process-write)Typed I/O (any input → any output)
Flow controlSequential, split, decision (SpEL expressions)10+ primitives (branch, loop, gate, supervisor, LLM decision)
Crash recoveryJobRepository (always on)CheckpointingStepRunner (opt-in per bean)
Error handlingSkip/retry policies on chunks.onError() routing to recovery steps
Quality gatesNot built inJudgeGate with verdict feedback and retry

Step Parameterization

All 4 patterns for getting data into steps

API Reference

AgentContext, ContextKey, StepRunner, TraceRecorder