diff --git a/apps/aether-gateway/src/execution_runtime/stream/commit_policy.rs b/apps/aether-gateway/src/execution_runtime/stream/commit_policy.rs index a8048b286..3cbf9f641 100644 --- a/apps/aether-gateway/src/execution_runtime/stream/commit_policy.rs +++ b/apps/aether-gateway/src/execution_runtime/stream/commit_policy.rs @@ -631,10 +631,7 @@ mod tests { }; assert_eq!(status_code, 502); - assert_eq!( - body_json["error"]["code"], - "MALFORMED_FUNCTION_CALL" - ); + assert_eq!(body_json["error"]["code"], "MALFORMED_FUNCTION_CALL"); assert_eq!( body_json["error"]["message"], "Malformed function call: Function call is empty - no input to parse." diff --git a/apps/aether-gateway/src/execution_runtime/stream/execution.rs b/apps/aether-gateway/src/execution_runtime/stream/execution.rs index 450f5bcac..587ed1a8f 100644 --- a/apps/aether-gateway/src/execution_runtime/stream/execution.rs +++ b/apps/aether-gateway/src/execution_runtime/stream/execution.rs @@ -71,6 +71,7 @@ use crate::ai_serving::api::{ UPSTREAM_IS_STREAM_KEY, }; use crate::ai_serving::is_openai_responses_family_format; +use crate::ai_serving::record_local_runtime_candidate_skip_reason; use crate::api::response::{ attach_control_metadata_headers, build_client_response, build_client_response_from_parts, }; @@ -114,7 +115,6 @@ use crate::execution_runtime::{ use crate::execution_runtime::{ MAX_ERROR_BODY_BYTES, MAX_STREAM_PREFETCH_BYTES, MAX_STREAM_PREFETCH_FRAMES, }; -use crate::ai_serving::record_local_runtime_candidate_skip_reason; use crate::log_ids::short_request_id; use crate::orchestration::{ apply_local_execution_effect, build_local_error_flow_metadata, classify_failure_disposition, @@ -8794,8 +8794,7 @@ mod tests { endpoint_id: format!("endpoint-{request_id}"), key_id: format!("key-{request_id}"), method: "POST".to_string(), - url: "https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent" - .to_string(), + url: "https://cloudcode-pa.googleapis.com/v1internal:streamGenerateContent".to_string(), headers: BTreeMap::from([ ("content-type".to_string(), "application/json".to_string()), ("accept".to_string(), "text/event-stream".to_string()), diff --git a/apps/aether-gateway/src/execution_runtime/sync/execution.rs b/apps/aether-gateway/src/execution_runtime/sync/execution.rs index 49f2c16ac..2b851598a 100644 --- a/apps/aether-gateway/src/execution_runtime/sync/execution.rs +++ b/apps/aether-gateway/src/execution_runtime/sync/execution.rs @@ -34,6 +34,7 @@ use crate::ai_serving::api::{ implicit_sync_finalize_report_kind, maybe_build_sync_finalize_outcome, LocalCoreSyncErrorKind, LocalCoreSyncFinalizeOutcome, }; +use crate::ai_serving::record_local_runtime_candidate_skip_reason; use crate::api::response::{ attach_control_metadata_headers, build_client_response, build_client_response_from_parts, build_client_response_from_parts_with_mutator, @@ -69,7 +70,6 @@ use crate::execution_runtime::{ local_failover_response_text, resolve_core_sync_error_finalize_report_kind, should_fallback_to_control_sync, should_finalize_sync_response, LocalFailoverDecision, }; -use crate::ai_serving::record_local_runtime_candidate_skip_reason; use crate::log_ids::short_request_id; use crate::orchestration::{ apply_local_execution_effect, build_local_error_flow_metadata, diff --git a/apps/aether-gateway/src/handlers/proxy/mod.rs b/apps/aether-gateway/src/handlers/proxy/mod.rs index ba319c275..60f0d9ed8 100644 --- a/apps/aether-gateway/src/handlers/proxy/mod.rs +++ b/apps/aether-gateway/src/handlers/proxy/mod.rs @@ -107,8 +107,10 @@ const AUTH_API_KEY_CONCURRENCY_LIMIT_REACHED_DETAIL: &str = "当前调用方 API Key 并发请求数已达上限,请稍后重试"; const PROVIDER_KEY_CAPACITY_LIMIT_REACHED_DETAIL: &str = "所有可用上游账号当前均已达到并发或 RPM 上限,请稍后重试"; -const PROVIDER_KEY_CAPACITY_LIMIT_SKIP_REASONS: &[&str] = - &["provider_key_concurrency_limit_reached", "key_rpm_exhausted"]; +const PROVIDER_KEY_CAPACITY_LIMIT_SKIP_REASONS: &[&str] = &[ + "provider_key_concurrency_limit_reached", + "key_rpm_exhausted", +]; const LOCAL_EXECUTION_PLANNING_TIMEOUT_DETAIL: &str = "当前 AI 请求在本地执行规划阶段超时,请稍后重试"; const EXECUTION_PATH_TUNNEL_AFFINITY_FORWARD: &str = "tunnel_affinity_forward"; @@ -2380,8 +2382,7 @@ fn diagnostic_is_provider_key_capacity_limited( || (diagnostic.candidate_count.is_some_and(|candidate_count| { candidate_count > 0 && diagnostic.skipped_candidate_count.unwrap_or(0) >= candidate_count - }) - && !diagnostic.skip_reasons.is_empty() + }) && !diagnostic.skip_reasons.is_empty() && diagnostic.skip_reasons.iter().all(|(reason, count)| { PROVIDER_KEY_CAPACITY_LIMIT_SKIP_REASONS.contains(&reason.as_str()) && *count > 0 })) diff --git a/apps/aether-gateway/src/request_candidate_runtime.rs b/apps/aether-gateway/src/request_candidate_runtime.rs index 9c84e3bbe..3f9f9f7a2 100644 --- a/apps/aether-gateway/src/request_candidate_runtime.rs +++ b/apps/aether-gateway/src/request_candidate_runtime.rs @@ -372,10 +372,8 @@ pub(crate) async fn record_local_request_candidate_status( else { return; }; - record.skip_reason = local_request_candidate_skip_reason( - record.status, - record.error_type.as_deref(), - ); + record.skip_reason = + local_request_candidate_skip_reason(record.status, record.error_type.as_deref()); persist_local_request_candidate_status_record(state, record).await; } diff --git a/crates/aether-ai/formats/src/formats/shared/stream_core/format_matrix.rs b/crates/aether-ai/formats/src/formats/shared/stream_core/format_matrix.rs index 79be931b0..d81d47247 100644 --- a/crates/aether-ai/formats/src/formats/shared/stream_core/format_matrix.rs +++ b/crates/aether-ai/formats/src/formats/shared/stream_core/format_matrix.rs @@ -379,9 +379,7 @@ impl StreamingStandardTerminalObserver { if let Some(parser_error) = finish_reason .as_deref() .filter(|reason| !canonical_stream_finish_reason_is_supported(reason)) - .map(|reason| { - format!("unsupported provider stream finish reason: {reason}") - }) + .map(|reason| format!("unsupported provider stream finish reason: {reason}")) { summary.parser_error.get_or_insert(parser_error); } @@ -832,9 +830,7 @@ mod tests { ); assert_eq!( summary.parser_error.as_deref(), - Some( - "unsupported provider stream finish reason: MALFORMED_FUNCTION_CALL" - ) + Some("unsupported provider stream finish reason: MALFORMED_FUNCTION_CALL") ); }