The max tokens of Claude 3.5 Sonnet for Bedrock and VertexAI are not correct #6655

Closed
opened 2026-02-21 18:16:43 -05:00 by yindo · 1 comment
Owner

Originally created by @fdb02983rhy on GitHub (Nov 10, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.11.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

N/A

✔️ Expected Behavior

Max tokens should be 8192

Actual Behavior

Max tokens are 4096

Originally created by @fdb02983rhy on GitHub (Nov 10, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.11.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce N/A ### ✔️ Expected Behavior Max tokens should be 8192 ### ❌ Actual Behavior Max tokens are 4096
yindo added the 🐞 bug label 2026-02-21 18:16:43 -05:00
yindo closed this issue 2026-02-21 18:16:43 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 10, 2024):

The issue you're experiencing with the max tokens being 4096 instead of the expected 8192 in the self-hosted version 0.11.0 of Claude 3.5 Sonnet for Bedrock and VertexAI is due to the configuration in the parameter_rules section of the YAML file. The max_tokens parameter is explicitly set with a maximum value of 4096, as shown below:

parameter_rules:
  - name: max_tokens
    use_template: max_tokens
    required: true
    type: int
    default: 4096
    min: 1
    max: 4096
    help:
      en_US: The maximum number of tokens to generate before stopping. Note that Anthropic Claude models might stop generating tokens before reaching the value of max_tokens. Different Anthropic Claude models have different maximum values for this parameter.

This configuration sets the maximum allowable tokens to 4096, which is why it does not reach 8192. Additionally, the documentation notes that different Anthropic Claude models have different maximum values for this parameter, which may explain the discrepancy [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 10, 2024): <!-- Answer --> The issue you're experiencing with the max tokens being 4096 instead of the expected 8192 in the self-hosted version 0.11.0 of Claude 3.5 Sonnet for Bedrock and VertexAI is due to the configuration in the `parameter_rules` section of the YAML file. The `max_tokens` parameter is explicitly set with a maximum value of 4096, as shown below: ```yaml parameter_rules: - name: max_tokens use_template: max_tokens required: true type: int default: 4096 min: 1 max: 4096 help: en_US: The maximum number of tokens to generate before stopping. Note that Anthropic Claude models might stop generating tokens before reaching the value of max_tokens. Different Anthropic Claude models have different maximum values for this parameter. ``` This configuration sets the maximum allowable tokens to 4096, which is why it does not reach 8192. Additionally, the documentation notes that different Anthropic Claude models have different maximum values for this parameter, which may explain the discrepancy <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/vertex_ai/llm/anthropic.claude-3.5-sonnet-v2.yaml)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/bedrock/llm/us.anthropic.claude-3-sonnet-v1.5.yaml)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6655