Skip to content

OpenAI: Guarding against batches that are >200MB - #41

Merged
beansrowning merged 6 commits into
devfrom
max_batch_size
Sep 10, 2026
Merged

beansrowning merged 6 commits into
devfrom
max_batch_size

Conversation

@beansrowning

Copy link
Copy Markdown
Collaborator

Changes

  • OpenAIBatchHandler should now prevent batches from exceeding 200MB
    • configured by MAX_BATCH_FILE_SIZE
  • Also handling case where individual request exceeds 200MB by raising before we hit the API
  • A lot of fixes to the internal plumbing of batch file creation
    • Requests are iteratively serialized, written to a spooling temporary file, and this is passed as-is to batch upload method
  • A lot of unit tests from codex

Co-authored-by: OpenAI Codex codex@openai.com
- Serializing once and passing that directly onward to post to API
- dropping _create_batch_file as a result
- Handling possible JSON encoding issues and sending exception onward per-request
- Generalizing _fail_too_large -> _fail_request for the above purpose
- Updating test suite
- Should help ease memory overhead a bit
- Also updating tests (thanks, codex)

Co-authored-by: OpenAI Codex codex@openai.com
@beansrowning
beansrowning merged commit b20bb3d into dev Sep 10, 2026
4 of 5 checks passed
@beansrowning beansrowning mentioned this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant