Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:HKUDS AI Trader Agentic Retry Loop

From Leeroopedia


Knowledge Sources
Domains Reliability, LLM_Agents
Last Updated 2026-02-09 14:00 GMT

Overview

A fault-tolerance pattern that wraps LLM invocations with exponential backoff retries to handle transient API failures.

Description

Agentic Retry Loop provides resilience against transient failures in LLM API calls. External LLM providers may return rate limit errors (429), server errors (500+), or timeout on any individual request. Rather than failing the entire trading session, this pattern retries the invocation with exponentially increasing delays.

This is essential for multi-day backtesting where a single API failure should not abort the entire simulation. The retry mechanism wraps each individual LLM invocation, separate from the multi-step reasoning loop.

Usage

Use this principle wherever LLM inference calls are made against external APIs. It is the inner retry layer (per-invocation), distinct from the outer reasoning loop (multi-step trading session).

Theoretical Basis

# Pseudocode for retry with exponential backoff
for attempt in range(1, max_retries + 1):
    try:
        response = await agent.ainvoke(messages)
        return response
    except Exception as e:
        if attempt == max_retries:
            raise
        delay = base_delay * attempt
        await sleep(delay)

Key properties:

  • Exponential backoff: Delay increases linearly with attempt number (base_delay * attempt)
  • Bounded retries: Maximum number of attempts prevents infinite loops
  • Transparent: Callers receive the response as if no retry occurred
  • Last-exception propagation: Final failure re-raises the last exception

Related Pages

Uses Heuristic

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment