Skip to content

Commit e1a74c6

Browse files
SunnyShu0925claude
andcommitted
fix(session-memory): narrow transcript filter to delivery-mirror only, preserve gateway-injected
ClawSweeper review flagged that using isTranscriptOnlyOpenClawAssistantMessage also filters standalone gateway-injected rows, which are visible assistant replies and should be preserved. Switch to isOpenClawDeliveryMirrorAssistantMessage which only filters delivery-mirror duplicates. - Change import from isTranscriptOnlyOpenClawAssistantMessage to isOpenClawDeliveryMirrorAssistantMessage - Update regression test to verify gateway-injected standalone rows are preserved - All 195 hooks tests pass Co-Authored-By: claude-sonnet-4-6 <[email protected]>
1 parent 4abfeb4 commit e1a74c6

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/hooks/bundled/session-memory/handler.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ describe("session-memory hook", () => {
813813
expect(memoryContent).toContain("assistant: Only message 2");
814814
});
815815

816-
it("skips delivery-mirror and gateway-injected assistant rows (fixes #92563)", async () => {
816+
it("filters delivery-mirror duplicates but preserves standalone gateway-injected assistant rows (fixes #92563)", async () => {
817817
const sessionContent = [
818818
JSON.stringify({ type: "message", message: { role: "user", content: "What is 2+2?" } }),
819819
JSON.stringify({
@@ -840,14 +840,15 @@ describe("session-memory hook", () => {
840840
role: "assistant",
841841
provider: "openclaw",
842842
model: "gateway-injected",
843-
content: [{ type: "text", text: "should be filtered" }],
843+
content: [{ type: "text", text: "standalone gateway reply" }],
844844
},
845845
}),
846846
].join("\n");
847847

848848
const memoryContent = await readSessionTranscript({ sessionContent });
849849
const assistantLines = memoryContent!.split("\n").filter((l) => l.startsWith("assistant:"));
850-
expect(assistantLines).toEqual(["assistant: 2+2 = 4"]);
851-
expect(memoryContent).not.toContain("should be filtered");
850+
// delivery-mirror duplicate is filtered, gateway-injected standalone is preserved
851+
expect(assistantLines).toEqual(["assistant: 2+2 = 4", "assistant: standalone gateway reply"]);
852+
expect(memoryContent).toContain("standalone gateway reply");
852853
});
853854
});

src/hooks/bundled/session-memory/transcript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import fs from "node:fs/promises";
33
import path from "node:path";
44
import { hasInterSessionUserProvenance } from "../../../sessions/input-provenance.js";
5-
import { isTranscriptOnlyOpenClawAssistantMessage } from "../../../shared/transcript-only-openclaw-assistant.js";
5+
import { isOpenClawDeliveryMirrorAssistantMessage } from "../../../shared/transcript-only-openclaw-assistant.js";
66

77
function extractTextMessageContent(content: unknown): string | undefined {
88
if (typeof content === "string") {
@@ -46,7 +46,7 @@ export async function getRecentSessionContent(
4646
if (role === "user" && hasInterSessionUserProvenance(msg)) {
4747
continue;
4848
}
49-
if (isTranscriptOnlyOpenClawAssistantMessage(msg)) {
49+
if (isOpenClawDeliveryMirrorAssistantMessage(msg)) {
5050
continue;
5151
}
5252
const text = extractTextMessageContent(msg.content);

0 commit comments

Comments
 (0)