refactor(scripts): extract shared Gemini quota-error predicate (9 sites)#1028
Open
sliamh11 wants to merge 2 commits into
Open
refactor(scripts): extract shared Gemini quota-error predicate (9 sites)#1028sliamh11 wants to merge 2 commits into
sliamh11 wants to merge 2 commits into
Conversation
Adds scripts/_gemini_quota.py with a single is_quota_error(exc) predicate and re-points the 9 duplicated inline "429"/RESOURCE_EXHAUSTED checks in drift_check.py, trec_atom_benchmark.py, memory_indexer.py, rule_following_judge.py, and attention_dilution_probe.py to use it. Scope is intentionally minimal — this is the one piece of the Gemini call-with-fallback logic proven safe to consolidate across prior review rounds. The surrounding retry/fallback bodies (temperatures, token limits, exhaustion-tracking, retry cadence) differ meaningfully per file and are left untouched. 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.
Summary
scripts/_gemini_quota.pywith a singleis_quota_error(exc)predicate and re-points 9 duplicated inline"429"/RESOURCE_EXHAUSTEDchecks acrossdrift_check.py(3),trec_atom_benchmark.py(2),memory_indexer.py(1, plus deleting its own now-redundant local copy),rule_following_judge.py(1), andattention_dilution_probe.py(2) to use it.Opportunistic dedup cleanup found during the Deus V2 migration — not a Linear-tracked issue. Deliberately narrow scope: an earlier, broader attempt to consolidate the entire "call Gemini with model-fallback" logic across these files was rejected across 3 review rounds because the actual retry/fallback bodies differ meaningfully per file (temperature, token limits, exhaustion-tracking, retry cadence, control-flow shape). Only the one-line predicate — proven byte-for-byte semantically identical after
str()normalization across all 9 sites — is extracted. Everything else stays untouched.Test plan
scripts/tests/test_gemini_quota.py— 6 cases, all passingtest_gemini_quota.py+test_drift_check.py— 113 passedtest_memory_indexer.py+test_memory_indexer_ner.py+test_rule_following_judge.py+test_attention_dilution_probe.py— 347 passedrule_following_judge,attention_dilution_probeneedscripts/bench/onsys.path;drift_check,trec_atom_benchmarkneedscripts/onsys.path)🤖 Generated with Claude Code