From 861c6e62de58083377cba4ae9852277132f306dd Mon Sep 17 00:00:00 2001 From: Jay4242 <96741732+Jay4242@users.noreply.github.com> Date: Sat, 28 Jun 2025 12:19:10 -0700 Subject: [PATCH] feat(cli): Clear persisted session file with /clear command The command in the CLI now not only clears the in-memory chat history but also deletes and recreates the associated session file. This ensures that the chat context is fully reset, including any previously persisted messages, providing a more complete clear operation. --- crates/goose-cli/src/session/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/goose-cli/src/session/mod.rs b/crates/goose-cli/src/session/mod.rs index 6f09c1ee653d..9221f0610c6e 100644 --- a/crates/goose-cli/src/session/mod.rs +++ b/crates/goose-cli/src/session/mod.rs @@ -544,6 +544,10 @@ impl Session { &Message::assistant().with_text("Chat context cleared."), self.debug, ); + if self.session_file.exists() { + std::fs::remove_file(&self.session_file)?; + std::fs::File::create(&self.session_file)?; + } continue; } input::InputResult::PromptCommand(opts) => {