mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 08:02:17 +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
|
|
@ -264,6 +264,20 @@ export class RpcClient {
|
|||
await this.send({ type: "set_auto_compaction", enabled });
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auto-retry enabled/disabled.
|
||||
*/
|
||||
async setAutoRetry(enabled: boolean): Promise<void> {
|
||||
await this.send({ type: "set_auto_retry", enabled });
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort in-progress retry.
|
||||
*/
|
||||
async abortRetry(): Promise<void> {
|
||||
await this.send({ type: "abort_retry" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a bash command.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -270,6 +270,20 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
return success(id, "set_auto_compaction");
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Retry
|
||||
// =================================================================
|
||||
|
||||
case "set_auto_retry": {
|
||||
session.setAutoRetryEnabled(command.enabled);
|
||||
return success(id, "set_auto_retry");
|
||||
}
|
||||
|
||||
case "abort_retry": {
|
||||
session.abortRetry();
|
||||
return success(id, "abort_retry");
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Bash
|
||||
// =================================================================
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ export type RpcCommand =
|
|||
| { id?: string; type: "compact"; customInstructions?: string }
|
||||
| { id?: string; type: "set_auto_compaction"; enabled: boolean }
|
||||
|
||||
// Retry
|
||||
| { id?: string; type: "set_auto_retry"; enabled: boolean }
|
||||
| { id?: string; type: "abort_retry" }
|
||||
|
||||
// Bash
|
||||
| { id?: string; type: "bash"; command: string }
|
||||
| { id?: string; type: "abort_bash" }
|
||||
|
|
@ -127,6 +131,10 @@ export type RpcResponse =
|
|||
| { id?: string; type: "response"; command: "compact"; success: true; data: CompactionResult }
|
||||
| { id?: string; type: "response"; command: "set_auto_compaction"; success: true }
|
||||
|
||||
// Retry
|
||||
| { id?: string; type: "response"; command: "set_auto_retry"; success: true }
|
||||
| { id?: string; type: "response"; command: "abort_retry"; success: true }
|
||||
|
||||
// Bash
|
||||
| { id?: string; type: "response"; command: "bash"; success: true; data: BashResult }
|
||||
| { id?: string; type: "response"; command: "abort_bash"; success: true }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue