Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AMAP ML SkillClaw Upstream Forwarding With Failover

From Leeroopedia
Knowledge Sources
Domains Fault_Tolerance, Networking
Last Updated 2026-10-22 00:00 GMT

Overview

A bounded failover pattern that forwards requests to a primary upstream endpoint with automatic fallback to preconfigured backup endpoints, governed by a shared time budget and retryable-error detection.

Description

Upstream forwarding with failover addresses the problem of maintaining availability when the primary LLM endpoint is unreliable. The SkillClaw pattern tries the primary endpoint first, then falls over to up to 3 preconfigured fallback endpoints on retryable HTTP errors (408, 429, 500, 502, 503, 504). A shared time budget (`timeout`) bounds all attempts together rather than resetting per endpoint, preventing indefinite retry loops. The pattern also handles compatibility retries: removing unsupported `temperature` parameters and switching to stream mode when required by the upstream.

Usage

Use this principle when designing systems that need:

  • High-availability LLM access with fallback endpoints
  • Bounded retry with exponential backoff and jitter
  • Automatic compatibility adjustment (parameter removal, stream mode)
  • Rate-limit-aware failover (skip quota-exhausted accounts)

Theoretical Basis

The failover logic combines several patterns:

  1. Bounded total timeout: Ttotal=timeout, all attempts share this budget
  2. Retryable errors: HTTP {408, 429, 500, 502, 503, 504} trigger failover
  3. Exponential backoff with jitter: delay=min⁡(2n+random(0,1),30)
  4. Endpoint rotation: Primary → fallback1 → fallback2 → fallback3
# Abstract algorithm (NOT real implementation)
async def forward_with_failover(config, body, timeout):
    endpoints = [primary] + fallbacks[:3]
    deadline = time.now() + timeout
    for attempt in range(6):
        endpoint = endpoints[min(attempt, len(endpoints) - 1)]
        try:
            response = await send(endpoint, body)
            return response
        except RetryableError as e:
            if is_quota_exhausted(e) and no_more_endpoints:
                break
            if time.now() > deadline:
                raise TimeoutError
            await sleep(backoff(attempt))

Related Pages

Implemented By

Uses Heuristic

Page Connections

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