mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:41:37 +00:00
refactor: extract iMessage echo cache and unify suppression guards
This commit is contained in:
@@ -17,6 +17,7 @@ import type { GetReplyOptions, ReplyPayload } from "../types.js";
|
||||
import { formatAbortReplyText, tryFastAbortFromMessage } from "./abort.js";
|
||||
import { shouldSkipDuplicateInbound } from "./inbound-dedupe.js";
|
||||
import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js";
|
||||
import { shouldSuppressReasoningPayload } from "./reply-payloads.js";
|
||||
import { isRoutableChannel, routeReply } from "./route-reply.js";
|
||||
|
||||
const AUDIO_PLACEHOLDER_RE = /^<media:audio>(\s*\([^)]*\))?$/i;
|
||||
@@ -366,7 +367,7 @@ export async function dispatchReplyFromConfig(params: {
|
||||
// Suppress reasoning payloads — channels using this generic dispatch
|
||||
// path (WhatsApp, web, etc.) do not have a dedicated reasoning lane.
|
||||
// Telegram has its own dispatch path that handles reasoning splitting.
|
||||
if (payload.isReasoning) {
|
||||
if (shouldSuppressReasoningPayload(payload)) {
|
||||
return;
|
||||
}
|
||||
// Accumulate block text for TTS generation after streaming
|
||||
@@ -404,7 +405,7 @@ export async function dispatchReplyFromConfig(params: {
|
||||
for (const reply of replies) {
|
||||
// Suppress reasoning payloads from channel delivery — channels using this
|
||||
// generic dispatch path do not have a dedicated reasoning lane.
|
||||
if (reply.isReasoning) {
|
||||
if (shouldSuppressReasoningPayload(reply)) {
|
||||
continue;
|
||||
}
|
||||
const ttsReply = await maybeApplyTtsToPayload({
|
||||
|
||||
@@ -68,6 +68,10 @@ export function isRenderablePayload(payload: ReplyPayload): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export function shouldSuppressReasoningPayload(payload: ReplyPayload): boolean {
|
||||
return payload.isReasoning === true;
|
||||
}
|
||||
|
||||
export function applyReplyThreading(params: {
|
||||
payloads: ReplyPayload[];
|
||||
replyToMode: ReplyToMode;
|
||||
|
||||
@@ -15,6 +15,7 @@ import { INTERNAL_MESSAGE_CHANNEL, normalizeMessageChannel } from "../../utils/m
|
||||
import type { OriginatingChannelType } from "../templating.js";
|
||||
import type { ReplyPayload } from "../types.js";
|
||||
import { normalizeReplyPayload } from "./normalize-reply.js";
|
||||
import { shouldSuppressReasoningPayload } from "./reply-payloads.js";
|
||||
|
||||
export type RouteReplyParams = {
|
||||
/** The reply payload to send. */
|
||||
@@ -56,7 +57,7 @@ export type RouteReplyResult = {
|
||||
*/
|
||||
export async function routeReply(params: RouteReplyParams): Promise<RouteReplyResult> {
|
||||
const { payload, channel, to, accountId, threadId, cfg, abortSignal } = params;
|
||||
if (payload.isReasoning) {
|
||||
if (shouldSuppressReasoningPayload(payload)) {
|
||||
return { ok: true };
|
||||
}
|
||||
const normalizedChannel = normalizeMessageChannel(channel);
|
||||
|
||||
Reference in New Issue
Block a user