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
- BaseLLM ABB defines the inference contract
- OllamaLLM, WatsonxLLM, MockLLM are SBB implementations
- ProviderAdapterRegistry maps provider name to adapter class
- LLMFactory.bootstrap(config) initialises the correct provider
- LLMFactory.get(alias) returns a cached instance
- Agents call llm_invoke() — never touch LLMFactory directly