Does Spring Batch Remember Between Runs? The Job Repository Keeps the Position. Not the Reasoning.
Does Spring Batch Remember Between Runs? The Job Repository Keeps the Position. Not the Reasoning. Spring Batch remembers a failed job remarkably well. It records every job instance, every execution, and every step in a job repository, and it can restart a failed job from the last committed chunk instead of the first record. What it does not record is what the work figured out. Each new run, launched with new parameters, starts its steps with a fresh execution context, and any AI step inside th
Does Spring Batch Remember Between Runs? The Job Repository Keeps the Position. Not the Reasoning.
Spring Batch remembers a failed job remarkably well. It records every job instance, every execution, and every step in a job repository, and it can restart a failed job from the last committed chunk instead of the first record. What it does not record is what the work figured out. Each new run, launched with new parameters, starts its steps with a fresh execution context, and any AI step inside the job starts with its instructions and its input, and nothing the previous run concluded.
That gap is easy to miss, because Spring Batch uses the word restart in a way that sounds like memory. Restart is about position. Agent memory is about understanding. A scheduled job can have the first in full and still have none of the second.
The job repository: a ledger of executions
The center of Spring Batch is the JobRepository, the mechanism that persists the batch metadata. With the JDBC-backed repository, that metadata lives in a set of database tables: BATCH_JOB_INSTANCE, BATCH_JOB_EXECUTION, BATCH_STEP_EXECUTION, and the execution context tables beside them. Every launch writes rows there: when the job started, which steps ran, how many items were read, written, skipped, and committed, and whether the execution finished or failed.
Identity in this system is precise. A JobInstance is a job name plus a set of identifying job parameters. Launch the same job with the same identifying parameters after it has completed, and Spring Batch refuses with a JobInstanceAlreadyCompleteException. Launch it with different parameters, for example a new date or a new input file, and it is a new instance, with its own clean metadata.
That design is deliberate. The repository exists so the framework can answer operational questions exactly: did this instance run, where did it stop, and what would a restart resume? It is a ledger of executions, maintained so work is neither lost nor processed twice.
The ExecutionContext: position, not conclusions
Inside a run, state moves through the ExecutionContext, a key-value map held on each StepExecution and on the JobExecution itself. This is where restart gets its power. Readers that implement ItemStream save their position into the step's execution context, and the framework persists that context to the repository when a chunk commits. A flat file reader, for example, stores how far it has read, so a restarted job resumes at the last committed chunk rather than the top of the file.
A restart follows strict rules. Only a failed or stopped execution can be restarted. The restart creates a new JobExecution under the same JobInstance, skips steps that already completed, and restores the failed step's execution context so its reader picks up where it stopped. Step state can also be promoted to the job-level context so later steps can read values an earlier step produced.
Read the shape of that carefully. The values in an execution context are positions, counts, and handoff values a developer explicitly chose to store. They describe where processing stopped. They do not describe what the processing meant, and nothing in the framework reads a previous completed instance's context into a new instance. Yesterday's completed job and today's new instance are strangers that happen to share a job name.
Where a scheduled AI step hits the wall
Put an AI step inside a nightly Spring Batch job, perhaps a processor that reviews each batch of records, groups them by likely cause, and drafts follow-ups. On Monday the job runs to completion. The agent works through the records, finds that a large cluster traces back to one upstream change, and deliberately leaves a handful of cases open because the evidence is incomplete.
On Tuesday the job launches with Tuesday's parameters. That is a new JobInstance. The agent receives Tuesday's records and its instructions. Monday's root-cause finding is in no execution context it can see, because Monday's context belonged to Monday's instance and held positions, not findings. The open cases look brand new. The grouping work is repeated from first principles, and it can land slightly differently, with no record anywhere of why Monday's judgment went the other way.
Nothing has failed. Spring Batch kept everything it promises to keep: instance identity, step state, committed positions, and a restartable record of failure. The missing piece was never part of its contract. An execution context is a bookmark, not a memory of the work.
The common workaround is manual plumbing. A developer adds a step that writes the agent's conclusions to a table or a file, and another step that reads them back at the start of the next run, and maintains that handoff as prompts, schemas, and edge cases evolve. For one job, that holds together. Across dozens of scheduled jobs, each with its own handoff format, the notes drift, contradict each other, and stop being trusted.
The memory layer belongs outside the batch framework
What the agent needs is a past that is read at the start of every run and written at the end of every run, regardless of which job, tool, or interface launched it.
Vilix AI provides that layer. It is cloud-hosted with zero infrastructure to run, so there is no second metadata database to install, secure, and maintain next to the job repository. The agent connects over MCP, and because that connection is the same everywhere, the memory available inside a Spring Batch job is the same memory available in a chat tool, a coding assistant, or another automation working on the same problem.
Content matters as much as access. Vilix AI keeps full conversation history, not just extracted facts, so a returning agent can recover why Monday's cluster was grouped the way it was, which explanations were considered and ruled out, and which cases were left open on purpose. Tuesday's run starts from that full context and adds to it, so the record grows with the work instead of resetting with each new job instance.
Starting small is straightforward. The free plan is free forever, and Pro includes a 7-day trial with no card required, so a single nightly job can be connected and judged on real runs. The memory stays under the operator's control, with export and deletion available at any time.
Keep Spring Batch for restart, add memory for continuity
Spring Batch remains excellent at what its repository was built for: chunk-oriented processing, skip and retry rules, exact restart from the last committed position, and protection against processing the same instance twice. Those are execution virtues, and they do not need replacing.
What they need is a counterpart. A job repository remembers where the work stopped, and how far it got. A memory layer remembers what the work learned, and why. Give a scheduled agent both, and each new job instance stops being a first day on the job.