Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

google_ai: Add Gemini 4 Argon (#65565)

Lorenzo Biassio76b8ab814f0d
diff --git a/crates/google_ai/src/completion.rs b/crates/google_ai/src/completion.rs
index 67f44b38359..6818dea4cf2 100644
--- a/crates/google_ai/src/completion.rs
+++ b/crates/google_ai/src/completion.rs
@@ -249,17 +249,20 @@ impl ThinkingConfig {
}
fn is_google_thinking_model(model_id: &str) -> bool {
- model_id.starts_with("gemini-2.5-") || model_id.starts_with("gemini-3")
+ model_id.starts_with("gemini-2.5-")
+ || model_id.starts_with("gemini-3")
+ || model_id.starts_with("gemini-4")
}
fn disabled_thinking_level(model_id: &str) -> Option<ThinkingLevel> {
match model_id {
- // Gemini 3.7 and 3.8 Flash reject `MINIMAL` with a validation error, so
- // `LOW` is the lowest level available to them.
+ // Gemini 3.7 and 3.8 Flash and Gemini 4 Argon reject `MINIMAL` with a
+ // validation error, so `LOW` is the lowest level available to them.
model_id
if model_id.starts_with("gemini-3.7-flash")
|| model_id.starts_with("gemini-3.8-flash")
- || (model_id.starts_with("gemini-3") && model_id.contains("-pro")) =>
+ || (model_id.starts_with("gemini-3") && model_id.contains("-pro"))
+ || (model_id.starts_with("gemini-4") && model_id.contains("-argon")) =>
{
Some(ThinkingLevel::Low)
}
@@ -884,6 +887,10 @@ mod tests {
#[test]
fn test_disabled_thinking_level_per_model() {
+ assert_eq!(
+ disabled_thinking_level("gemini-4-argon"),
+ Some(ThinkingLevel::Low)
+ );
assert_eq!(
disabled_thinking_level("gemini-3.8-flash"),
Some(ThinkingLevel::Low)
diff --git a/crates/google_ai/src/google_ai.rs b/crates/google_ai/src/google_ai.rs
index a1be7e05299..77d3e8656a7 100644
--- a/crates/google_ai/src/google_ai.rs
+++ b/crates/google_ai/src/google_ai.rs
@@ -649,6 +649,8 @@ pub enum Model {
Gemini38Flash,
#[serde(rename = "gemini-3.1-pro-preview")]
Gemini31Pro,
+ #[serde(rename = "gemini-4-argon")]
+ Gemini4Argon,
#[serde(rename = "custom")]
Custom {
name: String,
@@ -674,6 +676,7 @@ impl Model {
Self::Gemini37Flash => "gemini-3.7-flash",
Self::Gemini38Flash => "gemini-3.8-flash",
Self::Gemini31Pro => "gemini-3.1-pro-preview",
+ Self::Gemini4Argon => "gemini-4-argon",
Self::Custom { name, .. } => name,
}
}
@@ -686,6 +689,7 @@ impl Model {
Self::Gemini37Flash => "gemini-3.7-flash",
Self::Gemini38Flash => "gemini-3.8-flash",
Self::Gemini31Pro => "gemini-3.1-pro-preview",
+ Self::Gemini4Argon => "gemini-4-argon",
Self::Custom { name, .. } => name,
}
}
@@ -699,6 +703,7 @@ impl Model {
Self::Gemini37Flash => "Gemini 3.7 Flash",
Self::Gemini38Flash => "Gemini 3.8 Flash",
Self::Gemini31Pro => "Gemini 3.1 Pro",
+ Self::Gemini4Argon => "Gemini 4 Argon",
Self::Custom {
name, display_name, ..
} => display_name.as_ref().unwrap_or(name),
@@ -713,7 +718,8 @@ impl Model {
| Self::Gemini36Flash
| Self::Gemini37Flash
| Self::Gemini38Flash
- | Self::Gemini31Pro => 1_048_576,
+ | Self::Gemini31Pro
+ | Self::Gemini4Argon => 1_048_576,
Self::Custom { max_tokens, .. } => *max_tokens,
}
}
@@ -726,7 +732,8 @@ impl Model {
| Model::Gemini36Flash
| Model::Gemini37Flash
| Model::Gemini38Flash
- | Model::Gemini31Pro => Some(65_536),
+ | Model::Gemini31Pro
+ | Model::Gemini4Argon => Some(65_536),
Model::Custom { .. } => None,
}
}
@@ -749,6 +756,7 @@ impl Model {
| Self::Gemini37Flash
| Self::Gemini38Flash
| Self::Gemini31Pro
+ | Self::Gemini4Argon
| Self::Custom {
mode: GoogleModelMode::Thinking { .. },
..
@@ -767,11 +775,13 @@ impl Model {
ThinkingLevel::Medium,
ThinkingLevel::High,
],
- Self::Gemini37Flash | Self::Gemini38Flash | Self::Gemini31Pro => &[
- ThinkingLevel::Low,
- ThinkingLevel::Medium,
- ThinkingLevel::High,
- ],
+ Self::Gemini37Flash | Self::Gemini38Flash | Self::Gemini31Pro | Self::Gemini4Argon => {
+ &[
+ ThinkingLevel::Low,
+ ThinkingLevel::Medium,
+ ThinkingLevel::High,
+ ]
+ }
_ => &[],
}
}
@@ -785,6 +795,7 @@ impl Model {
Self::Gemini37Flash => Some(ThinkingLevel::Medium),
Self::Gemini38Flash => Some(ThinkingLevel::Medium),
Self::Gemini31Pro => Some(ThinkingLevel::High),
+ Self::Gemini4Argon => Some(ThinkingLevel::Medium),
_ => None,
}
}
@@ -797,7 +808,8 @@ impl Model {
| Self::Gemini36Flash
| Self::Gemini37Flash
| Self::Gemini38Flash
- | Self::Gemini31Pro => GoogleModelMode::Thinking {
+ | Self::Gemini31Pro
+ | Self::Gemini4Argon => GoogleModelMode::Thinking {
budget_tokens: None,
},
Self::Custom { mode, .. } => *mode,
@@ -815,6 +827,7 @@ impl std::fmt::Display for Model {
mod tests {
use super::*;
use serde_json::json;
+ use strum::IntoEnumIterator;
#[test]
fn test_gemini_3_6_flash_model_metadata() {
@@ -898,6 +911,46 @@ mod tests {
assert_eq!(deserialized, Model::Gemini38Flash);
}
+ #[test]
+ fn test_gemini_4_argon_model_metadata() {
+ let model = Model::Gemini4Argon;
+ assert_eq!(model.id(), "gemini-4-argon");
+ assert_eq!(model.request_id(), "gemini-4-argon");
+ assert_eq!(model.display_name(), "Gemini 4 Argon");
+ assert_eq!(model.max_token_count(), 1_048_576);
+ assert_eq!(model.max_output_tokens(), Some(65_536));
+ assert!(model.supports_thinking());
+ assert_eq!(
+ model.supported_thinking_levels(),
+ &[
+ ThinkingLevel::Low,
+ ThinkingLevel::Medium,
+ ThinkingLevel::High
+ ]
+ );
+ assert_eq!(model.default_thinking_level(), Some(ThinkingLevel::Medium));
+
+ let serialized = serde_json::to_value(&model).unwrap();
+ assert_eq!(serialized, json!("gemini-4-argon"));
+ let deserialized: Model = serde_json::from_value(json!("gemini-4-argon")).unwrap();
+ assert_eq!(deserialized, Model::Gemini4Argon);
+ }
+
+ #[test]
+ fn test_max_output_tokens_leave_room_for_input() {
+ // The agent reserves `max_output_tokens` from the shared context window,
+ // so an output limit equal to the window leaves no room for input.
+ for model in Model::iter() {
+ if let Some(max_output_tokens) = model.max_output_tokens() {
+ assert!(
+ max_output_tokens < model.max_token_count(),
+ "{} reserves its whole context window for output",
+ model.id()
+ );
+ }
+ }
+ }
+
#[test]
fn test_function_call_part_with_signature_serializes_correctly() {
let part = FunctionCallPart {