优化: sanitize 告警降级
- 修复告警 warn 降 debug,同份畸形历史每请求重复触发成洪水 - 涉 sanitize.rs 四处与 openai_compat 两处,含逐 orphan 单条刷屏点 - view-only 修复语义不变,存量配对清洗已完成
This commit is contained in:
@@ -142,7 +142,8 @@ pub fn sanitize_messages(messages: Vec<ChatMessage>) -> Vec<ChatMessage> {
|
||||
})
|
||||
.collect();
|
||||
|
||||
tracing::warn!(
|
||||
// debug 级:同份畸形历史每请求重复触发,降级防告警洪水;根治=ai_messages 配对清洗(DB 原始保留不动)
|
||||
tracing::debug!(
|
||||
full_drop_heads,
|
||||
partial_rewrite_heads = partial_heads,
|
||||
orphaned_tool_results = orphaned_ids.len(),
|
||||
@@ -252,7 +253,7 @@ pub fn drop_reverse_orphans(messages: Vec<ChatMessage>) -> Vec<ChatMessage> {
|
||||
}
|
||||
|
||||
if healed > 0 || unidentifiable_kept > 0 {
|
||||
tracing::warn!(
|
||||
tracing::debug!(
|
||||
healed_orphan_tool_results = healed,
|
||||
unidentifiable_tool_results_kept = unidentifiable_kept,
|
||||
"history sanitized: healed orphan tool_results by inserting placeholder heads (view-only, persisted history untouched)"
|
||||
@@ -331,7 +332,7 @@ pub fn assert_placeholder_pairing(
|
||||
out.push(m);
|
||||
}
|
||||
if healed > 0 {
|
||||
tracing::warn!(
|
||||
tracing::debug!(
|
||||
healed_orphan_tool_results = healed,
|
||||
"send-view exit: healed orphan tool_results by inserting TOOL_MISSING_PREFIX heads (view-only, persisted history untouched)"
|
||||
);
|
||||
@@ -425,7 +426,7 @@ pub fn ensure_sequence_legal(messages: Vec<ChatMessage>) -> Vec<ChatMessage> {
|
||||
fixed.push(m);
|
||||
}
|
||||
if skipped > 0 || merged > 0 {
|
||||
tracing::warn!(
|
||||
tracing::debug!(
|
||||
skipped,
|
||||
merged,
|
||||
"序列修复:skip 开头非 user(含连带丢 orphan result)+ 合并连续同 role(view-only,避免 Anthropic/GLM 1214)"
|
||||
|
||||
@@ -424,7 +424,7 @@ fn sanitize_openai_triplets(messages: &mut Vec<OpenAiMessage>) {
|
||||
// 无配对头(id 不在任何保留 assistant 头内)→ orphan tool_result,丢弃。
|
||||
// 含两类:(a) assistant 头被 step2 剥后残留的 tool;(b) 全程无配对头的直构造/DB 残留。
|
||||
dropped_orphan_tools += 1;
|
||||
tracing::warn!(
|
||||
tracing::debug!(
|
||||
tool_call_id = %id,
|
||||
"[openai] orphan tool result(无配对 assistant tool_calls),已丢弃(防 'tool must be response to preceding tool_calls' 400)",
|
||||
);
|
||||
@@ -432,7 +432,7 @@ fn sanitize_openai_triplets(messages: &mut Vec<OpenAiMessage>) {
|
||||
});
|
||||
|
||||
if stripped_heads > 0 || dropped_orphan_tools > 0 {
|
||||
tracing::warn!(
|
||||
tracing::debug!(
|
||||
stripped_heads,
|
||||
total_stripped,
|
||||
dropped_orphan_tools,
|
||||
|
||||
Reference in New Issue
Block a user