fix(webui): recover model failures and align chat controls
This commit is contained in:
1 parent
688976bcb9
commit
28f6c26946
42 files changed
+646
-82
No files matched your search
@@ -1281,6 +1281,34 @@ class TestRetryBeforeFailover:
|
||||
assert "cleared" in [status.state for status in retry_statuses]
|
||||
assert retry_statuses[-1].state == "exhausted"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_fallback_auth_error_preserves_primary_diagnosis_and_exhaustion(self) -> None:
|
||||
primary = _FakeProvider("primary", _make_response(
|
||||
"private network detail", finish_reason="error", error_kind="connection",
|
||||
))
|
||||
fallback = _FakeProvider("fallback", _make_response(
|
||||
"private auth detail", finish_reason="error", error_status_code=401,
|
||||
))
|
||||
provider = FallbackProvider(primary, [_fallback("backup")], MagicMock(return_value=fallback))
|
||||
statuses: list[RetryStatusEvent] = []
|
||||
|
||||
async def record(status: RetryStatusEvent) -> None:
|
||||
statuses.append(status)
|
||||
|
||||
with patch("nanobot.providers.base.asyncio.sleep", new_callable=AsyncMock):
|
||||
result = await provider.chat_with_retry(
|
||||
[{"role": "user", "content": "hello"}], on_retry_status=record,
|
||||
)
|
||||
|
||||
assert len(primary.chat_calls) == 4
|
||||
assert len(fallback.chat_calls) == 1
|
||||
assert LLMProvider.public_error_kind(result) == "connection"
|
||||
assert result.preserve_provider_state_on_error is True
|
||||
assert not LLMProvider.is_transient_response(result) # Retry policy is still terminal.
|
||||
assert statuses[-1] == RetryStatusEvent(
|
||||
state="exhausted", attempt=4, max_attempts=4, error_kind="connection",
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("factory_fails", [False, True])
|
||||
async def test_persistent_mode_repeats_the_whole_chain(
|
||||
|
||||
Reference in new issue
Block a user