fix: pop model_tokens so it is not forwarded to the model client#1100
Merged
Conversation
On the plain llm-config path, _create_llm read model_tokens but never removed it from llm_params, so it was splatted into init_chat_model and forwarded to the client. With ChatOpenAI (any OpenAI-compatible base_url) this surfaced as: Completions.create() got an unexpected keyword argument 'model_tokens'. Pop the key after consuming it, matching the model_instance path which already returns before the key can leak. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
VinciGit00
approved these changes
Jul 8, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 8, 2026
## [2.1.5](v2.1.4...v2.1.5) (2026-07-08) ### Bug Fixes * pop model_tokens so it is not forwarded to the model client ([#1100](#1100)) ([d2b970c](d2b970c)) ### Docs * **readme:** add Open Source vs Managed API comparison ([#1091](#1091)) ([ef3523b](ef3523b)) ### CI * run only deterministic unit suites in Test Suite workflow ([#1095](#1095)) ([037a42e](037a42e))
|
🎉 This PR is included in version 2.1.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Description
Fixes #1099.
On the plain
llm-config path,AbstractGraph._create_llm()readsmodel_tokensintoself.model_tokenbut never removes it fromllm_params.llm_paramsis then splatted intoinit_chat_model(**llm_params), somodel_tokensis forwarded to the model client. With aChatOpenAIclient (any OpenAI-compatiblebase_url) this surfaces as:This one-line change pops
model_tokensafter it is consumed, so it can't leak to the client. It mirrors the existingmodel_instancepath, which already returns before the key can reach a client (and is why that path works today).Repro (before this patch)
Change
Type of change
Notes
Verified locally against an OpenAI-compatible endpoint (Cloudflare AI Gateway
/compat): with the patch, passingmodel_tokensvia plain config no longer raises and the value is correctly used for chunk sizing.