chore(log): 缩减 INFO 日志量,高频诊断日志降级/删除
1. 删除缓存诊断日志 4 处(openai.rs):排查已完结,字段已补齐,每次 LLM 调用都刷屏。 2. 删除 AgentPromptProvider 模型配置日志(agent_prompt_provider.rs):排查遗留,每次请求刷。 3. AgentFactory 创建日志 info→debug(agent_factory.rs):每轮对话刷,降级保留供偶发排查。 4. Calling tool / Tool calls detected info→debug(agent_loop.rs):每次工具调用都刷,全量参数打印开销大,tracing 在未启用级别时不评估字段。 5. LoadTaskMessages 3 条日志 info→debug(load_task_messages.rs):每次前端 trigger 都刷,一次 3 条。 6. 旧结果诊断日志 info→debug(execution.rs):每条消息首次 agent 迭代都触发。 7. pending subagents 日志 info→debug(processor.rs):子代理运行期高频率重复触发。 8. Updating current_session_id 仅变化时打(ws.rs):old==new 时每条消息都刷,无信息量。 编译通过,测试全绿。
This commit is contained in:
parent
ca7dcabbde
commit
0f60b02ede
@ -1406,7 +1406,7 @@ impl AgentLoop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute tool calls
|
// Execute tool calls
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
iteration,
|
iteration,
|
||||||
count = response.tool_calls.len(),
|
count = response.tool_calls.len(),
|
||||||
"Tool calls detected, executing tools"
|
"Tool calls detected, executing tools"
|
||||||
@ -2088,7 +2088,7 @@ impl AgentLoop {
|
|||||||
serde_json::Value::Object(obj) if obj.is_empty() => "{}".to_string(),
|
serde_json::Value::Object(obj) if obj.is_empty() => "{}".to_string(),
|
||||||
other => serde_json::to_string_pretty(other).unwrap_or_else(|_| other.to_string()),
|
other => serde_json::to_string_pretty(other).unwrap_or_else(|_| other.to_string()),
|
||||||
};
|
};
|
||||||
tracing::info!(tool = %tool_call.name, args = %args_str, "Calling tool");
|
tracing::debug!(tool = %tool_call.name, args = %args_str, "Calling tool");
|
||||||
|
|
||||||
// Record ToolCallStart event
|
// Record ToolCallStart event
|
||||||
if let Some(ref observer) = self.observer {
|
if let Some(ref observer) = self.observer {
|
||||||
|
|||||||
@ -56,7 +56,7 @@ async fn handle_load_task_messages(
|
|||||||
task_id: String,
|
task_id: String,
|
||||||
ctx: CommandContext,
|
ctx: CommandContext,
|
||||||
) -> Result<CommandResponse, CommandError> {
|
) -> Result<CommandResponse, CommandError> {
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
task_id = %task_id,
|
task_id = %task_id,
|
||||||
request_id = %ctx.request_id,
|
request_id = %ctx.request_id,
|
||||||
"LoadTaskMessages: looking up task"
|
"LoadTaskMessages: looking up task"
|
||||||
@ -65,7 +65,7 @@ async fn handle_load_task_messages(
|
|||||||
// 1. Try in-memory repository first
|
// 1. Try in-memory repository first
|
||||||
let task = match handler.task_repository.load_task_session(&task_id).await {
|
let task = match handler.task_repository.load_task_session(&task_id).await {
|
||||||
Ok(Some(task)) => {
|
Ok(Some(task)) => {
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
task_id = %task.id,
|
task_id = %task.id,
|
||||||
session_id = %task.session_id,
|
session_id = %task.session_id,
|
||||||
state = ?task.state,
|
state = ?task.state,
|
||||||
@ -74,7 +74,7 @@ async fn handle_load_task_messages(
|
|||||||
Some(task)
|
Some(task)
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
task_id = %task_id,
|
task_id = %task_id,
|
||||||
"LoadTaskMessages: task not in memory, searching database"
|
"LoadTaskMessages: task not in memory, searching database"
|
||||||
);
|
);
|
||||||
|
|||||||
@ -233,8 +233,8 @@ impl AgentFactory {
|
|||||||
_ => expert_provider_config,
|
_ => expert_provider_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 诊断日志:记录 agent 实际使用的配置和实例 ID
|
// 诊断日志(debug):记录 agent 实际使用的配置和实例 ID
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
instance_id = self.instance_id,
|
instance_id = self.instance_id,
|
||||||
channel = %request.channel_name,
|
channel = %request.channel_name,
|
||||||
session_id = %session_id,
|
session_id = %session_id,
|
||||||
|
|||||||
@ -61,15 +61,6 @@ impl SystemPromptProvider for AgentPromptProvider {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 诊断日志:记录系统提示词实际使用的模型配置(用于排查"配置不生效"问题)
|
|
||||||
tracing::info!(
|
|
||||||
session_id = ?context.session_id,
|
|
||||||
chat_id = %context.chat_id,
|
|
||||||
provider = %self.provider_config.name,
|
|
||||||
model_id = %self.provider_config.model_id,
|
|
||||||
"AgentPromptProvider: building system prompt with model config"
|
|
||||||
);
|
|
||||||
|
|
||||||
// 加载 Agent 提示词(AGENT.md + builtin + MEMORY_SUMMARY.md)
|
// 加载 Agent 提示词(AGENT.md + builtin + MEMORY_SUMMARY.md)
|
||||||
let agent_prompt = load_agent_prompt().ok().flatten()?;
|
let agent_prompt = load_agent_prompt().ok().flatten()?;
|
||||||
|
|
||||||
|
|||||||
@ -167,7 +167,7 @@ impl AgentExecutionService {
|
|||||||
.as_deref()
|
.as_deref()
|
||||||
.unwrap_or(request.chat_id),
|
.unwrap_or(request.chat_id),
|
||||||
);
|
);
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
channel = %request.channel_name,
|
channel = %request.channel_name,
|
||||||
chat_id = %request.chat_id,
|
chat_id = %request.chat_id,
|
||||||
user_message_id = %request.user_message.id,
|
user_message_id = %request.user_message.id,
|
||||||
|
|||||||
@ -594,7 +594,7 @@ impl InboundProcessor {
|
|||||||
.list_pending_subagents(topic_id, Some("running"))
|
.list_pending_subagents(topic_id, Some("running"))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
if !pending.is_empty() {
|
if !pending.is_empty() {
|
||||||
tracing::info!(
|
tracing::debug!(
|
||||||
topic_id = %topic_id,
|
topic_id = %topic_id,
|
||||||
pending_count = pending.len(),
|
pending_count = pending.len(),
|
||||||
"Skipping ExecutionCompleted: pending subagents still running"
|
"Skipping ExecutionCompleted: pending subagents still running"
|
||||||
|
|||||||
@ -557,13 +557,15 @@ async fn handle_inbound(
|
|||||||
|
|
||||||
// 处理响应
|
// 处理响应
|
||||||
if response.success {
|
if response.success {
|
||||||
// 更新当前会话 ID(如果是创建会话)
|
// 更新当前会话 ID(如果是创建会话);仅在变化时记录日志
|
||||||
if let Some(session_id) = response.metadata.get("session_id") {
|
if let Some(session_id) = response.metadata.get("session_id") {
|
||||||
tracing::info!(
|
if session_id != current_session_id {
|
||||||
old_session_id = %current_session_id,
|
tracing::info!(
|
||||||
new_session_id = %session_id,
|
old_session_id = %current_session_id,
|
||||||
"Updating current_session_id"
|
new_session_id = %session_id,
|
||||||
);
|
"Updating current_session_id"
|
||||||
|
);
|
||||||
|
}
|
||||||
*current_session_id = session_id.clone();
|
*current_session_id = session_id.clone();
|
||||||
let _ = state
|
let _ = state
|
||||||
.channel_manager
|
.channel_manager
|
||||||
|
|||||||
@ -96,7 +96,6 @@ impl StreamingAccumulator {
|
|||||||
/// 跳过 total_tokens=0 的占位帧,避免覆盖真实值。
|
/// 跳过 total_tokens=0 的占位帧,避免覆盖真实值。
|
||||||
fn set_usage(&mut self, usage: OpenAIUsage) {
|
fn set_usage(&mut self, usage: OpenAIUsage) {
|
||||||
if usage.total_tokens > 0 {
|
if usage.total_tokens > 0 {
|
||||||
usage.log_cache_diagnostics("stream_final_frame");
|
|
||||||
self.usage = Some(usage);
|
self.usage = Some(usage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -725,7 +724,6 @@ impl OpenAIProvider {
|
|||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
// 回退场景下也从非流式响应提取 usage
|
// 回退场景下也从非流式响应提取 usage
|
||||||
openai_resp.usage.log_cache_diagnostics("non_streaming_fallback");
|
|
||||||
response.usage = Usage {
|
response.usage = Usage {
|
||||||
prompt_tokens: openai_resp.usage.prompt_tokens,
|
prompt_tokens: openai_resp.usage.prompt_tokens,
|
||||||
completion_tokens: openai_resp.usage.completion_tokens,
|
completion_tokens: openai_resp.usage.completion_tokens,
|
||||||
@ -1108,19 +1106,6 @@ impl OpenAIUsage {
|
|||||||
})
|
})
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 诊断日志:记录 API 是否返回缓存字段及解析后的值(排查"缓存一直不命中"问题)。
|
|
||||||
/// field_present=false 说明 API/网关根本没返回缓存字段(中转服务剥离或模型不支持)。
|
|
||||||
fn log_cache_diagnostics(&self, source: &str) {
|
|
||||||
tracing::info!(
|
|
||||||
source = %source,
|
|
||||||
prompt_tokens = self.prompt_tokens,
|
|
||||||
cached_tokens = self.cached_tokens(),
|
|
||||||
deepseek_cache_field_present = self.prompt_cache_hit_tokens.is_some(),
|
|
||||||
openai_cache_details_present = self.prompt_tokens_details.is_some(),
|
|
||||||
"OpenAI usage cache diagnostics"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@ -1279,7 +1264,6 @@ impl LLMProvider for OpenAIProvider {
|
|||||||
reasoning_content: openai_resp.choices[0].message.reasoning_content.clone(),
|
reasoning_content: openai_resp.choices[0].message.reasoning_content.clone(),
|
||||||
tool_calls,
|
tool_calls,
|
||||||
usage: {
|
usage: {
|
||||||
openai_resp.usage.log_cache_diagnostics("non_streaming");
|
|
||||||
Usage {
|
Usage {
|
||||||
prompt_tokens: openai_resp.usage.prompt_tokens,
|
prompt_tokens: openai_resp.usage.prompt_tokens,
|
||||||
completion_tokens: openai_resp.usage.completion_tokens,
|
completion_tokens: openai_resp.usage.completion_tokens,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user