@@ -540,11 +540,12 @@ def handler(request: httpx.Request) -> httpx.Response:
540540
541541
542542async def test_client_fetch_models_metadata ():
543- """倍率(display_contact_config.consumption_rate)与上下文窗口透传 。"""
543+ """倍率 / 上下文窗口 / 推理能力透传 。"""
544544 def handler (_request : httpx .Request ) -> httpx .Response :
545545 return httpx .Response (200 , json = {"config_info_list" : [
546546 {"config_name" : "Doubao-Seed-Evolving" ,
547- "display_config" : {"display_name" : "Seed-Evolving" },
547+ "display_config" : {"display_name" : "Seed-Evolving" ,
548+ "model_capability" : "reasoning_model" },
548549 "context_window_tokens" : {"dev" : 256000 },
549550 "display_contact_config" : json .dumps ({
550551 "consumption_rate" : {"enable" : True , "data" : {"rate" : 0.08 }}})},
@@ -555,18 +556,50 @@ def handler(_request: httpx.Request) -> httpx.Response:
555556 {"config_name" : "kimi-k3" ,
556557 "display_config" : {"display_name" : "K3" },
557558 "display_contact_config" : json .dumps ({
558- "consumption_rate" : {"enable" : True , "data" : {"rate" : "oops" }}})},
559+ "consumption_rate" : {"enable" : True , "data" : {"rate" : "oops" }}}),
560+ "reasoning_effort_config" : {"support_thinking" : False }},
559561 ]})
560562
561563 models = await _client (handler ).fetch_models (TraeCredential (access_token = "a" ))
562564 assert models [0 ].credit_rate == 0.08
563565 assert models [0 ].max_input_tokens == 256000
566+ assert models [0 ].supports_reasoning is True
567+ # TRAE 无档位清单可核实 → 不编造默认档位
568+ assert models [0 ].default_effort is None
564569 # 坏数据 → 字段留空,不影响条目
565570 assert models [1 ].credit_rate is None and models [1 ].max_input_tokens is None
571+ # 能力字段缺失 → 回落 reasoning_effort_config.support_thinking
572+ assert models [1 ].supports_reasoning is None
573+ assert models [2 ].supports_reasoning is False
566574 # rate 非数值同样留空
567575 assert models [2 ].credit_rate is None
568576
569577
578+ async def test_trae_supports_reasoning_branches ():
579+ """能力判定的优先级与回落:capability 优先,其次 support_thinking。"""
580+ def handler (_request : httpx .Request ) -> httpx .Response :
581+ return httpx .Response (200 , json = {"config_info_list" : [
582+ # capability 非空字符串 → 不以 support_thinking 为准
583+ {"config_name" : "c1" , "display_config" : {"model_capability" : "chat_model" },
584+ "reasoning_effort_config" : {"support_thinking" : True }},
585+ # capability 为空串 → 掉到 support_thinking
586+ {"config_name" : "c2" , "display_config" : {"model_capability" : "" },
587+ "reasoning_effort_config" : {"support_thinking" : True }},
588+ # display_config 非 dict → 掉到 support_thinking
589+ {"config_name" : "c3" , "display_config" : "oops" ,
590+ "reasoning_effort_config" : {"support_thinking" : True }},
591+ # support_thinking 非布尔 → None
592+ {"config_name" : "c4" , "reasoning_effort_config" : {"support_thinking" : "yes" }},
593+ # reasoning_effort_config 非 dict → None
594+ {"config_name" : "c5" , "reasoning_effort_config" : ["oops" ]},
595+ # 全部缺失 → None
596+ {"config_name" : "c6" },
597+ ]})
598+
599+ models = await _client (handler ).fetch_models (TraeCredential (access_token = "a" ))
600+ assert [m .supports_reasoning for m in models ] == [False , True , True , None , None , None ]
601+
602+
570603@pytest .mark .parametrize ("payload" , [
571604 {}, {"config_info_list" : "no" }, {"config_info_list" : []},
572605])
0 commit comments