fix(agent): OpenRouter transient error retry + heartbeat retry#16
Merged
fix(agent): OpenRouter transient error retry + heartbeat retry#16
Conversation
401/408/429 now retry same model (up to 2x with backoff) before falling to next model in the chain. Previously 401 threw immediately, causing empty reports on transient OpenRouter "User not found" errors.
runPipeline() now returns { narratives, anomalies } counts so callers
can detect empty reports (0 narratives with anomalies present) and
decide whether to commit or retry.
Two retry mechanisms: 1. Pipeline crash: retry after 30min instead of waiting 24h (max 2/day) 2. Empty report safety net: if anomalies detected but 0 narratives (LLM failure was silently caught), skip commit and retry after 30min Prevents both the Feb 19 scenario (transient 401 → empty report committed) and general pipeline failures from wasting an entire day.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mitigates the Feb 19 incident where a transient OpenRouter 401 ("User not found") caused an empty report to be committed (0 narratives despite 17 anomalies detected).
Three-layered defense:
Transient retry in OpenRouter — 401/408/429 now retry the same model up to 2x with 3s/6s backoff before falling to the next model in the chain. Previously these threw immediately, bypassing the fallback chain entirely.
Pipeline result reporting —
runPipeline()returns{ narratives, anomalies }counts so the heartbeat daemon can detect empty reports (LLM failure was silently caught by clustering's error handler).Heartbeat retry mechanism — Two retry paths:
Test plan