core/cli: 10 auto-retries with 5/10/15/20 then +10s waits

default_retry_delays builds (5,10,15,20,30,…80) for DEFAULT_MAX_AUTO_RETRIES=10.
This commit is contained in:
2026-07-17 15:36:29 +08:00
parent 39acd5967e
commit f7a562740e
2 changed files with 36 additions and 3 deletions
+17 -2
View File
@@ -17,8 +17,23 @@ if TYPE_CHECKING:
from plyngent.agent import AgentEvent
from plyngent.agent.chat import ChatAgent
# Wait before retry attempt 1, 2, and 3 (after the first failure).
DEFAULT_RETRY_DELAYS_SECONDS: tuple[float, ...] = (10.0, 20.0, 30.0)
# Auto-retry budget after the first failure (10 attempts by default).
DEFAULT_MAX_AUTO_RETRIES = 10
# First four waits; each further wait is previous + 10s.
_RETRY_BASE_DELAYS_SECONDS: tuple[float, ...] = (5.0, 10.0, 15.0, 20.0)
def default_retry_delays(max_retries: int = DEFAULT_MAX_AUTO_RETRIES) -> tuple[float, ...]:
"""Build wait times: 5, 10, 15, 20, then +10s each step, length *max_retries*."""
if max_retries <= 0:
return ()
delays: list[float] = list(_RETRY_BASE_DELAYS_SECONDS)
while len(delays) < max_retries:
delays.append(delays[-1] + 10.0)
return tuple(delays[:max_retries])
DEFAULT_RETRY_DELAYS_SECONDS: tuple[float, ...] = default_retry_delays()
_PREVIEW_LEN = 80