Your AI batch results are ready, but some drafts are unusable and your importer stopped halfway through. Resubmitting everything leaves you with another question: which outputs have already reached the destination?
The useful unit of recovery is the individual business task. For a document workflow, that might be an editable summary attached to a particular document revision. Before retrying, establish what was submitted, what came back, what passed your checks and what was actually saved.
This article uses Anthropic Message Batches as a concrete example. The tracking and import design below is our recommendation for your application, rather than a guarantee supplied by the API. For the broader setup, see our practical guide to using AI through an API.
Separate completion from acceptance
Anthropic's batch retrieval reference describes an idempotent endpoint for polling completion and a results_url for retrieving outputs. A completed provider job still leaves your application with acceptance and import decisions.
Consider a hypothetical contract-summary workflow. The requested output is an editable draft containing the parties, renewal clause and supporting passages. It does not amend a contract, send an email or update a customer record. A returned draft that names the wrong legal entity must be isolated even if the provider processed the request successfully.
Use separate local states for provider outcome, validation outcome and destination write. A task can therefore be succeeded, rejected and not_written at the same time. Another can be succeeded, accepted and write_unknown because the database connection disappeared after a save was attempted. Those situations need different recovery actions.
Define these distinctions before an operator sees a Retry button. Otherwise, a label such as “failed” hides whether the team should change the prompt, repair an import or wait for a temporary provider problem.
Reconcile AI batch results by identity
Anthropic's results reference specifies JSONL output: each line contains an individual result. It warns that result order may differ from request order and instructs developers to match results using custom_id, which must be unique within a batch.
Build a submission manifest before sending the work. Our recommended manifest links the provider batch ID and custom_id to the internal task, source revision, prompt version and attempt. Keep the business task identity stable across attempts; give each attempt its own traceable record. The provider's within-batch uniqueness rule does not establish your application's identity across batches.
For example, a local task named contract-renewal-draft could reference document supplier-agreement, revision revB. Its attempt record maps to the submitted custom_id. If the source changes to revC before import, hold the old draft for review instead of silently attaching it to the revised agreement.
During reconciliation, compare received identities with the manifest. Quarantine an unknown identity or a conflicting duplicate. Mark an expected but absent result as unresolved and check that the result download completed before deciding it needs another model call. An interrupted download is a retrieval problem; it does not prove the underlying request failed.
Give each outcome a specific next action
Anthropic's batch reference distinguishes succeeded, errored, canceled and expired results. Use those provider outcomes as inputs to a local decision table, alongside validation and write evidence. The actions below are our proposed operating policy.
| Evidence for the task | Local decision | Next action |
|---|---|---|
| Successful output, valid draft, no destination write | Accept | Save through the controlled importer |
| Successful output, missing renewal passage | Isolate | Review extraction instructions and source before another attempt |
| Error identifying an invalid request | Repair | Correct the request; do not replay it unchanged |
| Error judged temporary after inspection | Retry candidate | Resubmit under the approved attempt and spend limits |
| Canceled or expired result, work still required | Retry candidate | Confirm source revision and operator intent first |
| Accepted result with a confirmed destination record | Complete | Exclude it from further imports and model retries |
| Accepted result with an uncertain write | Reconcile destination | Look up the task key before attempting another save |
Cancellation deserves particular care. Anthropic says a batch enters canceling and may finish in-progress, non-interruptible requests before cancellation is finalized. Consequently, reconcile the eventual item results rather than assuming every request was canceled. If the operator canceled because the source contained sensitive material, renewed processing needs an explicit decision; technical eligibility alone is insufficient.
Make a repeated import harmless
A provider result ID and a local commit record answer different questions. Your importer needs durable evidence that an accepted result produced its intended destination record.
For a database-backed draft store, our recommendation is a uniqueness constraint on the logical output key, plus a transaction that saves the draft and marks its import committed together. A possible key combines task identity, source revision and output purpose. Store the accepted result reference too, so a competing attempt cannot silently overwrite a draft someone has reviewed.
On replay, a matching committed record is a no-op. A different result for the same output key becomes a conflict for review. Decide explicitly whether a revised prompt creates a new draft version or replaces an unreviewed draft; either choice must preserve the history needed by your team.
This design requires adaptation when the destination is an external system. A local transaction cannot make a remote write atomic. Use the destination's documented deduplication or lookup capabilities where available, and leave uncertain writes pending reconciliation. Our guide to webhook retries and duplicate events explains the related problem of handling repeated delivery.
Build retries from unresolved tasks
Generate a retry manifest from reconciled task records. Do not reconstruct it by selecting everything in the original input file. Include the previous attempt, observed reason and change that makes another attempt reasonable.
For the missing renewal passage, the change might be supplying the omitted appendix. For a temporary processing error, it might be waiting according to the applicable error guidance. If the task was saved successfully, there is no model retry to schedule. If its write is uncertain, resolve that uncertainty first.
Set an attempt ceiling, a spend ceiling and an escalation owner appropriate to the workflow. These are local controls, not universal thresholds. Keep sensitive document text out of routine operational logs; reference controlled source storage instead.
This approach suits asynchronous drafting that tolerates review and delay. It is a poor fit for a user waiting for an immediate answer. It also does not by itself make automated financial or contractual changes safe: those require a separate authorization and destination-control design. The remaining uncertainty is often semantic correctness, which a successful API result cannot establish for your business.
Test recovery before the next production batch
Use a small synthetic manifest and a destination sandbox. Check that your team can:
- Match shuffled results to the correct source revisions.
- Hold an unknown identity and an incomplete download without blind resubmission.
- Reject a draft with a missing required passage.
- Replay an accepted result without creating a duplicate draft.
- Resolve an interrupted write by checking the destination record.
- Produce a retry manifest that excludes committed work.
Sources
- Anthropic, 2026 documentation, Retrieve Message Batch results, accessed November 18, 2026.
- Anthropic, 2026 documentation, Batches API reference, accessed November 18, 2026.
- Anthropic, 2026 documentation, Retrieve a Message Batch, accessed November 18, 2026.
Your next step
Reliable recovery starts with a task record that separates returned output from accepted and committed work. Before your next batch, draw that state flow for one editable draft and test an interrupted import. Then use our API integration patterns guide to place the importer and its recovery owner within the wider system.
