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 Provider Interface

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

Overview

A protocol interface that abstracts LLM completion behind a single method, allowing pipeline stages to call LLMs without knowing the backend, and allowing backends to be swapped without changing stage code.

Description

The LLMProtocol defines the interface that pipeline stages use to call LLMs. A stage accesses the LLM via ctx.llm (a Protocol-typed attribute on ProcessorContext) and calls ctx.llm.complete(messages, ...). The stage does not know whether the backend is a CLI agent, an API-key service, or a mock.

This decoupling means:

  • Stages are backend-agnostic: the GenericLLM stage works with any backend that implements the protocol.
  • Backends are swappable: changing from LiteLLM to Claude Code is a pipeline YAML change (model string), not a code change.
  • Testing is simplified: a mock implementing complete() can replace a real LLM in tests.

The protocol defines a single method with adaptive retry parameters:

class LLMProtocol(Protocol):
    def complete(
        self,
        messages: list[dict[str, str]],
        max_retries: int = ...,
        initial_backoff: float = ...,
        max_backoff: float = ...,
        backoff_decay: float = ...,
        **kwargs: Any,
    ) -> str: ...

Usage

Use this interface when:

  • Pipeline stages need LLM access without coupling to a specific provider
  • Backends should be swappable via configuration, not code changes
  • Testing requires mock LLMs that implement the same interface

Related Pages

Implemented By

Uses Heuristic

Page Connections

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