fix(test): stabilize cron output capture and clippy cleanups

This commit is contained in:
Chummy 2026-02-18 18:15:48 +08:00
parent 483acccdb7
commit 50fd5b81e1
7 changed files with 20 additions and 19 deletions

View file

@ -7,3 +7,7 @@ cognitive-complexity-threshold = 30
too-many-arguments-threshold = 10 too-many-arguments-threshold = 10
too-many-lines-threshold = 200 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

View file

@ -999,12 +999,12 @@ pub(crate) async fn run_tool_call_loop(
let mut chunk = String::new(); let mut chunk = String::new();
for word in display_text.split_inclusive(char::is_whitespace) { for word in display_text.split_inclusive(char::is_whitespace) {
chunk.push_str(word); chunk.push_str(word);
if chunk.len() >= STREAM_CHUNK_MIN_CHARS { if chunk.len() >= STREAM_CHUNK_MIN_CHARS
if tx.send(std::mem::take(&mut chunk)).await.is_err() { && tx.send(std::mem::take(&mut chunk)).await.is_err()
{
break; // receiver dropped break; // receiver dropped
} }
} }
}
if !chunk.is_empty() { if !chunk.is_empty() {
let _ = tx.send(chunk).await; let _ = tx.send(chunk).await;
} }

View file

@ -369,7 +369,7 @@ async fn process_channel_message(ctx: Arc<ChannelRuntimeContext>, msg: traits::C
.conversation_histories .conversation_histories
.lock() .lock()
.unwrap_or_else(|e| e.into_inner()); .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::user(&enriched_message));
turns.push(ChatMessage::assistant(&response)); turns.push(ChatMessage::assistant(&response));
// Trim to MAX_CHANNEL_HISTORY (keep recent turns) // Trim to MAX_CHANNEL_HISTORY (keep recent turns)

View file

@ -849,7 +849,7 @@ fn format_expiry(profile: &auth::profiles::AuthProfile) -> String {
match profile match profile
.token_set .token_set
.as_ref() .as_ref()
.and_then(|token_set| token_set.expires_at.as_ref().cloned()) .and_then(|token_set| token_set.expires_at)
{ {
Some(ts) => { Some(ts) => {
let now = chrono::Utc::now(); let now = chrono::Utc::now();

View file

@ -6,6 +6,7 @@ use async_trait::async_trait;
use chrono::Local; use chrono::Local;
use parking_lot::Mutex; use parking_lot::Mutex;
use rusqlite::{params, Connection}; use rusqlite::{params, Connection};
use std::fmt::Write;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::mpsc; use std::sync::mpsc;
use std::sync::Arc; use std::sync::Arc;
@ -342,12 +343,12 @@ impl SqliteMemory {
let mut idx = 1; let mut idx = 1;
if let Some(cat) = category { 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())); param_values.push(Box::new(cat.to_string()));
idx += 1; idx += 1;
} }
if let Some(sid) = session_id { 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())); param_values.push(Box::new(sid.to_string()));
} }

View file

@ -166,7 +166,10 @@ impl Observer for PrometheusObserver {
self.tokens_used.set(i64::try_from(*t).unwrap_or(i64::MAX)); 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 { ObserverEvent::ToolCall {
tool, tool,
duration, duration,
@ -180,9 +183,6 @@ impl Observer for PrometheusObserver {
.with_label_values(&[tool.as_str()]) .with_label_values(&[tool.as_str()])
.observe(duration.as_secs_f64()); .observe(duration.as_secs_f64());
} }
ObserverEvent::TurnComplete => {
// No metric for turn complete currently
}
ObserverEvent::ChannelMessage { channel, direction } => { ObserverEvent::ChannelMessage { channel, direction } => {
self.channel_messages self.channel_messages
.with_label_values(&[channel, direction]) .with_label_values(&[channel, direction])
@ -197,8 +197,6 @@ impl Observer for PrometheusObserver {
} => { } => {
self.errors.with_label_values(&[component]).inc(); self.errors.with_label_values(&[component]).inc();
} }
ObserverEvent::LlmRequest { .. } => {}
ObserverEvent::LlmResponse { .. } => {}
} }
} }

View file

@ -202,13 +202,11 @@ impl AnthropicProvider {
if let Some(last_msg) = messages.last_mut() { if let Some(last_msg) = messages.last_mut() {
if let Some(last_content) = last_msg.content.last_mut() { if let Some(last_content) = last_msg.content.last_mut() {
match last_content { match last_content {
NativeContentOut::Text { cache_control, .. } => { NativeContentOut::Text { cache_control, .. }
| NativeContentOut::ToolResult { cache_control, .. } => {
*cache_control = Some(CacheControl::ephemeral()); *cache_control = Some(CacheControl::ephemeral());
} }
NativeContentOut::ToolResult { cache_control, .. } => { NativeContentOut::ToolUse { .. } => {}
*cache_control = Some(CacheControl::ephemeral());
}
_ => {}
} }
} }
} }