mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 15:50:20 +00:00
fix: hide raw provider errors from chat replies
This commit is contained in:
@@ -119,6 +119,23 @@ function isPureTransientRateLimitSummary(err: unknown): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function isToolResultTurnMismatchError(message: string): boolean {
|
||||
const lower = message.toLowerCase();
|
||||
return (
|
||||
lower.includes("toolresult") &&
|
||||
lower.includes("tooluse") &&
|
||||
lower.includes("exceeds the number") &&
|
||||
lower.includes("previous turn")
|
||||
);
|
||||
}
|
||||
|
||||
function buildExternalRunFailureText(message: string): string {
|
||||
if (isToolResultTurnMismatchError(message)) {
|
||||
return "⚠️ Session history got out of sync. Please try again, or use /new to start a fresh session.";
|
||||
}
|
||||
return "⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.";
|
||||
}
|
||||
|
||||
export async function runAgentTurnWithFallback(params: {
|
||||
commandBody: string;
|
||||
followupRun: FollowupRun;
|
||||
@@ -769,7 +786,9 @@ export async function runAgentTurnWithFallback(params: {
|
||||
? "⚠️ Context overflow — prompt too large for this model. Try a shorter message or a larger-context model."
|
||||
: isRoleOrderingError
|
||||
? "⚠️ Message ordering conflict - please try again. If this persists, use /new to start a fresh session."
|
||||
: `⚠️ Agent failed before reply: ${trimmedMessage}.\nLogs: openclaw logs --follow`;
|
||||
: shouldSurfaceToControlUi
|
||||
? `⚠️ Agent failed before reply: ${trimmedMessage}.\nLogs: openclaw logs --follow`
|
||||
: buildExternalRunFailureText(message);
|
||||
|
||||
return {
|
||||
kind: "final",
|
||||
|
||||
Reference in New Issue
Block a user