From 104d95d5abfa09fb398baf89eb8f5b145b897d31 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 7 Oct 2025 21:15:20 -0500 Subject: [PATCH] Filter out empty assistant messages when saving the history file --- src/lib/DotAI.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/DotAI.ts b/src/lib/DotAI.ts index 56864b77..20b246fc 100644 --- a/src/lib/DotAI.ts +++ b/src/lib/DotAI.ts @@ -1,6 +1,7 @@ import { join } from "path-browserify"; import type OpenAI from "openai"; import type { JSRuntimeFS } from "./JSRuntime"; +import { isEmptyMessage } from "./isEmptyMessage"; /** AI message history manager and .git/ai directory utilities */ export class DotAI { @@ -46,6 +47,9 @@ export class DotAI { sessionName: string, messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[], ): Promise { + // Filter out empty assistant messages + messages = messages.filter((msg) => !isEmptyMessage(msg)); + // Validate messages before saving this.validateMessages(messages);