4-Layer AI Agent Architecture Starter Template (@codewander) Developer Mustafa Yusuf Aksoy (@codewander) published a four-layer AI agent architecture starter template that routes inbound messages through a fast rule-based classifier, an isolated per-user memory store capped at three conversation turns, a pattern-matching security guard against prompt injection, and finally an LLM synthesis layer. The template is written in TypeScript and aims to cut token bloat and block prompt-injection attempts before requests reach a heavy generative model such as Claude or GPT. | | / | | | 4-Layer AI Agent Architecture Starter Template | | | Developed by Mustafa Yusuf Aksoy @codewander | | | | | | 1. Layer 1: Decision / Router Layer System One - Jev / Fast Classifier | | | 2. Layer 2: Isolated Memory Layer Bounded context, prevents token bloat | | | 3. Layer 3: Security Sandbox Layer Execution permissions & prompt injection guard | | | 4. Layer 4: LLM Synthesis Layer Heavy generative model - Claude / GPT | | | / | | | | | | export type UserIntent = "sales" \| "tech support" \| "spam" \| "architecture request" \| "general qa"; | | | | | | export interface InboundMessage { | | | userId: string; | | | text: string; | | | timestamp: number; | | | } | | | | | | // ============================================================================ | | | // 1. KATMAN: KARAR VE SINIFLANDIRMA KATMANI Decision Layer | | | // Büyük modele gitmeden önce ~50ms içinde niyeti çözer ve spam'i eler. | | | // ============================================================================ | | | export async function layer1 DecisionRouter message: InboundMessage : Promise