summaryrefslogtreecommitdiff
path: root/libpanto/src/config.zig
diff options
context:
space:
mode:
Diffstat (limited to 'libpanto/src/config.zig')
-rw-r--r--libpanto/src/config.zig20
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();