fix: judge the phase 2 shape by the tier that was asked for
A provider that registered a disable form but no enable form was told its shape was unknown and pointed at register_provider -- work it had already done -- for a request that only ever needed the disable form. The old bool code took the slot by direction; the tiered rewrite lost that. Take the relevant field again, and keep "shape unknown" for the case where both halves are missing, so the "cannot disable" wording still owns the half-missing case.
This commit is contained in:
@@ -177,6 +177,41 @@ class TestResolveThinking:
|
||||
assert "kimi-k3" in msg
|
||||
assert effort.value in msg
|
||||
|
||||
def test_phase2_reads_the_form_the_asked_for_tier_needs(self):
|
||||
"""请求 `none` 只需要**关闭**形态: 开启形态未知与这次请求无关。
|
||||
|
||||
旧版 `slot = thinking_on if enable_thinking else thinking_off` 即按请求方向
|
||||
取字段;档位化后一度写成"只看 `on_base`",于是一个已注册了关闭形态的自定义
|
||||
provider 在请求 `none` 时被误拒,还被指向它已经做过的 `register_provider`
|
||||
——指错方向比不指更糟(设计 §2 处置表第 2 条,2026-09-05 独立验证查出)。
|
||||
"""
|
||||
profile = ProviderProfile(
|
||||
name="off_only",
|
||||
thinking=ThinkingWire(
|
||||
off={"thinking": {"type": "disabled"}}, on_base=None, effort_key=None
|
||||
),
|
||||
strip_think_tags=False,
|
||||
)
|
||||
cap = ThinkingCapability((Effort.NONE, Effort.AUTO), "构造: 关得掉,开启形态却未登记")
|
||||
got = resolve_thinking(profile, cap, Effort.NONE, model="x-1")
|
||||
assert got.payload == {"thinking": {"type": "disabled"}}
|
||||
assert got.applied_effort is Effort.NONE
|
||||
|
||||
@pytest.mark.parametrize("effort", [Effort.AUTO, Effort.HIGH])
|
||||
def test_phase2_still_fires_when_the_on_form_is_the_missing_half(self, effort):
|
||||
"""反方向不得被一并放过: 要开推理而开启形态未知,仍须报错并指路注册。"""
|
||||
profile = ProviderProfile(
|
||||
name="off_only",
|
||||
thinking=ThinkingWire(
|
||||
off={"thinking": {"type": "disabled"}}, on_base=None, effort_key=None
|
||||
),
|
||||
strip_think_tags=False,
|
||||
)
|
||||
cap = ThinkingCapability((Effort.NONE, Effort.AUTO, Effort.HIGH), "构造")
|
||||
with pytest.raises(ThinkingUnsupportedError, match="register_provider") as exc:
|
||||
resolve_thinking(profile, cap, effort, model="x-1")
|
||||
assert effort.value in str(exc.value)
|
||||
|
||||
def test_phase2_beats_the_capability_checks(self):
|
||||
"""形态未知时无从注入,能力如何无关紧要——Phase 2 必须先于 4/5。"""
|
||||
cap = ThinkingCapability((Effort.AUTO,), "构造")
|
||||
|
||||
Reference in New Issue
Block a user