优化日志输出:斜杠命令执行时打印,过滤冗余的压缩日志

- 添加斜杠命令执行的 info 日志
- Context compression 日志只在实际触发压缩时输出 (debug级别)
This commit is contained in:
xiaoxixi 2026-04-28 20:52:20 +08:00
parent 7220e89a22
commit 84bb06cc76
2 changed files with 6 additions and 9 deletions

View File

@ -110,17 +110,11 @@ impl ContextCompressor {
// Check if compression is needed // Check if compression is needed
let tokens = estimate_tokens(&history); let tokens = estimate_tokens(&history);
if tokens <= self.threshold() { if tokens <= self.threshold() {
#[cfg(debug_assertions)]
tracing::info!(
tokens = tokens,
threshold = self.threshold(),
msg_count = history.len(),
"Context compression not needed"
);
return Ok(history); return Ok(history);
} }
tracing::info!( #[cfg(debug_assertions)]
tracing::debug!(
tokens = tokens, tokens = tokens,
threshold = self.threshold(), threshold = self.threshold(),
msg_count = history.len(), msg_count = history.len(),
@ -172,7 +166,8 @@ impl ContextCompressor {
} }
} }
tracing::info!( #[cfg(debug_assertions)]
tracing::debug!(
final_tokens = estimate_tokens(&current_history), final_tokens = estimate_tokens(&current_history),
final_msg_count = current_history.len(), final_msg_count = current_history.len(),
"Context compression completed" "Context compression completed"

View File

@ -265,6 +265,8 @@ impl SessionManager {
.find(|c| c.name == command) .find(|c| c.name == command)
.ok_or_else(|| AgentError::Other(format!("Unknown command: {}", command)))?; .ok_or_else(|| AgentError::Other(format!("Unknown command: {}", command)))?;
tracing::info!(cmd = %cmd.name, args = ?args, "Executing slash command");
match cmd.name { match cmd.name {
"new" => { "new" => {
let title = args.map(|s| s.to_string()); let title = args.map(|s| s.to_string());