From e2dc9b1682a3a140a3ee15621e58d9ed223c49b9 Mon Sep 17 00:00:00 2001 From: zidongdesign Date: Sun, 8 Mar 2026 15:36:02 +0800 Subject: [PATCH] fix(threading): keep compaction notices threaded after first assistant block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In replyToMode=first, the hasThreaded flag was set by the first assistant chunk, causing the completion notice (emitted after flush) to hit the `if (hasThreaded)` branch and have its replyToId stripped — making it an unthreaded top-level message. Fix: add an isCompactionNotice exemption inside the `hasThreaded` branch so that compaction notices (both start and completion) always retain their replyToId regardless of hasThreaded state, while non-notice payloads continue to behave as before. Addresses review comment https://github.com/openclaw/openclaw/pull/38805#discussion_r2901465625 --- src/auto-reply/reply/reply-threading.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/auto-reply/reply/reply-threading.ts b/src/auto-reply/reply/reply-threading.ts index e5ee97a9d7f..177f4ccbe0b 100644 --- a/src/auto-reply/reply/reply-threading.ts +++ b/src/auto-reply/reply/reply-threading.ts @@ -42,6 +42,12 @@ export function createReplyToModeFilter( return payload; } if (hasThreaded) { + // Compaction notices are transient status messages that should always + // appear in-thread, even after the first assistant block has already + // consumed the "first" slot. Let them keep their replyToId. + if (payload.isCompactionNotice) { + return payload; + } return { ...payload, replyToId: undefined }; } // Compaction notices are transient status messages — they should be