Architecture Patterns
K9-AIF Pattern Catalog
Reusable architectural patterns for building governed, enterprise-scale agentic AI systems. Framework-agnostic. Production-tested in K9-AIF.
9 Patterns
Apache 2.0
GoF · POSA · TOGAF lineage
Agent Squad Pattern
Organize multiple agents into a coordinated execution unit with shared context, sequential flow, and governance enforcement.
Used in
BaseSquadSquadLoaderEOC domain squadsDoW DoDAF stages
Validation Loop Pattern
Enable iterative hypothesis testing — validate, observe, and retry until confidence is sufficient or iteration cap is reached.
Used in
BaseValidationLoopAgentK9ValidationLoopAgentFraudDetectionAgentDocumentExtractorAgent
Critic-Actor Pattern
An Actor produces a draft; a Critic evaluates it; the Actor refines — repeating until quality bar is met or escalation triggers.
Used in
BaseCriticActorAgentK9CriticActorAgentContract draftingReport writing
Model Router Pattern
Dynamically select the most appropriate model based on task type, cost, latency, and policy — fully decoupled from agent code.
Used in
BaseModelRouterK9ModelRouterModelRouterFactoryllm_invoke()
Inference Layer Pattern
Provider-independent inference layer — ABB contracts separate from SBB implementations. Swap Ollama, Watsonx, or OpenAI via config.
Used in
LLMFactoryOllamaLLMInferenceRequestProviderAdapterRegistry
Provider Adapter Pattern
Support multiple pluggable backends without coupling factories or agents to any vendor — LLMs, secret managers, caches.
Used in
SecretManagerFactoryCacheFactoryK9XLiteLLMBridgeAdapterEnvSecretAdapter
Factory Pattern
Centralise component instantiation through static factories. Never instantiate agents, routers, or LLMs directly in application code.
Used in
AgentRegistryRouterFactoryLLMFactoryModelRouterFactory
Runtime Agent Loader Pattern
Load and wire agents, squads, and orchestrators from declarative YAML at runtime — change orchestration without changing code.
Used in
SquadLoaderAgentLoader_load_squad()k9_generator.sh
External Connector Pattern
Access external systems through a standardised connector layer with governance enforced at the boundary — APIs, databases, MCP servers.
Used in
MCPHttpConnectorMCPStdioConnectorBaseMCPAgentDocling OCR