Skip to content

Commit e69c3df

Browse files
authored
fix(agents): stop messaging dedupe from dropping final replies that quote a short tool send (#118178)
The forward substring check in isMessagingToolDuplicateNormalized treated any reply containing a prior message-tool send as a duplicate, with no length floor. A short interim update sent via the message tool then suppressed the entire final reply that restated it, and the user never received the answer. The reverse direction already carried a 0.5 length ratio floor. Apply the same floor to the forward direction so a reply is only deduped when the prior send covers at least half of it.
1 parent 9b02ea3 commit e69c3df

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎src/agents/embedded-agent-helpers.sanitizeuserfacingtext.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,17 @@ describe("isMessagingToolDuplicate", () => {
11041104
sentTexts: ["Hello, this is a test message!"],
11051105
expected: false,
11061106
},
1107+
{
1108+
input:
1109+
"Checking the deploy logs now. The deploy failed because the migration step timed out after 300 seconds while the database was mid-vacuum, which held the lock the migration needed. I re-ran the deploy after the vacuum finished and it completed cleanly. All services are healthy and the new version is serving traffic.",
1110+
sentTexts: ["Checking the deploy logs now."],
1111+
expected: false,
1112+
},
1113+
{
1114+
input: "Checking the deploy logs now. All good!",
1115+
sentTexts: ["Checking the deploy logs now."],
1116+
expected: true,
1117+
},
11071118
])("returns $expected for duplicate check", ({ input, sentTexts, expected }) => {
11081119
expect(isMessagingToolDuplicate(input, sentTexts)).toBe(expected);
11091120
});

‎src/agents/embedded-agent-helpers/messaging-dedupe.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
55

66
const MIN_DUPLICATE_TEXT_LENGTH = 10;
7-
const MIN_REVERSE_SUBSTRING_DUPLICATE_RATIO = 0.5;
7+
const MIN_SUBSTRING_DUPLICATE_RATIO = 0.5;
88

99
/**
1010
* Normalize text for duplicate comparison.
@@ -36,11 +36,11 @@ export function isMessagingToolDuplicateNormalized(
3636
return false;
3737
}
3838
if (normalized.includes(normalizedSent)) {
39-
return true;
39+
return normalizedSent.length >= normalized.length * MIN_SUBSTRING_DUPLICATE_RATIO;
4040
}
4141
return (
4242
normalizedSent.includes(normalized) &&
43-
normalized.length >= normalizedSent.length * MIN_REVERSE_SUBSTRING_DUPLICATE_RATIO
43+
normalized.length >= normalizedSent.length * MIN_SUBSTRING_DUPLICATE_RATIO
4444
);
4545
});
4646
}

0 commit comments

Comments
 (0)