mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
Auto-retry on transient provider errors (overloaded, rate limit, 5xx)
- Add retry logic with exponential backoff (2s, 4s, 8s) in AgentSession - Disable Anthropic SDK built-in retries (maxRetries: 0) to allow app-level handling - TUI shows retry status with Escape to cancel - RPC mode: add set_auto_retry, abort_retry commands and auto_retry_start/end events - Configurable via settings.json: retry.enabled, retry.maxRetries, retry.baseDelayMs - Exclude context overflow errors from retry (handled by compaction) fixes #157
This commit is contained in:
parent
79f5c6d22e
commit
bb445d24f1
11 changed files with 379 additions and 3 deletions
|
|
@ -8,6 +8,12 @@ export interface CompactionSettings {
|
|||
keepRecentTokens?: number; // default: 20000
|
||||
}
|
||||
|
||||
export interface RetrySettings {
|
||||
enabled?: boolean; // default: true
|
||||
maxRetries?: number; // default: 3
|
||||
baseDelayMs?: number; // default: 2000 (exponential backoff: 2s, 4s, 8s)
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
lastChangelogVersion?: string;
|
||||
defaultProvider?: string;
|
||||
|
|
@ -16,6 +22,7 @@ export interface Settings {
|
|||
queueMode?: "all" | "one-at-a-time";
|
||||
theme?: string;
|
||||
compaction?: CompactionSettings;
|
||||
retry?: RetrySettings;
|
||||
hideThinkingBlock?: boolean;
|
||||
shellPath?: string; // Custom shell path (e.g., for Cygwin users on Windows)
|
||||
collapseChangelog?: boolean; // Show condensed changelog after update (use /changelog for full)
|
||||
|
|
@ -149,6 +156,26 @@ export class SettingsManager {
|
|||
};
|
||||
}
|
||||
|
||||
getRetryEnabled(): boolean {
|
||||
return this.settings.retry?.enabled ?? true;
|
||||
}
|
||||
|
||||
setRetryEnabled(enabled: boolean): void {
|
||||
if (!this.settings.retry) {
|
||||
this.settings.retry = {};
|
||||
}
|
||||
this.settings.retry.enabled = enabled;
|
||||
this.save();
|
||||
}
|
||||
|
||||
getRetrySettings(): { enabled: boolean; maxRetries: number; baseDelayMs: number } {
|
||||
return {
|
||||
enabled: this.getRetryEnabled(),
|
||||
maxRetries: this.settings.retry?.maxRetries ?? 3,
|
||||
baseDelayMs: this.settings.retry?.baseDelayMs ?? 2000,
|
||||
};
|
||||
}
|
||||
|
||||
getHideThinkingBlock(): boolean {
|
||||
return this.settings.hideThinkingBlock ?? false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue