Add a two-stage curation fallback: alternate Gemini model, then manual - #9
Merged
Merged
Conversation
Fixes #8. A Gemini 503 ("high demand") or similar transient failure used to crash the whole run, discarding the fetching/clustering/domain- detection work already done -- often several minutes for a real family. Add two fallback layers: - GeminiCurationBackend now tries one alternate model (gemini-2.5-flash-lite by default, configurable/disableable via a new fallback_model param) before giving up on Gemini, since a different model is often not overloaded at the same time. - run_pipeline now catches any exception from a non-manual curation backend and falls back to the interactive manual-curation prompt, so a Gemini outage no longer loses the run -- only a genuine manual backend failure (e.g. non-interactive stdin) still propagates. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Fixes #8.
Summary
503 UNAVAILABLE("high demand") from Gemini's primary model used to crash the whole run, discarding the fetching/clustering/domain-detection work already done in that run -- often several minutes for a real CAZy family.GeminiCurationBackend.curate()now tries one alternate model (gemini-2.5-flash-liteby default, via a newfallback_modelconstructor param -- passNoneto disable) before giving up on Gemini, since a different model is frequently not overloaded/rate-limited/deprecated at the same time as the primary one.run_pipelinenow catches any exception from a non-manual curation backend and falls back to the existing interactive manual-curation prompt, so the run still completes instead of crashing. A failure in the manual backend itself (already the last resort) still propagates -- there's nowhere further to fall back to.Test plan
pytest-- 119 passed. New tests cover: Gemini falls back to the secondary model and succeeds; raises the last error when both models fail; fallback disabled viafallback_model=None;run_pipelinefalls back to manual curation when the configured backend fails (asserting the run still completes and the fallback is logged); a manual-backend failure is not caught (propagates, since it's the last resort)