AgentForge

Retry

Automatic retry with configurable backoff strategies for tool execution failures.

RetryConfig

Every tool has built-in retry support:

interface RetryConfig {
  maxAttempts?: number;       // Default: 3
  backoff?: BackoffStrategy;  // Default: 'exponential'
  baseDelay?: number;         // Default: 1000 (ms)
}

type BackoffStrategy = 'exponential' | 'linear' | 'fixed';

Defaults

If you don't configure retry, tools get these defaults:

SettingDefault
maxAttempts3
backoff'exponential'
baseDelay1000ms

Backoff Strategies

StrategyDelay PatternExample (base: 1000ms)
exponentialbaseDelay * 2^attempt1s, 2s, 4s
linearbaseDelay * attempt1s, 2s, 3s
fixedbaseDelay1s, 1s, 1s

Custom Retry Config

const apiTool = defineTool({
  name: 'external-api',
  description: 'Call an external API',
  input: z.object({ endpoint: z.string() }),
  output: z.object({ data: z.unknown() }),
  execute: async ({ endpoint }) => {
    const res = await fetch(endpoint);
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    return { data: await res.json() };
  },
  retry: {
    maxAttempts: 5,
    backoff: 'exponential',
    baseDelay: 2000,
  },
});

Disabling Retry

Set maxAttempts: 1 to disable retry:

const oneShot = defineTool({
  name: 'send-email',
  description: 'Send an email (no retry)',
  input: z.object({ to: z.string(), body: z.string() }),
  output: z.object({ sent: z.boolean() }),
  execute: async (input) => { /* ... */ },
  retry: { maxAttempts: 1 },
});

Next Steps