01 · Before and afterThe pattern
// before: reads whatever agent is open *now*, after each await
for (const batch of batches) await apply(currentAgent(), batch);
// after: pin the target once, and tell "nothing to do" apart from "failed"
const target = currentAgent();
for (const batch of batches) {
const r = await apply(target, batch); // { ok: true, value } | { ok: false }
if (!r.ok) break; // a no-op keeps going
}02 · Run it on your appThe check
If a user switches pages while a multi-step save is running, does every remaining step still write to the record they started on?
If the honest answer is no or not sure, this is worth a look before it reaches production.