fix(anthropic): coerce max_tokens to int to fix validation error (#1519) - #1787
Open
carlosjarenom wants to merge 8 commits into
Open
fix(anthropic): coerce max_tokens to int to fix validation error (#1519)#1787carlosjarenom wants to merge 8 commits into
carlosjarenom wants to merge 8 commits into
Conversation
…igent-ai#1511) Groq's API requires strict JSON schemas with 'additionalProperties: false' on every object type, including nested objects in anyOf/oneOf arrays. This caused 400 errors for browser_type tool and others. CAMEL's sanitize_and_enforce_required() already adds this, but we apply it as a safety net when tools are passed to the agent model. Fixes: eigent-ai#1511
…ent-ai#1519) max_tokens can arrive as string from env vars or JSON config. Anthropic API requires integer, causing 400 'Input should be a valid integer'. Added coercion with fallback to default 128000 on invalid values.
Collaborator
|
Thanks for the contribution and for looking into these issues. @carlosjarenom I found a few blocking points:
We’ll keep this PR open for now. If you have time to update it, we’ll be happy to review it again. |
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.
Changes
max_tokensto integer for Anthropic models.Root Cause
max_tokenscan arrive as a string from:extra_paramsAnthropic API requires
max_tokensto be an integer, causing 400 error:Fix
Added type coercion with fallback to default (128000) on invalid values:
Fixes