From 1b9a31665cab709fd1c4fb6f79bb801a964124b1 Mon Sep 17 00:00:00 2001 From: tegwick Date: Thu, 19 Feb 2026 20:32:23 +0100 Subject: [PATCH] fix(pipeline): retry on all LLM errors (not just rate limits) Free-tier APIs intermittently return invalid JSON or empty responses. Now any exception in _call_llm retries up to 3 times with a 5s back-off, rather than failing immediately on non-rate-limit errors. Co-Authored-By: Claude Sonnet 4.6 --- markitect/infospace/pipeline.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/markitect/infospace/pipeline.py b/markitect/infospace/pipeline.py index 5779e032..030ce264 100644 --- a/markitect/infospace/pipeline.py +++ b/markitect/infospace/pipeline.py @@ -584,9 +584,14 @@ class SourcePipeline: except Exception as exc: msg = str(exc) print(f" LLM error: {msg}") - meta["error"] = msg - meta["duration_seconds"] = round(time.time() - t0, 1) - return None, meta + if attempt < max_retries: + wait = 5 * (attempt + 1) + print(f" Retrying in {wait}s (attempt {attempt + 1}/{max_retries})...") + time.sleep(wait) + else: + meta["error"] = msg + meta["duration_seconds"] = round(time.time() - t0, 1) + return None, meta if response is None: meta["error"] = "no response"