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 LLM Client Abstraction

From Leeroopedia
Knowledge Sources
Domains LLM_Client, Async_IO
Last Updated 2026-10-22 00:00 GMT

Overview

An LLM client abstraction that wraps synchronous OpenAI-compatible SDKs with async dispatch, automatic retries, exponential backoff, and compatibility handling for provider-specific quirks.

Description

LLM client abstraction addresses the problem of making reliable LLM API calls from async applications. The SkillClaw pattern wraps the synchronous `openai` SDK in `asyncio.to_thread` calls, keeping the event loop free during HTTP round-trips. It includes retry logic (up to 6 attempts with exponential backoff and jitter), compatibility handling (removing unsupported `temperature` parameter, falling back to streaming when required), and model-specific normalization. Two variants exist: `AsyncLLMClient` (evolve server, async) and `run_llm` (client proxy, synchronous, supports Bedrock).

Usage

Use this principle when designing systems that need:

  • Async LLM clients in event-loop-based applications
  • Retry logic with exponential backoff
  • Provider compatibility handling
  • Multi-provider routing (OpenAI, Bedrock)

Theoretical Basis

The retry pattern with exponential backoff:

delayn=min⁡(2n+uniform(0,1),30)

# Abstract algorithm (NOT real implementation)
async def chat_with_retries(client, messages, max_retries=6):
    for attempt in range(max_retries):
        try:
            return await asyncio.to_thread(client.chat, messages)
        except RetryableError:
            if attempt < max_retries - 1:
                await sleep(min(2**attempt + random(), 30))
            else:
                raise

Related Pages

Implemented By

Uses Heuristic

Page Connections

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