fix: Make batch_add_requests split batches by serialized payload size (#953)
The 9 MB payload guard in `batch_add_requests` was inert: `constrained_batches` was called without `get_len`, so the default `len()` measured each request dict's key count (~4) instead of its serialized size. Batches were therefore split only by the 25-request count limit, and large requests shipped as one oversized POST that the API rejects with 413, failing the whole call. The guard now measures each request as its UTF-8 JSON byte length, using the same serialization flags as the HTTP client's request body path. It also passes `strict=False`, which preserves the previous contract for an individually oversized request: it's sent in its own batch and left for the API to judge, instead of raising a client-side `ValueError`. Both the size-based splitting and the oversized-singleton path are covered by new sync/async regression tests. *✍️ Drafted by Claude Code*
V
Vlada Dusek committed
2adf515d3e8db47b7f75d69931580ab9269cb2e3
Parent: 4324dcf
Committed by GitHub <noreply@github.com>
on 7/17/2026, 2:08:16 PM