mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 23:14:31 +00:00
fix: handle CLI session expired errors gracefully instead of crashing gateway (#31090)
* fix: handle CLI session expired errors gracefully - Add session_expired to FailoverReason type - Add isCliSessionExpiredErrorMessage to detect expired CLI sessions - Modify runCliAgent to retry with new session when session expires - Update agentCommand to clear expired session IDs from session store - Add proper error handling to prevent gateway crashes on expired sessions Fixes #30986 * fix: add session_expired to AuthProfileFailureReason and missing log import * fix: type cli-runner usage field to match EmbeddedPiAgentMeta * fix: harden CLI session-expiry recovery handling * build: regenerate host env security policy swift --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -883,6 +883,27 @@ export function isModelNotFoundErrorMessage(raw: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isCliSessionExpiredErrorMessage(raw: string): boolean {
|
||||
if (!raw) {
|
||||
return false;
|
||||
}
|
||||
const lower = raw.toLowerCase();
|
||||
return (
|
||||
lower.includes("session not found") ||
|
||||
lower.includes("session does not exist") ||
|
||||
lower.includes("session expired") ||
|
||||
lower.includes("session invalid") ||
|
||||
lower.includes("conversation not found") ||
|
||||
lower.includes("conversation does not exist") ||
|
||||
lower.includes("conversation expired") ||
|
||||
lower.includes("conversation invalid") ||
|
||||
lower.includes("no such session") ||
|
||||
lower.includes("invalid session") ||
|
||||
lower.includes("session id not found") ||
|
||||
lower.includes("conversation id not found")
|
||||
);
|
||||
}
|
||||
|
||||
export function classifyFailoverReason(raw: string): FailoverReason | null {
|
||||
if (isImageDimensionErrorMessage(raw)) {
|
||||
return null;
|
||||
@@ -890,6 +911,9 @@ export function classifyFailoverReason(raw: string): FailoverReason | null {
|
||||
if (isImageSizeError(raw)) {
|
||||
return null;
|
||||
}
|
||||
if (isCliSessionExpiredErrorMessage(raw)) {
|
||||
return "session_expired";
|
||||
}
|
||||
if (isModelNotFoundErrorMessage(raw)) {
|
||||
return "model_not_found";
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ export type FailoverReason =
|
||||
| "billing"
|
||||
| "timeout"
|
||||
| "model_not_found"
|
||||
| "session_expired"
|
||||
| "unknown";
|
||||
|
||||
Reference in New Issue
Block a user