mirror of
https://github.com/usestrix/strix.git
synced 2026-08-24 03:42:37 +02:00
Sign in with a ChatGPT subscription for inference (#854)
Co-authored-by: Jonathan Singer <jonathansinger@Jonathans-MacBook-Pro.local> Co-authored-by: Jonathan Singer <jonathansinger@Mac-3004.lan> Co-authored-by: Ahmed Allam <ahmed39652003@gmail.com>
This commit is contained in:
co-authored by
Jonathan Singer
Jonathan Singer
Ahmed Allam
parent
93af2b94a2
commit
cd8270c98b
@@ -13,12 +13,15 @@ import asyncio
|
||||
|
||||
from agents.retry import ModelRetryNormalizedError, RetryPolicyContext
|
||||
|
||||
from strix.config import codex
|
||||
from strix.config.models import DEFAULT_MODEL_RETRY, _retry_statusless_provider_errors
|
||||
|
||||
|
||||
def _context(normalized: ModelRetryNormalizedError) -> RetryPolicyContext:
|
||||
def _context(
|
||||
normalized: ModelRetryNormalizedError, error: Exception | None = None
|
||||
) -> RetryPolicyContext:
|
||||
return RetryPolicyContext(
|
||||
error=RuntimeError("boom"),
|
||||
error=error or RuntimeError("boom"),
|
||||
attempt=1,
|
||||
max_retries=5,
|
||||
stream=True,
|
||||
@@ -27,11 +30,11 @@ def _context(normalized: ModelRetryNormalizedError) -> RetryPolicyContext:
|
||||
)
|
||||
|
||||
|
||||
def _retries(normalized: ModelRetryNormalizedError) -> bool:
|
||||
def _retries(normalized: ModelRetryNormalizedError, error: Exception | None = None) -> bool:
|
||||
"""Evaluate the composed DEFAULT_MODEL_RETRY policy for a normalized error."""
|
||||
policy = DEFAULT_MODEL_RETRY.policy
|
||||
assert policy is not None
|
||||
decision = asyncio.run(policy(_context(normalized)))
|
||||
decision = asyncio.run(policy(_context(normalized, error)))
|
||||
return bool(getattr(decision, "retry", decision))
|
||||
|
||||
|
||||
@@ -63,6 +66,16 @@ def test_timeout_error_is_retried() -> None:
|
||||
assert _retries(ModelRetryNormalizedError(is_network_error=True)) is True
|
||||
|
||||
|
||||
def test_content_guardrail_error_is_not_retried() -> None:
|
||||
# A guardrail block is status-less, so it would match the statusless policy;
|
||||
# the guard must keep it from being retried (retrying never clears it).
|
||||
guardrail = codex.CodexContentGuardrailError("gpt-5.6-sol")
|
||||
assert _retries(ModelRetryNormalizedError(status_code=None), guardrail) is False
|
||||
# A raw provider error carrying the backend's wording is excluded too.
|
||||
raw = RuntimeError("This content was flagged for possible cybersecurity risk.")
|
||||
assert _retries(ModelRetryNormalizedError(status_code=None), raw) is False
|
||||
|
||||
|
||||
def test_policy_helper_matches_statusless_only() -> None:
|
||||
assert _retry_statusless_provider_errors(_context(ModelRetryNormalizedError())) is True
|
||||
assert (
|
||||
|
||||
Reference in New Issue
Block a user