Skip to content

Commit a978267

Browse files
feat: Add gemini-3-pro-preview (#3950)
* Add gemini-3-pro-preview Also refactors the tool support check for better forward compatibility. * Add cassette for Gemini 3 Pro --------- Co-authored-by: Greyson LaLonde <greyson.r.lalonde@gmail.com>
1 parent b759654 commit a978267

File tree

7 files changed

+78
-5
lines changed

7 files changed

+78
-5
lines changed

lib/crewai/src/crewai/cli/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"claude-3-haiku-20240307",
146146
],
147147
"gemini": [
148+
"gemini/gemini-3-pro-preview",
148149
"gemini/gemini-1.5-flash",
149150
"gemini/gemini-1.5-pro",
150151
"gemini/gemini-2.0-flash-lite-001",

lib/crewai/src/crewai/llm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def writable(self) -> bool:
179179
"o3-mini": 200000,
180180
"o4-mini": 200000,
181181
# gemini
182+
"gemini-3-pro-preview": 1048576,
182183
"gemini-2.0-flash": 1048576,
183184
"gemini-2.0-flash-thinking-exp-01-21": 32768,
184185
"gemini-2.0-flash-lite-001": 1048576,

lib/crewai/src/crewai/llms/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@
235235
]
236236

237237
GeminiModels: TypeAlias = Literal[
238+
"gemini-3-pro-preview",
238239
"gemini-2.5-pro",
239240
"gemini-2.5-pro-preview-03-25",
240241
"gemini-2.5-pro-preview-05-06",
@@ -287,6 +288,7 @@
287288
"learnlm-2.0-flash-experimental",
288289
]
289290
GEMINI_MODELS: list[GeminiModels] = [
291+
"gemini-3-pro-preview",
290292
"gemini-2.5-pro",
291293
"gemini-2.5-pro-preview-03-25",
292294
"gemini-2.5-pro-preview-05-06",

lib/crewai/src/crewai/llms/providers/gemini/completion.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
import re
34
from typing import Any, cast
45

56
from pydantic import BaseModel
@@ -100,9 +101,8 @@ def __init__(
100101
self.stop_sequences = stop_sequences or []
101102

102103
# Model-specific settings
103-
self.is_gemini_2 = "gemini-2" in model.lower()
104-
self.is_gemini_1_5 = "gemini-1.5" in model.lower()
105-
self.supports_tools = self.is_gemini_1_5 or self.is_gemini_2
104+
version_match = re.search(r"gemini-(\d+(?:\.\d+)?)", model.lower())
105+
self.supports_tools = bool(version_match and float(version_match.group(1)) >= 1.5)
106106

107107
@property
108108
def stop(self) -> list[str]:
@@ -559,6 +559,7 @@ def get_context_window_size(self) -> int:
559559
)
560560

561561
context_windows = {
562+
"gemini-3-pro-preview": 1048576, # 1M tokens
562563
"gemini-2.0-flash": 1048576, # 1M tokens
563564
"gemini-2.0-flash-thinking": 32768,
564565
"gemini-2.0-flash-lite": 1048576,
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
interactions:
2+
- request:
3+
body: '{"contents":[{"role":"user","parts":[{"text":"What is the capital of France?"}]}],"generationConfig":{"stop_sequences":[]}}'
4+
headers:
5+
accept:
6+
- '*/*'
7+
accept-encoding:
8+
- gzip, deflate
9+
connection:
10+
- keep-alive
11+
content-length:
12+
- '123'
13+
content-type:
14+
- application/json
15+
host:
16+
- generativelanguage.googleapis.com
17+
user-agent:
18+
- litellm/1.78.5
19+
method: POST
20+
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent
21+
response:
22+
body:
23+
string: !!binary |
24+
H4sIAAAAAAAC/21UW4+iSBh9719heGxmBgFvbDIPgKAgNwUV3OxDCSWU3KFApdP/fWl77XF2l6RI
25+
5ftOnVN1ku+8vQwGhA+yAAUAw5r4Y/BnXxkM3u7/j16eYZjhvvEo9cUCVPgX9vN7e9r3EAyvH4cI
26+
J4IDHxQIg2SQnwZyBTIfDlA9eH21QIXq19cfxLd/HY3yJoywjcIM4KaCHzRSvZbEWpL4YIlRytG8
27+
a3eo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r50a3aquVZ2uPeHl/+RvdmjG6dAUAAA==
41+
headers:
42+
Alt-Svc:
43+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
44+
Content-Encoding:
45+
- gzip
46+
Content-Type:
47+
- application/json; charset=UTF-8
48+
Date:
49+
- Wed, 19 Nov 2025 08:56:53 GMT
50+
Server:
51+
- scaffolding on HTTPServer2
52+
Server-Timing:
53+
- gfet4t7; dur=2508
54+
Transfer-Encoding:
55+
- chunked
56+
Vary:
57+
- Origin
58+
- X-Origin
59+
- Referer
60+
X-Content-Type-Options:
61+
- nosniff
62+
X-Frame-Options:
63+
- SAMEORIGIN
64+
X-XSS-Protection:
65+
- '0'
66+
status:
67+
code: 200
68+
message: OK
69+
version: 1

lib/crewai/tests/llms/google/test_google.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,11 @@ def test_gemini_model_capabilities():
455455
llm_2_0 = LLM(model="google/gemini-2.0-flash-001")
456456
from crewai.llms.providers.gemini.completion import GeminiCompletion
457457
assert isinstance(llm_2_0, GeminiCompletion)
458-
assert llm_2_0.is_gemini_2 == True
459458
assert llm_2_0.supports_tools == True
460459

461460
# Test Gemini 1.5 model
462461
llm_1_5 = LLM(model="google/gemini-1.5-pro")
463462
assert isinstance(llm_1_5, GeminiCompletion)
464-
assert llm_1_5.is_gemini_1_5 == True
465463
assert llm_1_5.supports_tools == True
466464

467465

lib/crewai/tests/test_llm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def test_validate_call_params_no_response_format():
259259
@pytest.mark.parametrize(
260260
"model",
261261
[
262+
"gemini/gemini-3-pro-preview",
262263
"gemini/gemini-2.0-flash-thinking-exp-01-21",
263264
"gemini/gemini-2.0-flash-001",
264265
"gemini/gemini-2.0-flash-lite-001",

0 commit comments

Comments
 (0)