AI Friendly architecture enables traditional systems to handle AI's inherent uncertainty through three paradigm shifts: deterministic→probabilistic, structured→semantic, and static→dynamic. This skill guides agents to apply these principles correctly and avoid common anti-patterns.
Core principle: Use appropriate architecture for the problem—don't over-engineer with AI when traditional solutions suffice.
Use when:
Do NOT use when:
Traditional: Output follows y=f(x) mapping—binary success/failure.
AI Friendly: Output emerges from model + prompt + context + environment. Design goal: converge probabilistic output to an acceptable "safe interval" through RAG, prompt engineering, and evaluation mechanisms.
Design implication: Don't expect exact schema compliance from AI outputs. Build validation and fallback mechanisms.
Traditional: Input must match predefined Schema exactly (JSON field types). System boundary is a rigid wall.
AI Friendly: System understands natural language and unstructured data. Responds based on intent, not format. System boundary becomes an elastic membrane.
Design implication: Design interfaces that accept flexible inputs and translate intent to actions.
Traditional: Execution paths defined by hardcoded if-else logic or rules. Behavior is enumerable and verifiable.
AI Friendly: System makes decisions based on models, can reason about current state, decompose tasks, and respond to unknown changes without human intervention.
Design implication: Shift from "rules" to "planning"—grant systems autonomy for intelligent task orchestration.
text
┌─────────────────────────────────────────────────────────────┐
│ Quality & Stability Layer │
│ (AI Observability, Evaluation, Security) │
├─────────────────────────────────────────────────────────────┤
│ Application Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────────────────┐ │
│ │ Agent │ │ Intent │ │ Session │ │
│ │ Layer │ │ Layer │ │ Layer │ │
│ └──────────┘ └──────────┘ └──────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ Capability Layer │
│ (MCP, RAG, Function Calling) │
├─────────────────────────────────────────────────────────────┤
│ Foundation Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────────────────┐ │
│ │ Model │ │ Knowledge│ │ Tool Management │ │
│ │Management│ │Management│ │ │ │
│ └──────────┘ └──────────┘ └──────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Provider Selection:
FactorConsiderationLatency requirementsRegional providers vs global (OpenAI, Anthropic)CostPer-token pricing, batch discounts, small model for simple tasksData privacyOn-premise (Ollama, vLLM) vs cloud APICapabilityTask-specific: code (Codex), vision (GPT-4V), reasoning (Claude)
Failover Strategy:
Cost Optimization:
Reference: The ReAct pattern is from the paper ReAct: Synergizing Reasoning and Acting in Language Models (Yao et al., 2022).
Three Agent types for different scenarios (this is one common taxonomy—other frameworks may use different classifications):
Agent TypeCapabilityUse CaseBaseAgentFixed workflow, no dynamic planningSimple chatbots, AI WorkflowsReActAgentThought→Action→Observation loopRational tasks with tool usePlanAgentGlobal planning + ReAct executionComplex tasks requiring strategy
Note: "PlanAgent" is a common architectural pattern but not a standardized term—different frameworks may name it differently.
ReAct + Plan Combination:
Required only for multi-intent scenarios. Handles:
Also performs query rewriting and expansion for intent optimization.
Manages conversation state and user context. Feeds data into Context Engineering.
Responsibilities:
What it does NOT do:
Session Layer provides the data; Context Engineering decides how to use it.
Three coordination patterns:
PatternDecision PointUse CaseCentralizedSingle coordinator agentClear task decompositionDecentralizedPeer-to-peer negotiationCollaborative problem-solvingHybridMixed coordinationComplex domains with sub-domains
MOE (Mixture of Experts) Pattern:
Split interfaces into atomic tools matching Agent reasoning patterns:
text
❌ getProductWithInventoryAndPricing(id)
✅ getProduct(id)
✅ getInventory(productId)
✅ getPricing(productId)
Human-readable names, flat KV structure, core parameters only:
json
// ❌ Bad: Nested, complex
{"product": {"identifiers": {"sku_id": "123"}, "filters": {"status": "active"}}}
// ✅ Good: Flat, clear
{"sku_id": "123", "status": "active"}
Context Engineering selects, organizes, and compresses information optimally within context windows. It is more impactful than model selection for production systems.
*Based on production AI Review system results. See Real-World Impact section.
Store past successful cases with their decision reasoning. Retrieve similar cases via vector search to guide current decisions.
*Based on production CogentAI system results. See Real-World Impact section.
Multiple models vote with confidence scores. Use when single-model accuracy is insufficient.
TypeScopeImplementationUse CaseLong-term memoryCross-sessionPersistent store (DB/vector)User preferences, historyShort-term memoryCurrent sessionIn-context windowCurrent task contextWorking memoryCurrent stepScratchpad patternIntermediate reasoning
TechniqueWhen to UseTrade-offStandard RAGSimple Q&A over documentsLow complexity, moderate accuracyGraphRAGEntity relationships, knowledge graphsHigher complexity, better associative retrievalDynamic context pruningLong conversations, large knowledge basesReduces noise, may lose relevant contextHybrid retrieval (dense + sparse)Mixed structured/unstructured dataBest recall, more infrastructure
text
Is the task pattern-recurring?
├─ Yes → Build historical case library
└─ No → Is single-model accuracy sufficient?
├─ Yes → Standard RAG + memory management
└─ No → Hybrid decision-making
└─ Complex entity relationships?
├─ Yes → GraphRAG
└─ No → Standard RAG + dynamic pruning
#QuestionIf YesIf No1Is the task deterministic?Traditional architecture (MVC/DDD)→ Q22Does it need language understanding?→ Q3Rules or traditional ML3Are there hard performance constraints (<100ms)?Hybrid: AI offline + rules online, caching→ Q44Are there strict cost constraints?Hybrid: AI + rules, small models, caching→ Q55Does it need dynamic tool selection?→ Q6Single LLM call or AI Workflow6Does it need multi-step reasoning?PlanAgent + ReActAgentReActAgent7Multiple domains?Multi-Agent (MOE pattern)Single Agent
Q1: Is the task deterministic?
Q2: Does it need language understanding?
Q3: Are there hard performance constraints?
Q4: Are there strict cost constraints?
Q5: Does it need dynamic tool selection?
Q6: Does it need multi-step reasoning?
Q7: Multiple domains?
Constraint Strategy Table:
ConstraintStrategyExamplePriorityLatency <100msAI offline training + rules online, cachingReal-time recommendationHardHigh volume (10M+/day)Caching + small models + rules fallbackAPI gatewaySoftLimited budgetHybrid AI+rules, model tieringInternal toolsSoftData privacyOn-premise models, data anonymizationMedical/financialHardPerformance + CostSmall models + caching, reduce AI scope to high-ROI tasksBudget real-time systemHard > SoftPerformance + PrivacyOn-premise small models + caching, accept lower accuracyHospital systemHard > HardCost + PrivacyOn-premise small models, rules for low-value decisionsInternal medical toolSoft < Hard
Rule: Hard constraints (latency, privacy) beat soft constraints (cost, accuracy). When constraints conflict, optimize for the hard constraint first.
MistakeWhy WrongFixUsing Multi-Agent for simple FAQOver-engineering, adds latency/costUse single Agent with knowledge baseComplex nested API for Agent toolsAgents can't parse deep structuresAtomic tools with flat parametersSkipping Intent Layer for multi-intent queriesAgent can't distinguish user goalsAdd Intent Layer with query rewritingUsing ReAct for deterministic tasksUnnecessary reasoning overheadUse BaseAgent or workflowIgnoring Context EngineeringPoor model performanceBuild case libraries, hybrid decisionsIgnoring performance constraintsAI inference latency breaks SLAUse hybrid architecture, see Constraint Strategy TableIgnoring cost constraintsUnsustainable AI spend at scaleModel tiering, caching, rules fallback"To use AI" as architecture goalNo business valueDefine specific problems AI solves
ExcuseReality"Multi-Agent is always better"Coordination overhead isn't justified for simple tasks"ReAct can handle everything"Deterministic tasks don't need dynamic reasoning"AI Friendly API is too much work"Atomic tools are easier to maintain and test"Context Engineering is optional"Memory and context are more important than model choice"We need AI for everything"Traditional architecture handles deterministic logic better"Paradigm shifts are just theory"They explain WHY the patterns work—skip them at your peril"Context Engineering is just RAG"Includes memory, hybrid decisions, case libraries beyond RAG"Intent Layer is optional"Required for multi-intent scenarios—Agent alone can't distinguish"This only applies to LLM systems"Principles apply to any AI system with uncertainty
From production systems:
Note: These metrics are illustrative examples from the source article, not independently verified measurements. Results will vary based on implementation quality, data, and domain.