|
@@ -80,9 +80,15 @@ const configSchema = {
|
|
|
retryDelayMs: {
|
|
retryDelayMs: {
|
|
|
type: 'number',
|
|
type: 'number',
|
|
|
title: 'Retry Delay (ms)',
|
|
title: 'Retry Delay (ms)',
|
|
|
- description: 'Pause before each retry attempt',
|
|
|
|
|
|
|
+ description: 'Pause before the first retry. Doubles on each further attempt.',
|
|
|
default: 2000
|
|
default: 2000
|
|
|
},
|
|
},
|
|
|
|
|
+ retryMaxDelayMs: {
|
|
|
|
|
+ type: 'number',
|
|
|
|
|
+ title: 'Max Retry Delay (ms)',
|
|
|
|
|
+ description: 'Upper bound for the exponential backoff',
|
|
|
|
|
+ default: 30000
|
|
|
|
|
+ },
|
|
|
skipOnError: {
|
|
skipOnError: {
|
|
|
type: 'boolean',
|
|
type: 'boolean',
|
|
|
title: 'Skip On Error',
|
|
title: 'Skip On Error',
|
|
@@ -293,7 +299,15 @@ module.exports = {
|
|
|
parsed = null;
|
|
parsed = null;
|
|
|
smartbotic.log.warn('ollama-chat: attempt ' + attempt + ' of ' + attempts + ' failed: ' + lastError);
|
|
smartbotic.log.warn('ollama-chat: attempt ' + attempt + ' of ' + attempts + ' failed: ' + lastError);
|
|
|
if (attempt < attempts) {
|
|
if (attempt < attempts) {
|
|
|
- smartbotic.utils.sleep(Number(config.retryDelayMs) || 2000);
|
|
|
|
|
|
|
+ // Exponential backoff. Ollama's cloud tier returns transient 500s far
|
|
|
|
|
+ // more often under rapid succession, so spacing retries out recovers
|
|
|
|
|
+ // markedly better than hammering at a fixed interval.
|
|
|
|
|
+ const base = Number(config.retryDelayMs) || 2000;
|
|
|
|
|
+ const cap = Number(config.retryMaxDelayMs) || 30000;
|
|
|
|
|
+ let delay = base * Math.pow(2, attempt - 1);
|
|
|
|
|
+ if (delay > cap) { delay = cap; }
|
|
|
|
|
+ smartbotic.log.info('ollama-chat: backing off ' + delay + 'ms before retry');
|
|
|
|
|
+ smartbotic.utils.sleep(delay);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|