import { getChannelPlugin } from "../../channels/plugins/index.js"; import type { ChannelThreadingAdapter } from "../../channels/plugins/types.core.js"; import { normalizeAnyChannelId } from "../../channels/registry.js"; import type { ReplyToMode } from "../../config/types.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js"; import type { OriginatingChannelType } from "../templating.js"; import type { ReplyPayload, ReplyThreadingPolicy } from "../types.js"; import { isSingleUseReplyToMode } from "./reply-reference.js";
export function createReplyToModeFilter(
mode: ReplyToMode,
opts: { allowExplicitReplyTagsWhenOff?: boolean } = {},
) {
let hasThreaded = false; return (payload: ReplyPayload): ReplyPayload => { if (!payload.replyToId) { return payload;
} if (mode === "off") { const isExplicit = Boolean(payload.replyToTag) || Boolean(payload.replyToCurrent); // Compaction notices must never be threaded when replyToMode=off — even // if they carry explicit reply tags (replyToCurrent). Honouring the // explicit tag here would make status notices appear in-thread while // normal assistant replies stay off-thread, contradicting the off-mode // expectation. Strip replyToId unconditionally for compaction payloads. if (opts.allowExplicitReplyTagsWhenOff && isExplicit && !payload.isCompactionNotice) { return payload;
} return { ...payload, replyToId: undefined };
} if (mode === "all") { return payload;
} if (isSingleUseReplyToMode(mode) && 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 // threaded (so they appear in-context), but they must not consume the // "first" slot of the replyToMode=first|batched filter. Skip advancing // hasThreaded so the real assistant reply still gets replyToId. if (isSingleUseReplyToMode(mode) && !payload.isCompactionNotice) {
hasThreaded = true;
} return payload;
};
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.