mirror of https://github.com/openclaw/openclaw.git
fix: stop LLM retry loop on browser service unavailable
This commit is contained in:
parent
17a148c8a8
commit
9ff00ccbd2
|
|
@ -90,9 +90,16 @@ function withLoopbackBrowserAuth(
|
|||
}
|
||||
|
||||
function enhanceBrowserFetchError(url: string, err: unknown, timeoutMs: number): Error {
|
||||
const hint = isAbsoluteHttp(url)
|
||||
? "If this is a sandboxed session, ensure the sandbox browser is running and try again."
|
||||
: `Start (or restart) the OpenClaw gateway (OpenClaw.app menubar, or \`${formatCliCommand("openclaw gateway")}\`) and try again.`;
|
||||
const isLocal = !isAbsoluteHttp(url);
|
||||
// Human-facing hint for logs/diagnostics.
|
||||
const operatorHint = isLocal
|
||||
? `Restart the OpenClaw gateway (OpenClaw.app menubar, or \`${formatCliCommand("openclaw gateway")}\`).`
|
||||
: "If this is a sandboxed session, ensure the sandbox browser is running.";
|
||||
// Model-facing suffix: explicitly tell the LLM NOT to retry.
|
||||
// Without this, models see "try again" and enter an infinite tool-call loop.
|
||||
const modelHint =
|
||||
"Do NOT retry the browser tool — it will keep failing. " +
|
||||
"Use an alternative approach or inform the user that the browser is currently unavailable.";
|
||||
const msg = String(err);
|
||||
const msgLower = msg.toLowerCase();
|
||||
const looksLikeTimeout =
|
||||
|
|
@ -103,10 +110,12 @@ function enhanceBrowserFetchError(url: string, err: unknown, timeoutMs: number):
|
|||
msgLower.includes("aborterror");
|
||||
if (looksLikeTimeout) {
|
||||
return new Error(
|
||||
`Can't reach the OpenClaw browser control service (timed out after ${timeoutMs}ms). ${hint}`,
|
||||
`Can't reach the OpenClaw browser control service (timed out after ${timeoutMs}ms). ${operatorHint} ${modelHint}`,
|
||||
);
|
||||
}
|
||||
return new Error(`Can't reach the OpenClaw browser control service. ${hint} (${msg})`);
|
||||
return new Error(
|
||||
`Can't reach the OpenClaw browser control service. ${operatorHint} ${modelHint} (${msg})`,
|
||||
);
|
||||
}
|
||||
|
||||
async function fetchHttpJson<T>(
|
||||
|
|
|
|||
Loading…
Reference in New Issue