diff --git a/crates/goose-cli/src/session/mod.rs b/crates/goose-cli/src/session/mod.rs index 15b0d6849842..70e9c8121adb 100644 --- a/crates/goose-cli/src/session/mod.rs +++ b/crates/goose-cli/src/session/mod.rs @@ -628,10 +628,22 @@ impl CliSession { continue; } + if let Err(e) = SessionManager::update_session(&self.session_id) + .total_tokens(Some(0)) + .input_tokens(Some(0)) + .output_tokens(Some(0)) + .apply() + .await + { + output::render_error(&format!("Failed to reset token counts: {}", e)); + continue; + } + self.messages.clear(); + tracing::info!("Chat context cleared by user."); output::render_message( - &Message::assistant().with_text("Chat context cleared."), + &Message::assistant().with_text("Chat context cleared.\n"), self.debug, );