fix: silent AI billing failures — add tracing::warn for billing errors

This commit is contained in:
ZhenYi 2026-04-27 11:15:15 +08:00
parent 1e975c0837
commit 763d47dc45
2 changed files with 10 additions and 4 deletions

View File

@ -224,14 +224,17 @@ pub async fn process_message_ai_react_streaming(
// Record billing (non-fatal) // Record billing (non-fatal)
// TODO: ReAct agent does not track token counts yet; billing with 0/0 // TODO: ReAct agent does not track token counts yet; billing with 0/0
let _ = super::billing::record_ai_usage( if let Err(e) = super::billing::record_ai_usage(
&db, &db,
project_id_inner, project_id_inner,
model_id, model_id,
0, 0,
0, 0,
) )
.await; .await
{
tracing::warn!(error = %e, "AI billing recording failed");
}
let msg_event = queue::RoomMessageEvent { let msg_event = queue::RoomMessageEvent {
id: streaming_msg_id, id: streaming_msg_id,

View File

@ -188,14 +188,17 @@ pub async fn process_message_ai_streaming(
} }
// Record billing (non-fatal) // Record billing (non-fatal)
let _ = super::billing::record_ai_usage( if let Err(e) = super::billing::record_ai_usage(
&db, &db,
project_id_inner, project_id_inner,
model_id, model_id,
result.input_tokens, result.input_tokens,
result.output_tokens, result.output_tokens,
) )
.await; .await
{
tracing::warn!(error = %e, "AI billing recording failed");
}
let msg_event = queue::RoomMessageEvent { let msg_event = queue::RoomMessageEvent {
id: streaming_msg_id, id: streaming_msg_id,