From dc63ad0ad2ec73014fb99f6c840a4ddea802b806 Mon Sep 17 00:00:00 2001 From: B1GGersnow <2642448440@qq.com> Date: Sat, 25 Apr 2026 00:37:54 +0800 Subject: [PATCH] fix(anthropic): cap max_tokens at 65536 for Qwen models via DashScope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DashScope's Anthropic-compatible endpoint enforces max_tokens ∈ [1, 65536]. Adding "qwen3" to _ANTHROPIC_OUTPUT_LIMITS prevents 400 errors that were misclassified as context overflow, triggering premature compression. Co-Authored-By: Claude Opus 4.7 --- agent/anthropic_adapter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.py index 8d8334acd1..7cdac560b1 100644 --- a/agent/anthropic_adapter.py +++ b/agent/anthropic_adapter.py @@ -105,6 +105,9 @@ _ANTHROPIC_OUTPUT_LIMITS = { "claude-3-haiku": 4_096, # Third-party Anthropic-compatible providers "minimax": 131_072, + # Qwen models via DashScope Anthropic-compatible endpoint + # DashScope enforces max_tokens ∈ [1, 65536] + "qwen3": 65_536, } # For any model not in the table, assume the highest current limit.