mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 19:51:11 +00:00
27 lines
882 B
TypeScript
27 lines
882 B
TypeScript
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
|
|
|
const FAILURE_REPLY_PREFIXES = [
|
|
"⚠️ something went wrong while processing your request.",
|
|
"⚠️ session history got out of sync.",
|
|
"⚠️ session history was corrupted.",
|
|
"⚠️ context overflow",
|
|
"⚠️ message ordering conflict.",
|
|
"⚠️ model login expired on the gateway",
|
|
"⚠️ model login failed on the gateway",
|
|
"⚠️ agent failed before reply:",
|
|
"⚠️ no api key found for provider ",
|
|
"⚠️ missing api key for ",
|
|
];
|
|
|
|
export function extractQaFailureReplyText(text: string): string | undefined {
|
|
const trimmed = text.trim();
|
|
if (!trimmed) {
|
|
return undefined;
|
|
}
|
|
const lower = normalizeLowercaseStringOrEmpty(trimmed);
|
|
if (FAILURE_REPLY_PREFIXES.some((prefix) => lower.startsWith(prefix))) {
|
|
return trimmed;
|
|
}
|
|
return undefined;
|
|
}
|