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 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 20:32:23 +01:00
parent 06e904ccf5
commit 1b9a31665c

View File

@@ -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"