An enterprise data platform uses Claude for async document processing via Anthropic's Message Batches API. Batch jobs are submitted with 500-document batches, and results are retrieved after completion. The team discovers that when a batch partially fails — 50 documents in a 500-document batch fail due to content policy violations — the batch API returns partial results and the failed items must be identified individually. Their current code treats any batch failure as a total failure and resubmits all 500 documents. What is the correct resilience pattern?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Here's the deal — the Message Batches API returns per-item results with individual success/error statuses. Treating partial batch failures as total failures is wasteful — re-processing 450 successful documents wastes compute and tokens.
Full explanation below image
Full Explanation
The Message Batches API returns per-item results with individual success/error statuses. Treating partial batch failures as total failures is wasteful — re-processing 450 successful documents wastes compute and tokens. The correct pattern extracts failed custom_ids from batch results and classifies failures: content policy violations (error type invalid_request_error with specific codes) should be escalated to human review, not retried, as they won't succeed on retry. Transient errors (rate limits, server errors) should be retried in a new batch. Option A (smaller batches) reduces re-processing waste but doesn't fix the fundamental logic error of conflating failure types or treating partial failures as total failures. Option C is explicitly wrong — the problem states this is the current antipattern. Option D (synchronous serial) eliminates the batch efficiency gains (parallelism, reduced API overhead) for a problem that item-level result parsing already solves.