Fix: further improve Ollama reliability with retry delays and increased attempts

This commit is contained in:
larchanka
2026-02-23 11:32:54 +01:00
committed by Mikhail Larchanka
parent b398bba68a
commit 36a812c29a
3 changed files with 10 additions and 4 deletions

View File

@@ -394,14 +394,21 @@ export class OllamaAdapter {
(err.name === "AbortError" ||
err.message.includes("fetch") ||
err.message.includes("ECONNREFUSED") ||
err.message.includes("network"));
err.message.includes("network") ||
err.message.includes("reset") ||
err.message.includes("hangup"));
if (attempt === this.retries || !isRetryable) {
if (err instanceof Error && (err as any).cause) {
err.message += ` (Cause: ${(err as any).cause})`;
const cause = (err as any).cause;
const causeMsg = cause instanceof Error ? cause.message : String(cause);
err.message += ` (Cause: ${causeMsg})`;
}
throw err;
}
// Wait before retry: 1s, 2s...
console.warn(`[ollama-adapter] Fetch failed: ${err.message}. Retrying in ${(attempt + 1)}s... (Attempt ${attempt + 1}/${this.retries})`);
await new Promise((resolve) => setTimeout(resolve, (attempt + 1) * 1000));
}
}
throw lastError;

View File

@@ -140,7 +140,7 @@ const DEFAULT_CONFIG: AppConfig = {
ollama: {
baseUrl: "http://127.0.0.1:11434",
timeoutMs: 600_000, // 10 minutes default
retries: 2,
retries: 3,
numCtx: 16384,
},
telegram: {

File diff suppressed because one or more lines are too long