Architecture Patterns
K9-AIF Pattern Catalog
Reusable architectural patterns for building governed, enterprise-scale agentic AI systems. Framework-agnostic. Production-tested in K9-AIF.
Execution
Agent Squad Pattern
Organize multiple agents into a coordinated execution unit with shared context, sequential flow, and governance enforcement.
Used in
Execution
Validation Loop Pattern
Enable iterative hypothesis testing — validate, observe, and retry until confidence is sufficient or iteration cap is reached.
Used in
Execution
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
Execution
Sub-Agent Pattern
A parent agent (K9AgentSpawner) spawns lightweight ChildAgents that execute concurrently and independently, then merges their results — applying the multithreading model to enterprise agentic AI.
Used in
Routing
Event Router Pattern
Single entry point for all events — deterministic routing when intent is known, decoupled IntentOrchestrator when it is not, guaranteed response in all cases.
Used in
Inference
Model Router Pattern
Dynamically select the most appropriate model based on task type, cost, latency, and policy — fully decoupled from agent code.
Used in
Inference
Inference Layer Pattern
Provider-independent inference layer — ABB contracts separate from SBB implementations. Swap Ollama, Watsonx, or OpenAI via config.
Used in
Inference · Integration
Provider Adapter Pattern
Support multiple pluggable backends without coupling factories or agents to any vendor — LLMs, secret managers, caches.
Used in
Inference
LLM Invoke Pattern
Single utility function — llm_invoke() — encapsulates all inference calls with retry, governance, and audit in one place.
Used in
Governance · Execution
Factory Pattern
Centralise component instantiation through static factories. Never instantiate agents, routers, or LLMs directly in application code.
Used in
Governance · Execution
Runtime Agent Loader Pattern
Load and wire agents, squads, and orchestrators from declarative YAML at runtime — change orchestration without changing code.
Used in
Integration
External Connector Pattern
Access external systems through a standardised connector layer with governance enforced at the boundary — APIs, databases, MCP servers.
Used in
Theoretical Lineage
Enterprise Integration Patterns Mapping
These patterns are not new. They are established Enterprise Integration Patterns (Hohpe & Woolf, 2003) applied to agentic AI — with formal ABB contracts, structural governance, and lifecycle guarantees added. K9-AIF did not invent the concepts. It brought the discipline.
| EIP Pattern | K9-AIF Equivalent | What K9-AIF adds |
|---|---|---|
| Pipes and Filters | Agent Squad — sequential flow | Shared context enrichment, governance per step |
| Scatter-Gather | Sub-Agent Pattern — K9AgentSpawner | No-orphan guarantee, deadlock prevention, bounded concurrency |
| Aggregator | merge_results() in K9AgentSpawner | SBB-controlled result policy, partial failure handling |
| Splitter | K9AgentSpawner splitting work to ChildAgents | Typed ChildAgent contract, lifecycle registry |
| Content-Based Router | K9EventRouter | Single entry point, intent fallback, governance boundary |
| Content Enricher | Context enrichment — each agent enriches shared context | Progressive enrichment contract across the Squad flow |
| Process Manager | Orchestrator | Squad coordination, governance enforcement, Zero Trust layer |
| Publish-Subscribe Channel | Kafka topics per domain | Router owns publish; Orchestrator owns consume — strict ownership |
| Transactional Client | K9TransactionAgent — 2-Phase Commit | Formal PREPARE/COMMIT/ROLLBACK over ChildAgents |
| Wire Tap | Governance pipeline intercept | Pre/post hooks on every agent, enforced in production |
| Canonical Data Model | K9-AIF shared context payload | Typed payload contract flowing Router → Squad → Agent |
| Correlation Identifier | session_id + transaction_id in payload | Session ABB with Redis-backed store, TTL, enable/disable flag |
| Message Store | K9Session — session_context persistence | Provider-agnostic store (Redis / SQLite / InMemory), auto-wired from config |
| Dead Letter Channel | Planned | — |
| Idempotent Receiver | Planned | — |
Reference: Hohpe, G. & Woolf, B. — Enterprise Integration Patterns (Addison-Wesley, 2003)