From 3f1ace16afc7877b0bfad374cb286d4d84140960 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 4 Jun 2026 09:46:49 -0600 Subject: failure retries scheme --- libpanto/src/config.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libpanto/src/config.zig') 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(); -- cgit v1.3