r/OpenAIDev • • 1d ago

Notes from fighting OpenAI Batch API 24h straggler tails, dirty error archives, and timeout double-billing (open-source CLI/SDK)

After running large offline workloads across `/v1/chat/completions`, `/v1/responses`, and `/v1/embeddings`, we kept hitting the same three protocol-level issues with the Batch API:

  1. **99% straggler lock-in**: Large batches routinely finish ~99% within 2–4 hours, then sit on the last <1% until expiring at 24h. Small batches (≤25 requests) also wait hours in batch queues when real-time calls would finish in seconds.
  2. **Dirty partial archives**: Cancelled/expired outputs can have unordered lines, `503`/overloaded failures inside `error_file` before `request_counts.failed` settles, or truncated lines.
  3. **Timeout double-billing**: Enabling SDK retries on `POST /batches` after a client read timeout can create duplicate paid batches.

I open-sourced what we built to wrap this state machine (`llm-batch-accelerator` / `lba`, MIT, Python 3.11+): - **3-tier adaptive Tail-Cut** (`off` / `shadow` / `active`): cancels stuck batches early to release completed results. - **Bounded Hybrid Sync (`SyncBudget`)**: finishes remaining tail items via real-time API only inside an explicit cap (e.g. `1%`, `$5`, or `250req`), auto-falling back to Batch on 429s. - **WAL intent journal + wire-hash reuse**: logs `metadata.lba_intent_id` before submission (`max_retries=0`) and hashes canonical requests to reuse completed results or adopt still-running batches across restarts.

If you want to check whether your own account actually has tail stalls (strictly read-only `GET /v1/batches`, zero writes): ```bash OPENAI_API_KEY="sk-..." uvx llm-batch-accelerator audit --days 30 --inspect-archives 5 --share ```

Current limitations: OpenAI-only right now (Anthropic Message Batches and Gemini Batch Mode are next) and local SQLite WAL only (no Postgres/S3 backend yet).

Repo: https://github.com/YuehaoDai/llm-batch-accelerator

2 Upvotes

0 comments sorted by