← All Patterns
Inference Layer Pattern diagram
Inference Layer Pattern — structural diagram

Motivation

Agents that import LLM clients directly become provider-locked. Switching from Ollama to Watsonx requires modifying every agent. The inference layer pattern ensures the framework controls which provider is used, not the agent.

ABB contracts define what the inference layer must provide. SBB implementations deliver it for each provider. The factory resolves the right implementation from config at runtime.

Structure

Key Concepts

BaseLLM LLMFactory OllamaLLM InferenceRequest InferenceResponse ProviderAdapterRegistry MockLLM

Used in K9-AIF

LLMFactory OllamaLLM InferenceRequest InferenceResponse ProviderAdapterRegistry MockLLM (testing)