fix(threading): keep compaction notices threaded after first assistant block

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
This commit is contained in:
zidongdesign 2026-03-08 15:36:02 +08:00 committed by Josh Lehman
parent 1e381c6c8c
commit e2dc9b1682
No known key found for this signature in database
GPG Key ID: D141B425AC7F876B

View File

@ -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