Skip to content

fix(backend): default max_tokens for Anthropic model validation#1549

Merged
Wendong-Fan merged 6 commits intoeigent-ai:mainfrom
emag165:cursor/fix-anthropic-max-tokens-validation-03d7
Apr 11, 2026
Merged

fix(backend): default max_tokens for Anthropic model validation#1549
Wendong-Fan merged 6 commits intoeigent-ai:mainfrom
emag165:cursor/fix-anthropic-max-tokens-validation-03d7

Conversation

@emag165
Copy link
Copy Markdown
Contributor

@emag165 emag165 commented Apr 10, 2026

Anthropic Messages API requires a positive integer max_tokens. The BYOK form does not expose this field, so validation could send an invalid or missing value and Anthropic returned 400.

Ensure validate_model_with_details and create_agent merge model_config_dict with a default of 4096 for platform anthropic when max_tokens is absent or invalid.

Related Issue

Closes #

Description

Testing Evidence (REQUIRED)

  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

Anthropic Messages API requires a positive integer max_tokens. The BYOK
form does not expose this field, so validation could send an invalid or
missing value and Anthropic returned 400.

Ensure validate_model_with_details and create_agent merge model_config_dict
with a default of 4096 for platform anthropic when max_tokens is absent or
invalid.

Co-authored-by: emag165 <emag165@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @emag165 for reporting this issue and doing the fix, please create one issue and link this PR to the issue to follow our contribution guideline. for the default value, i think we'd better set one max value all anthropic model support to allow long-horizon task execution which may require mode output token, the current code seems AI generated and have some unnecessary check logic which makes the code redundant, we just need to set the default value for Anthropic model, since it's built-in logic, no additional check needed

@fengju0213
Copy link
Copy Markdown
Collaborator

fengju0213 commented Apr 11, 2026

@emag165 thanks for your pr, I've submitted a commit to minimize the implementation of this fix; feel free to review it.
cc @Wendong-Fan

@Wendong-Fan Wendong-Fan merged commit eacda32 into eigent-ai:main Apr 11, 2026
7 checks passed
@fengju0213 fengju0213 added this to the Sprint 20 milestone Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants