Skip to content

fix(llms): give gemini -latest aliases full tool capabilities - #7639

Open
Madin-H23 wants to merge 1 commit into
crewAIInc:mainfrom
Madin-H23:fix/gemini-latest-alias-capabilities
Open

Madin-H23 wants to merge 1 commit into
crewAIInc:mainfrom
Madin-H23:fix/gemini-latest-alias-capabilities

Conversation

@Madin-H23

Copy link
Copy Markdown

Related issue

Fixes #7636

Summary

The version-less aliases listed in GEMINI_MODELS (gemini-flash-latest, gemini-flash-lite-latest, gemini-pro-latest) never match the gemini-<version> regex in _normalize_gemini_fields, so they fell back to pre-1.5 defaults: supports_tools=False dropped tools from GenerateContentConfig entirely, supports_function_calling() returned False (silently downgrading agents to the ReAct protocol), structured output took the legacy response_schema path, and thinking was not auto-enabled.

Following the approach sketched in the issue (same shape as the Anthropic fix in #4009): a new GEMINI_LATEST_ALIASES map in llms/constants.py (next to GEMINI_MODELS) resolves the three aliases to the 2.5 generation when the version regex misses. The regex itself is untouched, so ids like gemini-gemma-2-27b-it — which carry a version but no function calling — keep the pre-1.5 defaults.

Verification

  • pytest lib/crewai/tests/llms/google/test_google.py -n0 → all previously-passing tests still pass (the 9 pre-existing cassette-based failures reproduce identically on unpatched main); the new tests add 4 passes:
    • parametrized over all three aliases: supports_tools is True and supports_function_calling() is True
    • gemini-gemma-2-27b-it guard: still supports_tools == False — pins that the alias map doesn't loosen the regex
    • red-check: the alias tests fail against unpatched main (verified via git stash)
  • ruff check / ruff format --check clean on all three files.

Additional context

Out of scope per the issue: gemini-robotics-er-1.5-preview and the gemini-live-* ids.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: cb331489-6ea6-4d8b-b327-12aa1c6f17c0

📥 Commits

Reviewing files that changed from the base of the PR and between 8fee803 and 8f96fdb.

📒 Files selected for processing (1)
  • lib/crewai/src/crewai/llms/providers/gemini/completion.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/crewai/src/crewai/llms/providers/gemini/completion.py

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Gemini capability detection now resolves three version-less latest aliases to generation 2.5. This enables the corresponding tool, function-calling, Gemini 2.0, and automatic-thinking behavior. Tests cover these aliases and preserve Gemma behavior.

Changes

Gemini alias capabilities

Layer / File(s) Summary
Gemini alias capability resolution
lib/crewai/src/crewai/llms/constants.py, lib/crewai/src/crewai/llms/providers/gemini/completion.py
Adds explicit generation mappings for three -latest aliases. Capability detection uses numeric versions or the alias map, then applies tool, Gemini 2.0, and automatic-thinking thresholds.
Gemini alias regression coverage
lib/crewai/tests/llms/google/test_google.py
Tests tool and native function-calling support for the three latest aliases and confirms that the Gemma alias remains without tool support.

Priority: ➖ Normal

Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Gemini -latest alias fix and the restored tool capabilities. It is concise and directly related to the main change.
Description check ✅ Passed The description includes the related issue, a detailed summary, verification results, test coverage, lint and formatting checks, known baseline failures, and out-of-scope models. It satisfies the requ…
Linked Issues check ✅ Passed The pull request satisfies #7636. GEMINI_LATEST_ALIASES maps the three version-less aliases to 2.5. _normalize_gemini_fields uses this map when the numeric version regex does not match. The resolv…
Out of Scope Changes check ✅ Passed The current pull request summary identifies changes in the Gemini constants, Gemini completion logic, and related Gemini tests. These changes support #7636. The explicit map contains only the three re…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@Madin-H23
Madin-H23 force-pushed the fix/gemini-latest-alias-capabilities branch from 81eaf2e to 8fee803 Compare September 19, 2026 18:18
The version-less aliases listed in GEMINI_MODELS (gemini-flash-latest,
gemini-flash-lite-latest, gemini-pro-latest) never match the
gemini-<version> regex in _normalize_gemini_fields, so they fell back to
pre-1.5 defaults: supports_tools=False dropped tools from
GenerateContentConfig entirely, supports_function_calling() returned
False (silently downgrading agents to the ReAct protocol), structured
output took the legacy path, and thinking was not auto-enabled.

Resolve them through an explicit alias map in constants.py — same shape
as the Anthropic fix in crewAIInc#4009 — instead of loosening the regex, which
would mis-detect ids like gemini-gemma-2-27b-it (no function calling)
by the digits in their names.

Fixes crewAIInc#7636

Signed-off-by: Weijian He <230282609+Madin-H23@users.noreply.github.com>
@Madin-H23
Madin-H23 force-pushed the fix/gemini-latest-alias-capabilities branch from 8fee803 to 8f96fdb Compare September 19, 2026 18:21
@Madin-H23

Copy link
Copy Markdown
Author

CodeRabbit's out-of-scope warning was correct: this branch was cut from the working branch of #7587 and carried that commit. The branch is now rebased onto current main — the diff contains only the Gemini alias fix (3 files) plus the docstring for _normalize_gemini_fields (addressing the docstring-coverage warning). Tests re-run after the rebase: 48 passed, the 9 failures are the pre-existing cassette-based ones that reproduce identically on unpatched main.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant