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 <newfile> was rejected with
"already saving to <oldfile>". Free and clear save_path alongside the
buffer so a cleared session can save to a fresh file.
This commit is contained in:
Adrià Arrufat
2026-06-15 14:54:26 +02:00
parent 4147274fa8
commit e35c66c2a6

View File

@@ -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();
}