Default the Anthropic batch model from the connection - #69624
Merged
Conversation
Batch requests that omit params['model'] now inherit it: from a new AnthropicBatchOperator `model` argument, else the connection's default_model (extra['model']). An explicit per-request model still wins, so a batch can mix models. This aligns the batch path with the hook's create_message/count_tokens, which already default the model from the connection. The hook fills a missing model without mutating the caller's request dicts.
gopidesupavan
approved these changes
Jul 8, 2026
amoghrajesh
approved these changes
Jul 8, 2026
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.
AnthropicBatchOperatormade you repeatparams["model"]in every request ofrequests=[{"custom_id", "params"}], even though the Anthropic connection already carries adefault_model(extra['model']) that the hook'screate_message/count_tokensuse.Batches were the one path that ignored it.
Now a request that omits
modelinherits one. Resolution order:params["model"](unchanged; a batch can still mix models)modelargumentdefault_model(extra['model'], else the provider default)Design notes
create_message/count_tokensalready resolve
model or self.default_model. The connection is the natural home for "whichmodel", and batches now honor it.
paramsstays a verbatim passthrough of the Anthropicmessages.createpayload.create_batchfills a missingmodelvia_apply_default_modelwithout mutating the caller's request dicts, and leaves an explicit per-request model
untouched, so mixed-model batches keep working.
_resolve_modelstep: the Message Batches API is first-party + AWS only, so the Bedrockbranch is unreachable here.
Usage
A request that sets its own
modeloverrides both, so you can still mix models within one batch.