From 50fd5b81e146a08e9ba6c91436be84bc8f17ed10 Mon Sep 17 00:00:00 2001 From: Chummy Date: Wed, 18 Feb 2026 18:15:48 +0800 Subject: [PATCH] fix(test): stabilize cron output capture and clippy cleanups --- clippy.toml | 4 ++++ src/agent/loop_.rs | 8 ++++---- src/channels/mod.rs | 2 +- src/main.rs | 2 +- src/memory/sqlite.rs | 5 +++-- src/observability/prometheus.rs | 10 ++++------ src/providers/anthropic.rs | 8 +++----- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/clippy.toml b/clippy.toml index c45fd63..2ffd47c 100644 --- a/clippy.toml +++ b/clippy.toml @@ -7,3 +7,7 @@ cognitive-complexity-threshold = 30 too-many-arguments-threshold = 10 too-many-lines-threshold = 200 + +# Some generated/test-only paths legitimately allocate larger local buffers. +# Keep linting enabled while reducing false positives from those cases. +array-size-threshold = 65536 diff --git a/src/agent/loop_.rs b/src/agent/loop_.rs index 455f588..813bb9f 100644 --- a/src/agent/loop_.rs +++ b/src/agent/loop_.rs @@ -999,10 +999,10 @@ pub(crate) async fn run_tool_call_loop( let mut chunk = String::new(); for word in display_text.split_inclusive(char::is_whitespace) { chunk.push_str(word); - if chunk.len() >= STREAM_CHUNK_MIN_CHARS { - if tx.send(std::mem::take(&mut chunk)).await.is_err() { - break; // receiver dropped - } + if chunk.len() >= STREAM_CHUNK_MIN_CHARS + && tx.send(std::mem::take(&mut chunk)).await.is_err() + { + break; // receiver dropped } } if !chunk.is_empty() { diff --git a/src/channels/mod.rs b/src/channels/mod.rs index dcc55ff..91b59ca 100644 --- a/src/channels/mod.rs +++ b/src/channels/mod.rs @@ -369,7 +369,7 @@ async fn process_channel_message(ctx: Arc, msg: traits::C .conversation_histories .lock() .unwrap_or_else(|e| e.into_inner()); - let turns = histories.entry(history_key).or_insert_with(Vec::new); + let turns = histories.entry(history_key).or_default(); turns.push(ChatMessage::user(&enriched_message)); turns.push(ChatMessage::assistant(&response)); // Trim to MAX_CHANNEL_HISTORY (keep recent turns) diff --git a/src/main.rs b/src/main.rs index a8413cd..7acf617 100644 --- a/src/main.rs +++ b/src/main.rs @@ -849,7 +849,7 @@ fn format_expiry(profile: &auth::profiles::AuthProfile) -> String { match profile .token_set .as_ref() - .and_then(|token_set| token_set.expires_at.as_ref().cloned()) + .and_then(|token_set| token_set.expires_at) { Some(ts) => { let now = chrono::Utc::now(); diff --git a/src/memory/sqlite.rs b/src/memory/sqlite.rs index 6faaddb..a5e973f 100644 --- a/src/memory/sqlite.rs +++ b/src/memory/sqlite.rs @@ -6,6 +6,7 @@ use async_trait::async_trait; use chrono::Local; use parking_lot::Mutex; use rusqlite::{params, Connection}; +use std::fmt::Write; use std::path::{Path, PathBuf}; use std::sync::mpsc; use std::sync::Arc; @@ -342,12 +343,12 @@ impl SqliteMemory { let mut idx = 1; if let Some(cat) = category { - sql.push_str(&format!(" AND category = ?{idx}")); + let _ = write!(sql, " AND category = ?{idx}"); param_values.push(Box::new(cat.to_string())); idx += 1; } if let Some(sid) = session_id { - sql.push_str(&format!(" AND session_id = ?{idx}")); + let _ = write!(sql, " AND session_id = ?{idx}"); param_values.push(Box::new(sid.to_string())); } diff --git a/src/observability/prometheus.rs b/src/observability/prometheus.rs index 572a198..ce19568 100644 --- a/src/observability/prometheus.rs +++ b/src/observability/prometheus.rs @@ -166,7 +166,10 @@ impl Observer for PrometheusObserver { self.tokens_used.set(i64::try_from(*t).unwrap_or(i64::MAX)); } } - ObserverEvent::ToolCallStart { tool: _ } => {} + ObserverEvent::ToolCallStart { tool: _ } + | ObserverEvent::TurnComplete + | ObserverEvent::LlmRequest { .. } + | ObserverEvent::LlmResponse { .. } => {} ObserverEvent::ToolCall { tool, duration, @@ -180,9 +183,6 @@ impl Observer for PrometheusObserver { .with_label_values(&[tool.as_str()]) .observe(duration.as_secs_f64()); } - ObserverEvent::TurnComplete => { - // No metric for turn complete currently - } ObserverEvent::ChannelMessage { channel, direction } => { self.channel_messages .with_label_values(&[channel, direction]) @@ -197,8 +197,6 @@ impl Observer for PrometheusObserver { } => { self.errors.with_label_values(&[component]).inc(); } - ObserverEvent::LlmRequest { .. } => {} - ObserverEvent::LlmResponse { .. } => {} } } diff --git a/src/providers/anthropic.rs b/src/providers/anthropic.rs index 5944566..9c8066d 100644 --- a/src/providers/anthropic.rs +++ b/src/providers/anthropic.rs @@ -202,13 +202,11 @@ impl AnthropicProvider { if let Some(last_msg) = messages.last_mut() { if let Some(last_content) = last_msg.content.last_mut() { match last_content { - NativeContentOut::Text { cache_control, .. } => { + NativeContentOut::Text { cache_control, .. } + | NativeContentOut::ToolResult { cache_control, .. } => { *cache_control = Some(CacheControl::ephemeral()); } - NativeContentOut::ToolResult { cache_control, .. } => { - *cache_control = Some(CacheControl::ephemeral()); - } - _ => {} + NativeContentOut::ToolUse { .. } => {} } } }