From 53aa5cd247c860061cc8b93e10326dfed93bd564 Mon Sep 17 00:00:00 2001 From: zhiyu Date: Fri, 31 Jul 2026 11:47:21 +0800 Subject: [PATCH] test: align ModelMappingPreservesOtherFields with max_tokens strip The count_tokens path now strips max_tokens; this sibling test also exercises ForwardCountTokens but still asserted max_tokens preservation. Flip its assertion to expect the field is filtered, matching CountTokensFiltersGenerationFields. --- .../service/gateway_anthropic_apikey_passthrough_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/internal/service/gateway_anthropic_apikey_passthrough_test.go b/backend/internal/service/gateway_anthropic_apikey_passthrough_test.go index d5976c42b4..e7ac736ed6 100644 --- a/backend/internal/service/gateway_anthropic_apikey_passthrough_test.go +++ b/backend/internal/service/gateway_anthropic_apikey_passthrough_test.go @@ -523,7 +523,8 @@ func TestGatewayService_AnthropicAPIKeyPassthrough_ModelMappingPreservesOtherFie require.Equal(t, "hello world", gjson.GetBytes(sentBody, "messages.0.content.0.text").String(), "messages 字段不应被修改") require.Equal(t, "enabled", gjson.GetBytes(sentBody, "thinking.type").String(), "thinking 字段不应被修改") require.Equal(t, int64(5000), gjson.GetBytes(sentBody, "thinking.budget_tokens").Int(), "thinking.budget_tokens 不应被修改") - require.Equal(t, int64(1024), gjson.GetBytes(sentBody, "max_tokens").Int(), "max_tokens 不应被修改") + require.False(t, gjson.GetBytes(sentBody, "max_tokens").Exists(), + "max_tokens 作为生成参数应被 count_tokens 过滤剥离") } func TestGatewayService_AnthropicAPIKeyPassthrough_CountTokensFiltersGenerationFields(t *testing.T) {