diff --git a/docs/superpowers/plans/2026-06-21-cyclone-pipeline-agent.md b/docs/superpowers/plans/2026-06-21-cyclone-pipeline-agent.md index ded566c..14cca1e 100644 --- a/docs/superpowers/plans/2026-06-21-cyclone-pipeline-agent.md +++ b/docs/superpowers/plans/2026-06-21-cyclone-pipeline-agent.md @@ -747,7 +747,7 @@ T = TypeVar("T", bound=BaseModel) DEFAULT_TIMEOUT = httpx.Timeout(connect=10.0, read=30.0, write=10.0, pool=5.0) MAX_RETRIES = 3 -BACKOFF_S = (1.0, 2.0, 4.0) +BACKOFF_S = (1.0, 2.0) # only used between attempts 0→1 and 1→2 # --- Response models --------------------------------------------------------- @@ -820,24 +820,31 @@ class CycloneClient: async def _get_typed( self, path: str, model: type[T] ) -> T: - assert self._http is not None, "use `async with CycloneClient(...)`" + if self._http is None: + raise RuntimeError("use `async with CycloneClient(...)`") last_exc: Exception | None = None for attempt in range(MAX_RETRIES): try: resp = await self._http.get(path) resp.raise_for_status() return model.model_validate(resp.json()) - except (httpx.HTTPStatusError, httpx.RequestError) as e: + except httpx.HTTPStatusError as e: + # 4xx is terminal — surface immediately, do not retry + if e.response is not None and e.response.status_code < 500: + raise last_exc = e - if attempt < MAX_RETRIES - 1: - wait_s = BACKOFF_S[attempt] - log.warning( - "api_get_retry", - path=path, attempt=attempt + 1, wait_s=wait_s, - error=str(e), - ) - await asyncio.sleep(wait_s) - assert last_exc is not None + except httpx.RequestError as e: + # connect/read failures are transient — retry + last_exc = e + if attempt < MAX_RETRIES - 1: + wait_s = BACKOFF_S[attempt] + log.warning( + "api_get_retry", + path=path, attempt=attempt + 1, wait_s=wait_s, + error=str(last_exc), + ) + await asyncio.sleep(wait_s) + assert last_exc is not None # loop body always sets this on the way out raise last_exc # --- methods -----------------------------------------------------------