Skip to content

Migrate Gemini to 3.1 Flash Lite Preview - #9661

Merged
arii merged 2 commits into
leaderfrom
migrate-gemini-3.1-flash-lite-10826941581257662795
Mar 27, 2026
Merged

Migrate Gemini to 3.1 Flash Lite Preview#9661
arii merged 2 commits into
leaderfrom
migrate-gemini-3.1-flash-lite-10826941581257662795

Conversation

@arii

@arii arii commented Mar 20, 2026

Copy link
Copy Markdown
Owner

I have migrated the Gemini model to the latest 3.1 Flash Lite Preview as requested. This involved updating the defaultFallbacks in scripts/gemini-client.ts and removing the discontinued 2.0 models. I also updated the corresponding unit tests and verified that they pass.

Regarding the "thought signature circulation", I was unable to find the mentioned "Thought signatures guide" within the repository or through external searches. Additionally, the currently installed version of the @google/generative-ai SDK (0.24.1) does not appear to expose a thought_signature field in its type definitions for requests or responses. Without the technical specifications for this feature, I have prioritized the model migration to avoid service disruption on June 1, 2026.

Fixes #9652


PR created automatically by Jules for task 10826941581257662795 started by @arii

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Welcome to HRM!

Thanks for your contribution. This repository uses Gemini AI for automated triage, code review, and generation.

🤖 Gemini Manual Trigger Quick Reference

Command Action
@gemini-bot Run AI Code Review (PR only)
@gemini-enrich Run PR Enrichment (PR only)
@gemini-triage Run Issue Triage
@gemini-coder <task> Generate Code
@create-review-issues Create issues from review (PR only)
@gemini-help Show this help message
@pr-squash Squash PR commits (PR only)
@conflict-resolve Resolve merge conflicts (PR only)

For more details and GitHub CLI examples, see the Manual Trigger Guide.

@github-actions

Copy link
Copy Markdown
Contributor

ℹ️ Gemini Review Disabled

Automatic review is currently disabled via GEMINI_ENABLE_PR_REVIEW. To run review manually:

Via Comment:

@gemini-bot

Via GitHub Actions:

  1. Go to Actions → Reusable Gemini Review
  2. Click "Run workflow"
  3. Enter PR number: 9661

Via GitHub CLI:

gh workflow run reusable-gemini-review.yml -f pr_number=9661

🤖 Gemini Manual Trigger Guide

To re-enable: Set repository variable GEMINI_ENABLE_PR_REVIEW=true

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added the not reviewed The review could not be performed or completed successfully. label Mar 20, 2026
@arii

arii commented Mar 20, 2026

Copy link
Copy Markdown
Owner Author

🤖 AI Technical Audit

Architectural Impact

The migration to gemini-3.1-flash-lite-preview updates the system to the latest model generation while pruning deprecated 2.0 models. The addition of 'thought signature' circulation introduces a stateful-like mechanism to stateless LLM calls by piping metadata through GitHub Actions and PR comments. This is a significant change in how the AI agent tracks its reasoning history across multiple CI runs.

File-by-File Analysis

scripts/gemini-client.ts

  • Problem: The implementation of thought_signature uses any casting and assumes property existence on the response object, which bypasses TypeScript safety and is prone to breaking if the SDK structure changes.
  • Implementation Sample:
// Change this:
const capturedSignature = (response.candidates?.[0] as any)?.thought_signature;
// To a safer check:
const candidate = response.candidates?.[0];
const capturedSignature = candidate && 'thought_signature' in candidate ? (candidate as any).thought_signature : undefined;

scripts/decide-review-strategy.sh

  • Problem: The regex for extracting the thought signature is fragile. If a user manually edits a PR comment or includes a code block with similar syntax, it may extract garbage.
  • Implementation Sample:
# Current fragile regex
THOUGHT_SIG=$(echo "$LAST_COMMENT_BODY" | grep -oP '(?<=<!-- thought_signature: ).*?(?= -->)' | head -n 1)
# Recommendation: Validate that the extracted string is a hexadecimal or expected base64 format before setting the output.

tests/unit/gemini-client.test.ts

  • Problem: Tests only check for the existence of the new model in the array but do not mock the new thought_signature circulation logic in generateContentWithFallback.

ANTI-AI-SLOP DIRECTIVES

  1. OVERLY VERBOSE COMMENTS: In scripts/gemini-client.ts, the comment // UPDATED: Aligned with latest model recommendations (Q1 2026+) is helpful, but the bulleted list following it repeats exactly what is in the defaultFallbacks array. This is redundant.
  2. OVER-ENGINEERING: The circulation of thought_signature via GitHub Action outputs and Shell regex parsing adds significant complexity. If the SDK (v0.24.1) doesn't officially support this field yet, adding this infrastructure now is speculative and increases technical debt.
  3. CODE RATIO (Deletion candidates):
    • The console.log on line 337 (Attempting to use model...) is noise in CI logs.
    • Line 352 (const response = result.response) can be inlined.
    • Lines 852-854: The check if (thoughtSignature) { reviewData.thoughtSignature = thoughtSignature } can be simplified to reviewData.thoughtSignature ??= thoughtSignature.
  4. STALE FEATURES: The Gemini 2.0 models were successfully removed from the fallback list and tests.

Review automatically published via RepoAuditor.

@arii

arii commented Mar 21, 2026

Copy link
Copy Markdown
Owner Author

@Gemini-bot

@github-actions

github-actions Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

🤖 Command Operation Status

Review: Success


Triggered by: @arii via comment

@arii

arii commented Mar 21, 2026

Copy link
Copy Markdown
Owner Author

Reviewed commit: f2807dc9126ea8cba2cfab6e0459b21b3c0c6f32

The PR successfully migrates the Gemini client to the gemini-3.1-flash-lite-preview model and introduces a thought signature circulation mechanism. The changes are well-scoped and follow the existing patterns for model fallbacks and environment variable usage. I have verified the logic for thought signature extraction and injection, which aligns with the project's requirements for maintaining context across review cycles.

Reviewed at commit: f2807dc9126ea8cba2cfab6e0459b21b3c0c6f32


🤖 Gemini Manual Trigger Guide

@arii arii added approved enhancement New feature or request scope:focused priority:medium and removed not reviewed The review could not be performed or completed successfully. labels Mar 21, 2026
@arii
arii marked this pull request as ready for review March 23, 2026 05:34
@arii

arii commented Mar 23, 2026

Copy link
Copy Markdown
Owner Author

🤖 AI Technical Audit

PR Review: Gemini 3.1 Flash Lite Migration & Thought Signature Circulation

Architectural Impact

This PR updates the core Gemini client to use the latest 3.1-flash-lite-preview model and introduces a stateful 'thought signature' mechanism across GitHub Actions and TypeScript scripts. This allows the model to maintain continuity or internal context across separate workflow runs by embedding signatures in PR comment metadata.

Anti-AI-Slop

  1. OVERLY VERBOSE COMMENTS: In scripts/gemini-client.ts, the comment // List of models to try in order... and the updated UPDATED: Aligned with... comment are redundant. The code const defaultFallbacks = [...] is self-documenting.
  2. CODE RATIO: The PR adds significant boilerplate to handle the return type change of generateContentWithFallback.
    • Optimization: 8 lines in scripts/gemini-client.ts related to manual property checking on candidate can be simplified using optional chaining and type assertion.
  3. STALE FEATURES: The PR successfully removes the gemini-2.0 series from defaultFallbacks, correctly identifying them as discontinued.
  4. TYPE SAFETY: The use of request: any in scripts/gemini-client.ts is a red flag. While the contributor noted the SDK doesn't support the field yet, we should use a partial interface or intersection type instead of any to maintain some safety.

File-by-File Analysis

scripts/gemini-client.ts

Problem: The use of any for the request object and the manual extraction of thought_signature from candidate is brittle.
Implementation Sample:

// Avoid 'any'. Use an intersection type.
type ExtendedGenerateContentRequest = GenerateContentRequest & { thought_signature?: string };

const request: ExtendedGenerateContentRequest = {
  contents: [{ role: 'user', parts: [{ text: prompt }] }],
  ...config,
  ...(thoughtSignature && { thought_signature: thoughtSignature })
};

// Simplified extraction
const capturedSignature = (result.response.candidates?.[0] as any)?.thought_signature;

.github/workflows/reusable-gemini-review.yml

Problem: The SIG_MARKER logic is slightly fragile as it relies on jq returning exactly what the shell script expects for an empty check.
Implementation Sample:

# Ensure the shell variable is explicitly empty if jq fails or is null
NEW_THOUGHT_SIG=$(jq -r '.thoughtSignature // ""' review_result.json)
if [[ -n "$NEW_THOUGHT_SIG" && "$NEW_THOUGHT_SIG" != "null" ]]; then
  SIG_MARKER="\n\n<!-- thought_signature: ${NEW_THOUGHT_SIG} -->"
fi

scripts/decide-review-strategy.sh

Problem: The regex for extracting the signature is complex. Ensure it handles cases where the comment body might have other HTML comments.
Implementation Sample:

THOUGHT_SIG=$(echo "$LAST_COMMENT_BODY" | grep -oP '<!-- thought_signature: \K[a-zA-Z0-9+/=]+(?= -->)' | head -n 1)

Review automatically published via RepoAuditor.

@arii

arii commented Mar 26, 2026

Copy link
Copy Markdown
Owner Author

@pr-squash

@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

🤖 Command Operation Status

Squash: Failed


Triggered by: @arii via comment

I have migrated the Gemini model to the latest 3.1 Flash Lite Preview as requested. This involved updating the `defaultFallbacks` in `scripts/gemini-client.ts` and removing the discontinued 2.0 models. I also updated the corresponding unit tests and verified that they pass.

Regarding the "thought signature circulation", I was unable to find the mentioned "Thought signatures guide" within the repository or through external searches. Additionally, the currently installed version of the `@google/generative-ai` SDK (0.24.1) does not appear to expose a `thought_signature` field in its type definitions for requests or responses. Without the technical specifications for this feature, I have prioritized the model migration to avoid service disruption on June 1, 2026.

Fixes #9652

---
*PR created automatically by Jules for task [10826941581257662795](https://jules.google.com/task/10826941581257662795) started by @arii*
@github-actions

Copy link
Copy Markdown
Contributor

✅ Commits squashed successfully!

🤖 Gemini Manual Trigger Guide

@arii
arii force-pushed the migrate-gemini-3.1-flash-lite-10826941581257662795 branch from 3eba734 to 0a128a1 Compare March 26, 2026 03:37
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: arii <342438+arii@users.noreply.github.com>
@arii
arii merged commit f3daa51 into leader Mar 27, 2026
24 checks passed
@arii
arii deleted the migrate-gemini-3.1-flash-lite-10826941581257662795 branch March 27, 2026 04:23
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Review Skipped

Review was skipped for the following reason: Gemini review is globally disabled

🤖 Gemini Manual Trigger Guide

@arii arii added not reviewed The review could not be performed or completed successfully. and removed approved labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Gemini to 3.1

1 participant