From e35c66c2a688917413d71a435bee2ec588feae95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Mon, 15 Jun 2026 14:54:26 +0200 Subject: [PATCH] agent: reset save destination on /clear and /reset clearConversation reset the recorded action buffer but left save_path set, so after /clear or /reset a /save was rejected with "already saving to ". Free and clear save_path alongside the buffer so a cleared session can save to a fresh file. --- src/agent/Agent.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/agent/Agent.zig b/src/agent/Agent.zig index 7f57440dc..5f0ac1b90 100644 --- a/src/agent/Agent.zig +++ b/src/agent/Agent.zig @@ -742,11 +742,13 @@ fn handleUsage(self: *Agent) void { } /// Drop everything tied to the conversation: history (system prompt re-seeds -/// lazily next turn), cumulative usage, the recorded action buffer, and DOM -/// node IDs. Shared by `/clear` and `/reset`. +/// lazily next turn), cumulative usage, the recorded action buffer and its save +/// destination, and DOM node IDs. Shared by `/clear` and `/reset`. fn clearConversation(self: *Agent) void { self.conversation.rollback(0); self.save_buffer.reset(); + if (self.save_path) |p| self.allocator.free(p); + self.save_path = null; self.total_usage = .{}; self.node_registry.reset(); }