mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 15:48:28 +00:00
fix: harden heartbeat acks + gateway reconnect
This commit is contained in:
@@ -6,16 +6,8 @@ export function stripHeartbeatToken(raw?: string) {
|
||||
if (!raw) return { shouldSkip: true, text: "" };
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed) return { shouldSkip: true, text: "" };
|
||||
if (trimmed === HEARTBEAT_TOKEN) return { shouldSkip: true, text: "" };
|
||||
const hadToken = trimmed.includes(HEARTBEAT_TOKEN);
|
||||
let withoutToken = trimmed.replaceAll(HEARTBEAT_TOKEN, "").trim();
|
||||
if (hadToken && withoutToken) {
|
||||
// LLMs sometimes echo malformed HEARTBEAT_OK_OK... tails; strip trailing OK runs to avoid spam.
|
||||
withoutToken = withoutToken.replace(/[\s_]*OK(?:[\s_]*OK)*$/gi, "").trim();
|
||||
if (trimmed.includes(HEARTBEAT_TOKEN)) {
|
||||
return { shouldSkip: true, text: "" };
|
||||
}
|
||||
const shouldSkip = withoutToken.length === 0;
|
||||
return {
|
||||
shouldSkip,
|
||||
text: shouldSkip ? "" : withoutToken || trimmed,
|
||||
};
|
||||
return { shouldSkip: false, text: trimmed };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user