mirror of
https://github.com/usestrix/strix.git
synced 2026-10-12 03:47:56 +00:00
fix: don't retry 401, 402 or 403
This commit is contained in:
parent
f7c4b5221e
commit
15941e080d
3 changed files with 5 additions and 8 deletions
|
|
@ -184,7 +184,7 @@ def _is_transient_model_error(exc: BaseException) -> bool:
|
|||
return True
|
||||
code = _model_error_status_code(exc)
|
||||
if code is not None:
|
||||
return code >= 400
|
||||
return code >= 400 and code not in (401, 402, 403)
|
||||
return isinstance(exc, APIError)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -96,12 +96,8 @@ async def test_blocked_provider_failure_text_carries_request_id(
|
|||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
coordinator = AgentCoordinator()
|
||||
# 4xx errors are retried, so the block repeats until retries run out.
|
||||
streams = [
|
||||
_FakeStream(exc=_blocked_error()) for _ in range(execution._MAX_TRANSIENT_MODEL_RETRIES + 1)
|
||||
]
|
||||
with pytest.raises(PermissionDeniedError):
|
||||
await _run(monkeypatch, streams, coordinator)
|
||||
await _run(monkeypatch, [_FakeStream(exc=_blocked_error())], coordinator)
|
||||
assert coordinator.statuses["root"] == "failed"
|
||||
error = coordinator.errors["root"]
|
||||
assert "Output blocked by policy" in error
|
||||
|
|
|
|||
|
|
@ -84,8 +84,9 @@ def test_client_errors_are_transient() -> None:
|
|||
"bad", response=httpx.Response(400, request=_request()), body=None
|
||||
)
|
||||
assert execution._is_transient_model_error(bad_request) is True
|
||||
for status in (401, 402, 403, 404):
|
||||
assert execution._is_transient_model_error(_status_error(status)) is True
|
||||
assert execution._is_transient_model_error(_status_error(404)) is True
|
||||
for status in (401, 402, 403):
|
||||
assert execution._is_transient_model_error(_status_error(status)) is False
|
||||
assert execution._is_transient_model_error(ValueError("nope")) is False
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue