mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:58:26 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -76,7 +76,9 @@ export function buildEmbeddedRunPayloads(params: {
|
||||
: null;
|
||||
const normalizedErrorText = errorText ? normalizeTextForComparison(errorText) : null;
|
||||
const genericErrorText = "The AI service returned an error. Please try again.";
|
||||
if (errorText) replyItems.push({ text: errorText, isError: true });
|
||||
if (errorText) {
|
||||
replyItems.push({ text: errorText, isError: true });
|
||||
}
|
||||
|
||||
const inlineToolResults =
|
||||
params.inlineToolResultsAllowed && params.verboseLevel !== "off" && params.toolMetas.length > 0;
|
||||
@@ -110,31 +112,51 @@ export function buildEmbeddedRunPayloads(params: {
|
||||
params.lastAssistant && params.reasoningLevel === "on"
|
||||
? formatReasoningMessage(extractAssistantThinking(params.lastAssistant))
|
||||
: "";
|
||||
if (reasoningText) replyItems.push({ text: reasoningText });
|
||||
if (reasoningText) {
|
||||
replyItems.push({ text: reasoningText });
|
||||
}
|
||||
|
||||
const fallbackAnswerText = params.lastAssistant ? extractAssistantText(params.lastAssistant) : "";
|
||||
const shouldSuppressRawErrorText = (text: string) => {
|
||||
if (!lastAssistantErrored) return false;
|
||||
if (!lastAssistantErrored) {
|
||||
return false;
|
||||
}
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) return false;
|
||||
if (!trimmed) {
|
||||
return false;
|
||||
}
|
||||
if (errorText) {
|
||||
const normalized = normalizeTextForComparison(trimmed);
|
||||
if (normalized && normalizedErrorText && normalized === normalizedErrorText) return true;
|
||||
if (trimmed === genericErrorText) return true;
|
||||
if (normalized && normalizedErrorText && normalized === normalizedErrorText) {
|
||||
return true;
|
||||
}
|
||||
if (trimmed === genericErrorText) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (rawErrorMessage && trimmed === rawErrorMessage) {
|
||||
return true;
|
||||
}
|
||||
if (formattedRawErrorMessage && trimmed === formattedRawErrorMessage) {
|
||||
return true;
|
||||
}
|
||||
if (rawErrorMessage && trimmed === rawErrorMessage) return true;
|
||||
if (formattedRawErrorMessage && trimmed === formattedRawErrorMessage) return true;
|
||||
if (normalizedRawErrorText) {
|
||||
const normalized = normalizeTextForComparison(trimmed);
|
||||
if (normalized && normalized === normalizedRawErrorText) return true;
|
||||
if (normalized && normalized === normalizedRawErrorText) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (normalizedFormattedRawErrorMessage) {
|
||||
const normalized = normalizeTextForComparison(trimmed);
|
||||
if (normalized && normalized === normalizedFormattedRawErrorMessage) return true;
|
||||
if (normalized && normalized === normalizedFormattedRawErrorMessage) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (rawErrorFingerprint) {
|
||||
const fingerprint = getApiErrorPayloadFingerprint(trimmed);
|
||||
if (fingerprint && fingerprint === rawErrorFingerprint) return true;
|
||||
if (fingerprint && fingerprint === rawErrorFingerprint) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return isRawApiErrorPayload(trimmed);
|
||||
};
|
||||
@@ -222,8 +244,12 @@ export function buildEmbeddedRunPayloads(params: {
|
||||
audioAsVoice: item.audioAsVoice || Boolean(hasAudioAsVoiceTag && item.media?.length),
|
||||
}))
|
||||
.filter((p) => {
|
||||
if (!p.text && !p.mediaUrl && (!p.mediaUrls || p.mediaUrls.length === 0)) return false;
|
||||
if (p.text && isSilentReplyText(p.text, SILENT_REPLY_TOKEN)) return false;
|
||||
if (!p.text && !p.mediaUrl && (!p.mediaUrls || p.mediaUrls.length === 0)) {
|
||||
return false;
|
||||
}
|
||||
if (p.text && isSilentReplyText(p.text, SILENT_REPLY_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user