Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent workflows

Submit and reconcile offline message batches

Submit many independent prompts asynchronously, then reconcile successes and failures by custom_id.

Goal

Goal: Submit many independent prompts asynchronously, then reconcile successes and failures by `custom_id`.

Steps

  1. Assign each request a stable custom_id and build a {"custom_id":..., "params":{...}} request. [batch]
  2. Submit with client.beta.messages.batches.create(requests=...), persist the batch ID, and poll retrieve(batch_id) until processing_status == "ended". [batch]
  3. Read result items into a result store using idempotent upserts by custom_id; separate success, error, and missing items. [batch]

How to verify

The request count reconciles to success, failure, and missing items; retry only failed items and retain original batch mapping.

Troubleshooting

If a batch stalls, poll with bounded backoff and retain status; creation success does not mean every item completed.

Permissions

Prerequisites

Permissions

Limitations

Batches are asynchronous and one-shot; handle expiration, per-item failure, and retention; do not use for interactive latency.

Pinned upstream source

https://github.com/anthropics/anthropic-cookbook/blob/9c1e493ddd2b82df399d2a61b9c806c539e18be6/misc/batch_processing.ipynb

Repository
anthropics/anthropic-cookbook
File path
misc/batch_processing.ipynb
Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Turn ecommerce campaign materials into a reviewable weekly brief

Related resources