diff options
| author | t <t@tjp.lol> | 2026-06-04 09:46:49 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-04 12:09:09 -0600 |
| commit | 3f1ace16afc7877b0bfad374cb286d4d84140960 (patch) | |
| tree | a114a0081e147ef02f0188e408d79199f5e7dcfc /libpanto/src/config.zig | |
| parent | ac5c4898dfa0a9e57424336774893dfc72b132e9 (diff) | |
failure retries scheme
Diffstat (limited to 'libpanto/src/config.zig')
| -rw-r--r-- | libpanto/src/config.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libpanto/src/config.zig b/libpanto/src/config.zig index 114280c..eca81ff 100644 --- a/libpanto/src/config.zig +++ b/libpanto/src/config.zig @@ -87,6 +87,25 @@ pub const CompactionConfig = struct { model: ?ProviderConfig = null, }; +/// Policy for retrying transient provider/API failures. Conservative +/// defaults: four attempts (one initial + three retries) with exponential +/// backoff and jitter, capped at 10s per delay. +pub const RetryConfig = struct { + /// Total attempts including the first. `4` => initial try + up to 3 + /// retries. Must be >= 1. + max_attempts: usize = 4, + /// Base delay before the first retry, in milliseconds. + initial_delay_ms: u64 = 500, + /// Upper bound on any single backoff delay, in milliseconds. Also caps + /// a provider-supplied `Retry-After`. + max_delay_ms: u64 = 10_000, + /// Exponential growth factor applied per retry. + multiplier: f64 = 2.0, + /// When true, apply random jitter in `[0, computed_delay)` (full + /// jitter) to avoid thundering-herd retries. + jitter: bool = true, +}; + /// An immutable snapshot of everything the agent consults per turn: which /// provider/model to talk to, and which tools to expose. The agent holds a /// `*const Config` and re-reads it each turn; replacing the pointer swaps @@ -99,6 +118,7 @@ pub const Config = struct { provider: ProviderConfig, registry: *const ToolRegistry, compaction: CompactionConfig = .{}, + retry: RetryConfig = .{}, pub fn style(self: Config) APIStyle { return self.provider.style(); |
