Principle:AMAP ML SkillClaw Upstream Forwarding With Failover
| 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:
- Bounded total timeout: , all attempts share this budget
- Retryable errors: HTTP {408, 429, 500, 502, 503, 504} trigger failover
- Exponential backoff with jitter:
- 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))