Merge remote-tracking branch 'origin/pr/538'

This commit is contained in:
fawney19
2026-05-21 23:12:42 +08:00
16 changed files with 422 additions and 38 deletions

View File

@@ -1,6 +1,7 @@
use aether_ai_formats::api::{
sanitize_request_path, sanitize_request_path_and_query, sanitize_request_query_string,
};
use aether_ai_formats::UPSTREAM_IS_STREAM_KEY;
use aether_contracts::ExecutionPlan;
use serde_json::{json, Map, Value};
@@ -74,7 +75,7 @@ fn copy_allowed_metadata_fields(source: &Map<String, Value>, target: &mut Map<St
copy_non_empty_string(source, target, "user_agent");
copy_non_empty_string(source, target, "client_family");
copy_bool(source, target, "client_requested_stream");
copy_bool(source, target, "upstream_is_stream");
copy_bool(source, target, UPSTREAM_IS_STREAM_KEY);
copy_non_null_value(source, target, "client_session_affinity");
copy_bool(source, target, "api_key_is_standalone");
copy_non_empty_string(source, target, "request_path");
@@ -114,7 +115,7 @@ fn move_allowed_metadata_fields(mut source: Map<String, Value>, target: &mut Map
remove_non_empty_string(&mut source, target, "user_agent");
remove_non_empty_string(&mut source, target, "client_family");
remove_bool(&mut source, target, "client_requested_stream");
remove_bool(&mut source, target, "upstream_is_stream");
remove_bool(&mut source, target, UPSTREAM_IS_STREAM_KEY);
remove_non_null_value(&mut source, target, "client_session_affinity");
remove_bool(&mut source, target, "api_key_is_standalone");
remove_non_empty_string(&mut source, target, "request_path");

View File

@@ -1,5 +1,6 @@
use std::collections::BTreeMap;
use aether_ai_formats::UPSTREAM_IS_STREAM_KEY;
use aether_contracts::{ExecutionPlan, ExecutionTelemetry};
use aether_data_contracts::repository::usage::{UpsertUsageRecord, UsageBodyCaptureState};
use aether_data_contracts::DataLayerError;
@@ -719,7 +720,7 @@ pub fn build_sync_terminal_usage_payload_seed(
.report_context
.as_ref()
.and_then(Value::as_object)
.and_then(|context| context.get("upstream_is_stream"))
.and_then(|context| context.get(UPSTREAM_IS_STREAM_KEY))
.and_then(Value::as_bool)
.unwrap_or(false);
let provider_response_full = if upstream_is_stream && payload.body_base64.is_some() {
@@ -1632,9 +1633,9 @@ fn build_runtime_request_metadata_seed_from_parts(
Value::Bool(client_requested_stream),
);
}
if let Some(upstream_is_stream) = context_bool(context, "upstream_is_stream") {
if let Some(upstream_is_stream) = context_bool(context, UPSTREAM_IS_STREAM_KEY) {
metadata.insert(
"upstream_is_stream".to_string(),
UPSTREAM_IS_STREAM_KEY.to_string(),
Value::Bool(upstream_is_stream),
);
}