Skip to content

feat: implement issue #1777 — Gemini is not working optimally - #1780

Merged
don-petry merged 6 commits into
mainfrom
dev-lead/issue-1777-20260913-0323
Sep 13, 2026
Merged

don-petry merged 6 commits into
mainfrom
dev-lead/issue-1777-20260913-0323

Conversation

@don-petry

@don-petry don-petry commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

User description

Closes #1777

Implemented by dev-lead agent. Please review.


CodeAnt-AI Description

Improve Gemini availability with multi-key rotation and an updated model

What Changed

  • Gemini now uses gemini-3.8-flash for triage and action work by default.
  • Gemini can rotate through up to three configured API keys when a key is rate-limited, staying on the same model before falling back.
  • Secondary Gemini keys count as valid configuration, and Gemini is tried before Copilot in the provider fallback order.
  • Added coverage for key rotation, fallback behavior, configuration detection, and the updated model assignments.

Impact

✅ Fewer Gemini quota-related failures
✅ Fewer unnecessary model or provider fallbacks
✅ Faster recovery when a Gemini key is rate-limited

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@don-petry
don-petry requested a review from a team as a code owner September 13, 2026 03:49
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@codeant-ai

codeant-ai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR e08529d Sep 13, 2026 · 03:49 03:51

@codeant-ai

codeant-ai Bot commented Sep 13, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 02af2d8f-b689-4298-bf35-b704a9b624d8

📥 Commits

Reviewing files that changed from the base of the PR and between 56d8ccc and 09cc15f.

📒 Files selected for processing (9)
  • .github/workflows/dev-lead-reusable.yml
  • .github/workflows/pr-review.yml
  • scripts/engine.sh
  • scripts/review-batch.sh
  • scripts/validate-engines.sh
  • tests/dev-lead/fixtures/engines/stub-gemini
  • tests/dev-lead/unit/test_engine_fallback.bats
  • tests/dev-lead/unit/test_engine_gemini_35.bats
  • tests/dev-lead/unit/test_engine_gemini_keys.bats

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the default Gemini flash model to gemini-3.8-flash and adjusts the fallback engine order to claude → gemini → copilot. It also introduces per-key rotation for Gemini API keys (GEMINI_API_KEY, GOOGLE_API_KEY, GOOGLE_API_KEY_2, and GOOGLE_API_KEY_3) to handle rate limits gracefully before downgrading models or providers, along with corresponding unit tests. The review feedback suggests utilizing $BATS_TEST_TMPDIR in the new and updated BATS tests instead of manually managing temporary files and directories with mktemp and rm to ensure proper test isolation and automatic cleanup.

Comment thread tests/dev-lead/unit/test_engine_gemini_keys.bats
Comment thread tests/dev-lead/unit/test_engine_fallback.bats
Comment thread scripts/engine.sh
Comment thread scripts/engine.sh
Comment thread .github/workflows/pr-review.yml
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) September 13, 2026 03:52
@don-petry
don-petry disabled auto-merge September 13, 2026 03:53
@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) September 13, 2026 03:56
@don-petry
don-petry disabled auto-merge September 13, 2026 03:58
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) September 13, 2026 04:01
@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

@don-petry
don-petry disabled auto-merge September 13, 2026 04:03
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
- ✅ **0.0% Duplication on New Code**
Per the task instructions: *"A neutral overview is not an actionable finding. If the bot comment merely describes or summarizes the diff without reporting a specific, actionable defect tied to a file/line, there is nothing to fix."*
This SonarCloud comment is a **pass** — it reports zero issues found, which means there are no code quality, security, or duplication problems. This is not a finding to address; it's a clean result.
**CI Status Review:**
- No checks with failure/timeout/cancelled/action_required conclusions
- No reviews with `state` = `CHANGES_REQUESTED`
- Only `in_progress` and `queued` checks remain, which will complete naturally
**Conclusion:**
There are **zero Tier 1 blockers** (failed checks or change requests) and **zero actionable findings** from the SonarCloud bot. The PR has a passing quality gate with no issues to fix.
**No changes required.** The PR is clean from a code quality and security analysis perspective.

@don-petry
don-petry enabled auto-merge (squash) September 13, 2026 04:04
@donpetry-bot donpetry-bot added the needs-human-review Flagged by automated PR review agent label Sep 13, 2026
@don-petry
don-petry disabled auto-merge September 13, 2026 04:15
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
- Quality Gate passed (0 issues, 0 hotspots): No actionable defects reported
Files changed: None
Skipped (informational): 1
```
**No changes required.** The PR is in good standing — the SonarCloud comment is a passing status notification, not a defect report.

@don-petry
don-petry enabled auto-merge (squash) September 13, 2026 04:15
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-09-13T05:15:55Z.

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: db788cd35ef95fdc8337e136e484b520d91e92bb
Cascade: triage → audit (triage: haiku 4.5 [sonnet 5] → deep: opus 4.8 [sonnet 5] + duck: o4-mini → audit: fable 5)

Summary

Gemini multi-key rotation PR expands the credential surface (GOOGLE_API_KEY_2/_3) but handles it safely: optional secrets wired identically to the existing GOOGLE_API_KEY pattern into first-party scripts, no key value ever logged (warnings name variables only, billing probe uses a header not the URL), and rotation saves/restores caller key env correctly. All three unresolved CodeAnt majors that drove escalation are verified fixed at head SHA (validate-engines.sh accepts all four keys, engine.sh config-gap uses _gemini_api_keys with a secondary-only bats test, review-batch.sh matches the claude->gemini->copilot order). Remaining items are minor robustness/process nits, not security issues; human review is still required by branch protection.

Downstream impact

This change is consumed by 8 downstream repo(s) that pin the affected reusable workflow / lib / prompt. Impacted consumers:

Impacted shared surfaces:
  - .github/workflows/dev-lead-reusable.yml
  - .github/workflows/pr-review.yml

Impacted consumers (8, fetching up to 10):
  - petry-projects/.github (pins .github/workflows/dev-lead-reusable.yml)
      .github/workflows/dev-lead.yml
  - petry-projects/.github-private (pins .github/workflows/dev-lead-reusable.yml,.github/workflows/pr-review.yml)
      .github/workflows/dev-lead.yml
      .github/workflows/pr-review-canary.yml
      .github/workflows/pr-review-trigger.yml
      .github/workflows/test-dev-lead.yml
  - petry-projects/ContentTwin (pins .github/workflows/dev-lead-reusable.yml,.github/workflows/pr-review.yml)
      .github/workflows/dev-lead.yml
      .github/workflows/pr-review.yml
  - petry-projects/TalkTerm (pins .github/workflows/dev-lead-reusable.yml)
      .github/workflows/dev-lead.yml
  - petry-projects/bmad-bgreat-suite (pins .github/workflows/dev-lead-reusable.yml,.github/workflows/pr-review.yml)
      .github/workflows/dev-lead.yml
      .github/workflows/pr-review.yml
  - petry-projects/broodly (pins .github/workflows/dev-lead-reusable.yml)
      .github/workflows/dev-lead.yml
  - petry-projects/google-app-scripts (pins .github/workflows/dev-lead-reusable.yml,.github/workflows/pr-review.yml)
      .github/workflows/dev-lead.yml
      .github/workflows/pr-review.yml
  - petry-projects/markets (pins .github/workflows/dev-lead-reusable.yml,.github/workflows/pr-review.yml)
      .github/workflows/dev-lead.yml
      .github/workflows/pr-review.yml

Findings

  • info: New optional secrets GOOGLE_API_KEY_2/_3 forwarded into run-step env across dev-lead jobs. Verified benign: first-party pinned reusables, required:false (no downstream startup failures for the 8 pinned consumers), no echo of key values anywhere in the diff, rotation loop restores original GOOGLE_API_KEY/GEMINI_API_KEY with correct set/unset semantics, and STUB_ENGINE_RECORD_KEYS key-recording exists only in the test fixture with dummy keys.
  • minor: _gemini_billing_probe only probes the FIRST configured key. If the primary key's prepayment credits are depleted while GOOGLE_API_KEY_2/_3 still have credit, validate_engines marks Gemini unavailable and per-key rotation never gets a chance - partially undercutting the resilience goal of #1777. Suggest probing keys in _gemini_api_keys order until one is not billing-depleted. Availability gap, not a security issue.
  • minor: Nested default expansion ${GOOGLE_API_KEY_2:-${GOOGLE_API_KEY_3}} omits :- on the innermost variable; under set -u this is an unbound-variable crash if the first three keys are empty/unset and GOOGLE_API_KEY_3 is unset. Currently unreachable (the probe is only called after validate_engines confirms at least one non-empty key, and workflows always define the env vars), but a latent trap for future callers. Use ${GOOGLE_API_KEY_3:-}.
  • minor: review-batch.sh dropped the classic-PAT guard (COPILOT_GITHUB_TOKEN != ghp_*) when Copilot moved to last fallback; the copilot leg now gates only on COPILOT_AVAILABLE, which is derived from gh copilot --version and may pass with a classic PAT that then fails at Copilot API call time. engine.sh's own fallback path retains its guard. Failure mode is a skipped review with a warning, not a security exposure.
  • info: PR description lacks explicit risk/test-plan/rollback sections (DESCRIPTION_MISSING=3). Mitigating: rollback is a clean revert (new secrets are optional and additive), and the change ships a dedicated 193-line bats suite covering rotation, de-dup, config-gap recognition, and fallback ordering.

Reviewed by the PR-review cascade (triage: haiku 4.5 [sonnet 5] → deep: opus 4.8 [sonnet 5] + duck: o4-mini → audit: fable 5). Reply if you need a human review.

@donpetry-bot donpetry-bot removed the needs-human-review Flagged by automated PR review agent label Sep 13, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini is not working optimally

2 participants