Skip to content

Commit 6198909

Browse files
fix(reply): fix duplicate block replies by unblocking coalesced payloads (openclaw#5080)
Merged via squash. Prepared head SHA: 399e125 Co-authored-by: yassine20011 <[email protected]> Co-authored-by: jalehman <[email protected]> Reviewed-by: @jalehman
1 parent c58d2aa commit 6198909

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

changelog/fragments/pr-5080.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Clarify block reply pipeline seen-check parameter naming for maintainability (#5080) (thanks @yassine20011)

src/auto-reply/reply/block-reply-pipeline.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ export function createBlockReplyPipeline(params: {
9090
let didStream = false;
9191
let didLogTimeout = false;
9292

93-
const sendPayload = (payload: ReplyPayload, skipSeen?: boolean) => {
93+
const sendPayload = (payload: ReplyPayload, bypassSeenCheck: boolean = false) => {
9494
if (aborted) {
9595
return;
9696
}
9797
const payloadKey = createBlockReplyPayloadKey(payload);
98-
if (!skipSeen) {
98+
if (!bypassSeenCheck) {
9999
if (seenKeys.has(payloadKey)) {
100100
return;
101101
}
@@ -155,7 +155,7 @@ export function createBlockReplyPipeline(params: {
155155
shouldAbort: () => aborted,
156156
onFlush: (payload) => {
157157
bufferedKeys.clear();
158-
sendPayload(payload);
158+
sendPayload(payload, /* bypassSeenCheck */ true);
159159
},
160160
})
161161
: null;
@@ -186,7 +186,7 @@ export function createBlockReplyPipeline(params: {
186186
}
187187
for (const payload of bufferedPayloads) {
188188
const finalPayload = buffer?.finalize?.(payload) ?? payload;
189-
sendPayload(finalPayload, true);
189+
sendPayload(finalPayload, /* bypassSeenCheck */ true);
190190
}
191191
bufferedPayloads.length = 0;
192192
bufferedPayloadKeys.clear();
@@ -202,19 +202,20 @@ export function createBlockReplyPipeline(params: {
202202
const hasMedia = Boolean(payload.mediaUrl) || (payload.mediaUrls?.length ?? 0) > 0;
203203
if (hasMedia) {
204204
void coalescer?.flush({ force: true });
205-
sendPayload(payload);
205+
sendPayload(payload, /* bypassSeenCheck */ false);
206206
return;
207207
}
208208
if (coalescer) {
209209
const payloadKey = createBlockReplyPayloadKey(payload);
210210
if (seenKeys.has(payloadKey) || pendingKeys.has(payloadKey) || bufferedKeys.has(payloadKey)) {
211211
return;
212212
}
213+
seenKeys.add(payloadKey);
213214
bufferedKeys.add(payloadKey);
214215
coalescer.enqueue(payload);
215216
return;
216217
}
217-
sendPayload(payload);
218+
sendPayload(payload, /* bypassSeenCheck */ false);
218219
};
219220

220221
const flush = async (options?: { force?: boolean }) => {

0 commit comments

Comments
 (0)