feat(preset): add Anthropic batch jobs - #43
Open
tasoo-oos wants to merge 22 commits into
Open
Conversation
tasoo-oos
force-pushed
the
feat-preset-anthropic-batch-jobs
branch
from
June 20, 2026 15:17
56f8421 to
76c8195
Compare
tasoo-oos
force-pushed
the
feat-preset-anthropic-batch-jobs
branch
from
June 20, 2026 16:56
76c8195 to
9c8b60b
Compare
tasoo-oos
marked this pull request as ready for review
June 25, 2026 17:05
Contributor
Author
Contributor
Author
|
Also, I know this is pretty big for a single PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Summary
Adds Anthropic Messages batch support for Model Presets. Anthropic presets can now submit a long-running batch job, poll for completion, parse the final JSONL result, and surface progress through request status.
Related Issues
None.
Changes
Behavior changes:
/v1/messages/batcheswhen presetservice_tieris set tobatch.waitingphase and Anthropic batch badges for submitted/running/cancel/completed/failed states.Anthropic batch architecture:
ProviderRequestJobadds a generic async job result type to the request pipeline.AnthropicBatchJobowns submit-time metadata, polling, timeout, cancellation, JSONL result parsing, and final status state.requestModelPresetdecides whether a preset should use batch mode, creates the prepared Anthropic request, strips batch-incompatible fields, and returns{ type: "job" }.wrapAnthropicBatchStatusJobbridges provider job status into the request-status store without letting status UI failures affect the request.Other changes:
Batchas a bundled Anthropic service tier option.Impact
Users can opt Anthropic presets into slower long-running batch requests. Existing streaming/non-streaming requests remain unchanged unless batch mode is selected. Batch mode does not automatically retry for banned character sets. Also, batch jobs bypass normal blank-response fallback/retry behavior and banned-character auto-regeneration.
Demo
All these E2E tests were conducted at version 1b2187a
For long videos, middle parts are API polling, so nothing happens really.
I suggest you to watch start and end part of the video.
Test settings / Test run
test-req.mp4
Base - Success
base.-.successful.request.mp4
Cancellation behavior - Cancelled
Cancellation.behavior.-.Cancelled.mp4
Cancellation behavior - Cancelled from Anthropic Server
Cancellation.behavior.-.server.side.cancel.mp4
This path can be triggered by canceling batch in the Anthropic Console.
Cancellation behavior - Successful anyway
Cancellation.behavior.-.Successful.anyway.mp4
Invalid Request - Invalid API key
Invalid.Request.-.Invalid.API.key.mp4
Invalid Request - Invalid parameter
Invalid.Request.-.Invalid.parameter.mp4
Settings were made with additional parameters.
Batch with tool use - Success
simple.tool.call.-.success.mp4
Internally, multiple batch request is getting submitted sequentially.
Tool use must be enabled at the model preset, or else model hallucinates tool result.
This seems buggy, but it is not handled since it is not necessarilly batch-specific behavior.
Batch with tool use - Cancelled in the middle
logging
Anthropic Batch API only logs two things: First batch submit and final results.
request log preview
request log exmaple - iniital request
request log exmaple - final response success
request log example - cancelled
Additional Notes
After this PR's merge, there's a registry-side PR that matches this one at PocketRisu/pocketrisu-model-registry#1
Footnotes
Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩
Over 80% of the code is AI generated. ↩