fix: explain explicit auto migration and verify probe cleanup

This commit is contained in:
2026-09-09 01:37:07 -04:00
parent a0a33c0c01
commit c710c3a7ec
3 changed files with 42 additions and 0 deletions
+24
View File
@@ -1316,3 +1316,27 @@ class TestManagedReasoningAdmission:
assert (await client._limiter_backend.source_stats(source.name)).inflight == 0
finally:
await client._transport.aclose()
async def test_managed_conflict_returns_half_open_probe_and_permit():
"""本地拒绝没有上游响应,不计故障且必须归还半开探针。"""
from tests.contracts.conftest import FakeClock
clock = FakeClock()
source = _source(
provider="openai", reasoning_effort="high", extra_body={"reasoning_effort": "high"}
)
gate = InMemoryGate(config=BreakerConfig(1, 1, 10), now=clock)
entry = await gate.try_enter(source.name, "setup")
await gate.record_failure(entry, "source_dead", True)
clock.advance(2)
client = _client(sources=[source], breaker=gate)
try:
with pytest.raises(RequestRejectedError, match="冲突"):
await client.chat([])
assert (await client._limiter_backend.source_stats(source.name)).inflight == 0
next_entry = await gate.try_enter(source.name, "next")
assert next_entry.allowed and next_entry.is_probe
await gate.release_probe(next_entry)
finally:
await client._transport.aclose()
+11
View File
@@ -911,3 +911,14 @@ class TestThinkingRawOwnership:
wire = ThinkingWire(off=None, on_base={"output_config": {"enabled": True}}, effort_key=None)
with pytest.raises(ThinkingUnsupportedError):
validate_thinking_raw(raw, effort=Effort.AUTO, wire=wire, origin="test")
def test_auto_rejection_explains_how_to_choose_explicitly():
"""可执行配置是指路,不由库自动应用其建议。"""
with pytest.raises(ThinkingUnsupportedError) as error:
resolve_thinking(
get_provider("minimax"), get_capability("MiniMax-M3"), Effort.AUTO, model="MiniMax-M3"
)
assert "REASONING_EFFORT=" in str(error.value)
assert "reasoning_effort=Effort." in str(error.value)
assert "EFFORT_FALLBACK=nearest" not in str(error.value)