Skip to content

Commit 66c0a4e

Browse files
committed
🤖 fix: surface script persist errors & avoid LLM prompt duplication
Change-Id: Ida7a74adf242613693e4f556ef7338ca2be22a5b Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 86d295a commit 66c0a4e

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/browser/utils/messages/modelMessageTransform.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,9 @@ export function transformScriptMessagesForLLM(messages: MuxMessage[]): MuxMessag
226226
llmContent += `\nStdout/Stderr: (no output)`;
227227
}
228228

229-
// Include MUX_OUTPUT if present
230-
if (result.outputFile?.trim()) {
231-
llmContent += `\nMUX_OUTPUT:\n${result.outputFile.trim()}`;
232-
}
233-
234-
// Include MUX_PROMPT if present
235-
if (result.promptFile?.trim()) {
236-
llmContent += `\nMUX_PROMPT:\n${result.promptFile.trim()}`;
237-
}
229+
// EXCLUDE MUX_OUTPUT and MUX_PROMPT from the LLM context for the script message itself.
230+
// MUX_PROMPT is sent as a separate user message by ChatInput, so including it here would be duplication.
231+
// MUX_OUTPUT is intended for user toasts, not LLM context.
238232

239233
return {
240234
...msg,

src/browser/utils/messages/transformScriptMessagesForLLM.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("transformScriptMessagesForLLM", () => {
4343
}
4444
});
4545

46-
it("should include all fields (stdout, output, prompt) if present", () => {
46+
it("should exclude MUX_OUTPUT and MUX_PROMPT from script execution messages (avoid duplication)", () => {
4747
const scriptResult: BashToolResult = {
4848
success: true,
4949
output: "stdout stuff",
@@ -79,8 +79,10 @@ describe("transformScriptMessagesForLLM", () => {
7979
expect(textPart.type).toBe("text");
8080
if (textPart.type === "text") {
8181
expect(textPart.text).toContain("Stdout/Stderr:\nstdout stuff");
82-
expect(textPart.text).toContain("MUX_OUTPUT:\nUser toast");
83-
expect(textPart.text).toContain("MUX_PROMPT:\nModel prompt");
82+
expect(textPart.text).not.toContain("MUX_OUTPUT");
83+
expect(textPart.text).not.toContain("User toast");
84+
expect(textPart.text).not.toContain("MUX_PROMPT");
85+
expect(textPart.text).not.toContain("Model prompt");
8486
}
8587
});
8688
});

src/node/services/ipcMain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ export class IpcMain {
12791279
}
12801280
} else {
12811281
log.error("Failed to persist script execution:", appendResult.error);
1282+
return Err(`Failed to persist script execution: ${appendResult.error}`);
12821283
}
12831284

12841285
return Ok(enhancedResult);

0 commit comments

Comments
 (0)