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:416rehman DeepZero LLM Backend Dispatch

From Leeroopedia
Knowledge Sources
Domains LLM_Backend, Dispatch
Last Updated 2026-10-27 00:00 GMT

Overview

A model-string dispatch pattern where a scheme prefix (before the first slash) selects the backend class, and unregistered schemes fall through to a default backend covering all API-key endpoints.

Description

Model-string dispatch maps a user-facing model string (e.g., "claude-code/claude-opus-5", "openai/gpt-4o") to a concrete backend class. The scheme is the part before the first slash; the alias is the part after. A registry maps schemes to backend classes.

The fall-through to default is critical: an unregistered scheme (e.g., "openai/gpt-4o", "gemini/gemini-pro", or a bare "gpt-4o") lands on the default backend (LiteLLM), which handles every API-key endpoint it supports. This means:

  • Registered schemes get specialized backends (e.g., "claude-code" → ClaudeCodeBackend for subscription auth).
  • Everything else gets the general-purpose API-key backend.
  • No user ever needs to know which backend handles their model—the dispatch is transparent.

The pre-flight validation (validate_model_binding) runs at pipeline load time. Each backend's validate_model() checks its own prerequisites (binary presence, API key presence) and returns problems. This catches "model configured but CLI not installed" before a run starts.

Usage

Use this pattern when:

  • Multiple LLM access methods exist (CLI subscription, API key)
  • Model strings should be the user-facing interface
  • Unknown models should gracefully fall through to a general-purpose handler
  • Pre-flight checks should catch configuration errors early

Theoretical Basis

# Abstract dispatch (NOT real implementation)
def resolve_backend(model_string):
    scheme = model_string.split("/")[0].lower()
    return REGISTRY.get(scheme, DEFAULT_BACKEND)

# Examples:
# "claude-code/sonnet"    -> ClaudeCodeBackend (registered scheme)
# "openai/gpt-4o"         -> LiteLLMBackend (default, unregistered scheme)
# "gpt-4o"                -> LiteLLMBackend (no slash, unregistered)

Related Pages

Implemented By

Uses Heuristic

Page Connections

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