Merge pull request #818 from wanzhao-ysy/fix/antigravity-omit-agent-request-type

fix(antigravity): omit agent requestType from v1internal envelope
This commit is contained in:
ZheFox
2026-09-15 10:02:55 +08:00
committed by GitHub
7 changed files with 22 additions and 15 deletions
@@ -2763,7 +2763,7 @@ mod tests {
payload.provider_request_body["userAgent"], payload.provider_request_body["userAgent"],
"vscode/1.X.X (Antigravity/4.3.0)" "vscode/1.X.X (Antigravity/4.3.0)"
); );
assert_eq!(payload.provider_request_body["requestType"], "agent"); assert!(payload.provider_request_body.get("requestType").is_none());
assert!(payload.provider_request_body.get("contents").is_none()); assert!(payload.provider_request_body.get("contents").is_none());
assert!(payload.provider_request_body["request"] assert!(payload.provider_request_body["request"]
.get("contents") .get("contents")
@@ -1972,7 +1972,7 @@ async fn gateway_executes_openai_chat_antigravity_cross_format_sync_via_local_fi
seen_execution_runtime_request.user_agent, seen_execution_runtime_request.user_agent,
aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT
); );
assert_eq!(seen_execution_runtime_request.request_type, "agent"); assert_eq!(seen_execution_runtime_request.request_type, "");
assert_eq!(seen_execution_runtime_request.contents_len, 1); assert_eq!(seen_execution_runtime_request.contents_len, 1);
assert!(!seen_execution_runtime_request.request_has_model); assert!(!seen_execution_runtime_request.request_has_model);
@@ -1570,7 +1570,7 @@ async fn gateway_executes_openai_responses_antigravity_cross_format_upstream_str
seen_remote_execution_runtime_request.user_agent, seen_remote_execution_runtime_request.user_agent,
aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT
); );
assert_eq!(seen_remote_execution_runtime_request.request_type, "agent"); assert_eq!(seen_remote_execution_runtime_request.request_type, "");
assert_eq!(seen_remote_execution_runtime_request.contents_len, 1); assert_eq!(seen_remote_execution_runtime_request.contents_len, 1);
assert!(!seen_remote_execution_runtime_request.request_has_model); assert!(!seen_remote_execution_runtime_request.request_has_model);
@@ -2155,7 +2155,7 @@ async fn gateway_executes_antigravity_gemini_cli_sync_upstream_stream_via_local_
seen_remote_execution_runtime_request.user_agent, seen_remote_execution_runtime_request.user_agent,
aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT
); );
assert_eq!(seen_remote_execution_runtime_request.request_type, "agent"); assert_eq!(seen_remote_execution_runtime_request.request_type, "");
assert_eq!(seen_remote_execution_runtime_request.contents_len, 0); assert_eq!(seen_remote_execution_runtime_request.contents_len, 0);
assert!((seen_remote_execution_runtime_request.exact_temperature - 0.2).abs() < f64::EPSILON); assert!((seen_remote_execution_runtime_request.exact_temperature - 0.2).abs() < f64::EPSILON);
assert!(!seen_remote_execution_runtime_request.request_has_model); assert!(!seen_remote_execution_runtime_request.request_has_model);
@@ -2060,7 +2060,7 @@ async fn gateway_executes_antigravity_gemini_cli_stream_via_local_decision_gate_
seen_execution_runtime_request.user_agent, seen_execution_runtime_request.user_agent,
aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT
); );
assert_eq!(seen_execution_runtime_request.request_type, "agent"); assert_eq!(seen_execution_runtime_request.request_type, "");
assert_eq!(seen_execution_runtime_request.contents_len, 0); assert_eq!(seen_execution_runtime_request.contents_len, 0);
assert!((seen_execution_runtime_request.exact_temperature - 0.2).abs() < f64::EPSILON); assert!((seen_execution_runtime_request.exact_temperature - 0.2).abs() < f64::EPSILON);
assert!(!seen_execution_runtime_request.request_has_model); assert!(!seen_execution_runtime_request.request_has_model);
@@ -2374,7 +2374,7 @@ async fn gateway_executes_antigravity_gemini_cli_sync_via_local_decision_gate_af
seen_execution_runtime_request.user_agent, seen_execution_runtime_request.user_agent,
aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT aether_provider_transport::antigravity::ANTIGRAVITY_REQUEST_USER_AGENT
); );
assert_eq!(seen_execution_runtime_request.request_type, "agent"); assert_eq!(seen_execution_runtime_request.request_type, "");
assert_eq!(seen_execution_runtime_request.contents_len, 0); assert_eq!(seen_execution_runtime_request.contents_len, 0);
assert!((seen_execution_runtime_request.exact_temperature - 0.2).abs() < f64::EPSILON); assert!((seen_execution_runtime_request.exact_temperature - 0.2).abs() < f64::EPSILON);
assert!(!seen_execution_runtime_request.request_has_model); assert!(!seen_execution_runtime_request.request_has_model);
@@ -83,17 +83,21 @@ pub fn build_antigravity_safe_v1internal_request(
let request_id = non_empty_string_field(source, "requestId").unwrap_or(request_id); let request_id = non_empty_string_field(source, "requestId").unwrap_or(request_id);
let user_agent = let user_agent =
non_empty_string_field(source, "userAgent").unwrap_or(ANTIGRAVITY_REQUEST_USER_AGENT); non_empty_string_field(source, "userAgent").unwrap_or(ANTIGRAVITY_REQUEST_USER_AGENT);
let request_type = let existing_request_type = existing_v1internal_request_type(source);
existing_v1internal_request_type(source).unwrap_or_else(|| request_type.as_str());
return AntigravityRequestEnvelopeSupport::Supported(serde_json::json!({ let mut envelope = serde_json::json!({
"project": auth.project_id, "project": auth.project_id,
"requestId": request_id, "requestId": request_id,
"request": Value::Object(inner_request), "request": Value::Object(inner_request),
"model": model, "model": model,
"userAgent": user_agent, "userAgent": user_agent,
"requestType": request_type, });
})); if let Some(existing_request_type) = existing_request_type {
envelope["requestType"] = Value::String(existing_request_type.to_string());
} else if request_type != AntigravityEnvelopeRequestType::Agent {
envelope["requestType"] = Value::String(request_type.as_str().to_string());
}
return AntigravityRequestEnvelopeSupport::Supported(envelope);
} }
let mut inner_request: Map<String, Value> = source.clone(); let mut inner_request: Map<String, Value> = source.clone();
@@ -103,14 +107,17 @@ pub fn build_antigravity_safe_v1internal_request(
normalize_antigravity_builtin_tool_names(&mut inner_request); normalize_antigravity_builtin_tool_names(&mut inner_request);
normalize_antigravity_function_declaration_parameters(&mut inner_request); normalize_antigravity_function_declaration_parameters(&mut inner_request);
AntigravityRequestEnvelopeSupport::Supported(serde_json::json!({ let mut envelope = serde_json::json!({
"project": auth.project_id, "project": auth.project_id,
"requestId": request_id, "requestId": request_id,
"request": Value::Object(inner_request), "request": Value::Object(inner_request),
"model": model, "model": model,
"userAgent": ANTIGRAVITY_REQUEST_USER_AGENT, "userAgent": ANTIGRAVITY_REQUEST_USER_AGENT,
"requestType": request_type.as_str(), });
})) if request_type != AntigravityEnvelopeRequestType::Agent {
envelope["requestType"] = Value::String(request_type.as_str().to_string());
}
AntigravityRequestEnvelopeSupport::Supported(envelope)
} }
/// Antigravity's private v1internal Gemini surface still uses the legacy /// Antigravity's private v1internal Gemini surface still uses the legacy
@@ -298,7 +305,7 @@ mod tests {
assert_eq!(envelope["requestId"], "request-ant-agent-123"); assert_eq!(envelope["requestId"], "request-ant-agent-123");
assert_eq!(envelope["model"], "gemini-3.5-flash-low"); assert_eq!(envelope["model"], "gemini-3.5-flash-low");
assert_eq!(envelope["userAgent"], ANTIGRAVITY_REQUEST_USER_AGENT); assert_eq!(envelope["userAgent"], ANTIGRAVITY_REQUEST_USER_AGENT);
assert_eq!(envelope["requestType"], "agent"); assert!(envelope.get("requestType").is_none());
assert!(envelope["request"].get("model").is_none()); assert!(envelope["request"].get("model").is_none());
assert!(envelope["request"].get("safetySettings").is_none()); assert!(envelope["request"].get("safetySettings").is_none());
assert_eq!( assert_eq!(