How-To Guide

Build an AI Agent from Agentic Architectural Patterns

A phased, requirements-driven approach: extract capabilities from Arsanjani & Bustos's "Agentic Architectural Patterns for Building Multi-Agent Systems," implement each pattern, and assemble a production-ready coding agent.

May 23, 2026 ~20 min read ~7 min listen 4 Phases ~8 weeks
🎤 Listen
← All How-To Guides

Contents click to toggle

  1. The Premise: Patterns As Requirements
  2. About the Book
  3. The Agentic Patterns We'll Implement
  4. Phase 1: Requirements Extraction
  5. Phase 2: Capability Implementation
  6. Phase 3: The Coding Agent Assembly
  7. Phase 4: Iteration & Refinement
  8. Prioritization Framework
  9. Recommended Tech Stack
  10. Common Pitfalls
  11. Timeline Summary

The Premise: Patterns As Requirements

Traditional tutorials show you how to build one specific agent — a chatbot, a coding assistant, a research tool. But they don't give you a framework for building any agent. They show you the pieces but not the why behind those pieces.

"Agentic Architectural Patterns for Building Multi-Agent Systems" by Dr. Ali Arsanjani and Juan Pablo Bustos (Packt, 2026) is different. It distills enterprise-grade agentic AI into a structured library of proven architectural patterns — each one a reusable solution to a specific challenge in building robust, scalable, multi-agent systems.

Our approach: Instead of following one tutorial, we treat the book's patterns as structured requirements. We use an AI agent (like Hermes) to extract, organize, and prioritize those requirements from the book. Then we systematically implement each capability and assemble a production-ready coding agent from the patterns.

Why This Approach?

🎯 End State

A coding agent built on enterprise-grade agentic architectural patterns, extracted systematically from a published book, with each pattern as a verified, pluggable module ready for production use.

About the Book

"Agentic Architectural Patterns for Building Multi-Agent Systems: Proven Design Patterns and Practices for GenAI, Agents, RAG, LLMOps, and Enterprise-Scale AI Systems" was written by Dr. Ali Arsanjani and Juan Pablo Bustos, published by Packt in January 2026 (574 pages).

The book is organized into two parts:

Part 1: Foundations and Core Agent Concepts

Part 2: Agentic AI Architecture and Design Patterns

The book introduces a concrete, hierarchical multi-agent architecture where high-level orchestrator agents manage complex workflows by delegating sub-processes to specialized agents. Each pattern is backed by real-world scenarios and code examples using the open-source Agent Development Kit (ADK).

Note on source access: You have a physical or digital copy of the book. Use your copy to extract the detailed specifications for each pattern — the exact implementation guidance, prompts, and code examples. The O'Reilly preview only shows table of contents and index; you'll need the full book content for the pattern details.

The Agentic Patterns We'll Implement

Here are the key design patterns extracted from the book (from the index and chapter descriptions), organized by the phase they'll be implemented in:

Phase 1 Patterns (Foundation)

🧠

LLM Selection & Deployment

Choosing the right model for agent tasks — FP16, FP32, INT8 quantization considerations for inference speed vs quality trade-offs

🔌

Function Calling

Pattern for agents to call external functions — the lowest layer of the agent stack

📚

RAG (Retrieval-Augmented Generation)

Contextual enhancement — grounding model output in external knowledge sources

Phase 2 Patterns (Core Capabilities)

🔀

Multi-Agent Coordination

Orchestrator-delegate hierarchy — one agent manages, others specialize

🔗

Agent Protocol (MCP)

Standardized tool protocols for agents to interact with external systems

💬

Agent-to-Agent (A2A) Communication

Structured agent collaboration — how agents communicate and pass work between each other

🔄

Adaptive Retry Pattern

Agents automatically retry failed operations, with prompt mutation variants for different error types

🤝

Agent Calls Human Pattern

Human-in-the-loop at designated intervention points — when to pause and request user input

Phase 3 Patterns (Safety & Reliability)

🔒

Agent Authentication & Authorization

Security patterns for multi-departmental analytics systems and access control for agents

📋

Explainability & Compliance

Auditability, traceability, and governance patterns for regulated environments

🛡️

Adversarial Testing & Red Teaming

Proactive testing — the agent tests itself against adversarial inputs and failure modes

🧩

In-Context Learning (ICL)

Agent adaptation through prompt-based learning without retraining — for handling new task types

📈

Agent Fine-Tuning for Capability Enhancement

Domain specialization through parameter-efficient fine-tuning for persistent capability upgrades

Phase 1: Requirements Extraction

Week 1–2

Before writing any agent code, we extract structured requirements from the book. This is where we train an AI agent (Hermes or Claude) to act as a product manager and systems analyst, reading your copy of the book and producing actionable specifications.

Step 1: Feed the Book to an Agent

Since you have the book, use one of these approaches to digitize it for the requirements extraction agent:

  1. Scanned PDF pages: Use Marker-PDF or similar OCR pipeline to convert to text, then chunk by chapter for LLM consumption
  2. Kindle/Digital copy: Export via Calibre, clean the text, chunk by chapter
  3. Print-to-text: If it's a physical copy, scan chapters individually and OCR each page

Step 2: Product Requirements Extraction

Run a dedicated agent prompt to extract product-level requirements:

# Role: You are a product manager and systems analyst.
# Source: "Agentic Architectural Patterns for Building Multi-Agent Systems"
# by Dr. Ali Arsanjani and Juan Pablo Bustos (Packt, 2026)

# Task: For each agentic pattern in the book, extract:
1. What problem it solves (the "context" element)
2. The problem statement (when is this pattern needed?)
3. The solution structure (how does it work?)
4. Implementation guidance (from the book's examples)
5. Success criteria (how do we know it works?)
6. User scenarios where this pattern is essential

# Output: Structured JSON with "user_stories", "system_requirements",
#      "capability_map" (pattern → capability), "prioritization" (MoSCoW)

Step 3: System Architecture Extraction

Next, extract the technical specifications. The book's three-layer agentic architecture is critical:

  1. Layer 1 — Function Calling: How agents execute functions. Get the exact schemas, parameter types, and return formats.
  2. Layer 2 — Tool Protocols (MCP): How agents interact with external APIs and data sources. Extract the MCP connection patterns.
  3. Layer 3 — Agent-to-Agent (A2A) Collaboration: How agents delegate, coordinate, and share state. Extract the multi-agent delegation patterns.

🎯 Milestone 1 (End of Phase 1)

A structured requirements document with: user stories mapped to patterns, the three-layer architecture diagram, prioritized capability list (MoSCoW), and an implementation roadmap that groups patterns into logical development phases.

Phase 2: Capability Implementation

Weeks 3–5

Now we build. The key is to implement patterns in the book's prescribed order — foundation first, then coordination, then safety. Each pattern becomes a Python module with a clear interface.

Week 3: Foundation Patterns (LLM + RAG)

  1. LLM Selection & Deployment: Build a model router that routes tasks to the right model based on complexity. Use the book's guidance on FP16 vs FP32 vs INT8 trade-offs. Test: the agent responds correctly with a fast, quantized model on simple tasks, and switches to a full-precision model for complex reasoning.
  2. RAG: Implement the contextual enhancement pattern. Index your knowledge base (docs, APIs, previous agent outputs) using a vector store. Test: the agent retrieves relevant context before generating responses.
  3. Function Calling: Build the lowest layer of the three-layer stack. Create typed function schemas with parameter validation. Test: the agent correctly calls functions and processes returned data.

Week 4: Core Agentic Patterns

  1. Multi-Agent Coordination (from Chapter 5): Implement the orchestrator-delegate hierarchy. Create an "orchestrator" agent that breaks tasks into subtasks and assigns them to specialized agents (planner, coder, reviewer). This is the heart of the book's architecture.
  2. Agent Protocol (MCP): Connect agents to external tools — Git operations, code execution, web search. Use the MCP patterns from the book's implementation examples.
  3. Adaptive Retry: Build retry logic that adapts based on error type — the book distinguishes between retries that simply repeat and retries that mutate the prompt. Implement both variants and test against real failure cases (e.g., malformed code output, API rate limits).
  4. Agent Calls Human: Implement the human-in-the-loop pattern at strategic decision points. The agent should pause and request approval from the user before making significant changes (like committing code or deploying).

Week 5: Safety & Reliability Patterns

  1. Agent Authentication & Authorization: Implement access control for agents. Different agent roles get different permissions (e.g., the reviewer agent can read but not write, the builder agent can write but needs approval before commit).
  2. Adversarial Testing & Red Teaming: Create a testing agent that intentionally tries to break your coding agent — inject malformed prompts, test edge cases, check for prompt injection vulnerabilities.
  3. In-Context Learning: Implement the agent's ability to learn from experience without retraining. Add a "lessons learned" mechanism where the agent stores successful patterns in its context and references them for similar future tasks.

🎯 Milestone 2 (End of Phase 2)

A library of 10+ agentic pattern modules, each tested and with a clean interface. The agent core has: LLM routing, RAG, function calling, orchestrator-delegate multi-agent coordination, MCP tool protocols, adaptive retry, human-in-the-loop, authentication, adversarial testing, and in-context learning. It's the engine — not yet a product, but a complete pattern-based architecture.

Phase 3: The Coding Agent Assembly

Weeks 6–7

Now we assemble the agent. We take the patterns built in Phase 2 and combine them into a functional coding agent — a concrete, working demonstration of the book's patterns in action.

Agent Architecture from the Book

# Coding Agent built on agentic architectural patterns
class CodingAgent:
     def __init__(self):
         # Pattern: Multi-Agent Coordination (Chapter 5)
         self.orchestrator = OrchestratorAgent("task_decomposer")
         self.specialists = {
             "planner": SpecialistAgent("code_planner"),
             "builder": SpecialistAgent("code_writer"),
             "reviewer": SpecialistAgent("code_reviewer"),
         }

         # Pattern: LLM Selection & Adaptation (Chapter 2-3)
         self.llm_router = ModelRouter({
             simple_tasks: "gpt-4o-mini",   # Fast, cheap
             complex_reasoning: "claude-sonnet-4",  # Strong reasoning
         })

         # Pattern: RAG (Chapter 3)
         self.knowledge = KnowledgeRetriever("codebase_index")

         # Pattern: Function Calling (Chapter 4)
         self.tools = FunctionCallingLayer([
             "read_file", "write_file", "shell_execute", "git_ops", "web_search"
         ])

         # Pattern: MCP Tool Protocols (Chapter 4)
         self.mcp_client = MCPClient(tools=self.tools)

         # Pattern: Agent Calls Human (Chapter 6/7)
         self.human_interface = HumanCallout(approval_required=["git_commit", "deploy"])

         # Pattern: Adaptive Retry (Chapter 7)
         self.retrier = AdaptiveRetry(
             max_attempts=3,
             mutation_strategy="prompt_reformulation",
         )

         # Pattern: In-Context Learning
         self.icl = InContextLearner(
             storage="memory_context",
             retrieval_mode="similar_tasks",
         )

         # Pattern: Auth & Authorization
         self.auth = AgentAuth(
             roles={
                 "orchestrator": {"read", "write", "deploy"},
                 "planner": {"read", "plan"},
                 "builder": {"read", "write"},
                 "reviewer": {"read", "approve", "reject"},
             }
         )

     async def execute(self, task: str) -> AgentResult:
         # Step 1: Route to best model
         model = self.llm_router.select(task)

         # Step 2: Planner orchestrates (multi-agent coordination)
         spec = await self.orchestrator.plan(task, model=model)

         # Step 3: Execute plan with pattern-based agents
         results = []
         for step in spec.steps:
             try:
                 # Step 4: RAG for context
                 context = self.knowledge.retrieve(step.description)

                 # Step 5: In-context learning — apply past lessons
                 prior_lessons = self.icl.recall_similar(step.description)

                 # Step 6: Execute tools with MCP
                 output = await self.mcp_client.execute(
                     step.action,
                     params={"context": context, "lessons": prior_lessons},
                 )

                 # Step 7: Adaptive retry on failure
                 if output.failed:
                     output = self.retrier.retry(step, output)

                 # Step 8: Human-in-the-loop for critical ops
                 if step.requires_approval:
                     output = await self.human_interface.request_approval(output)

                 results.append(output)
             except AgentError as e:
                 # Step 9: Adaptive retry with prompt mutation
                results.append(self.retrier.mutation_retry(step, e))

         return AgentResult(plan=spec, results=results, status="completed")

What You're Building

Implementation Order

  1. Week 6, Sunday: Set up the project structure. Build the orchestrator + function calling layer. Get a basic "read directory, suggest changes" working.
  2. Week 6, Tuesday: Add RAG. The agent queries the codebase for context before generating changes.
  3. Week 6, Thursday: Add multi-agent coordination. Split into planner, builder, and reviewer specialists.
  4. Week 6, Saturday: Add adaptive retry and human-in-the-loop. The agent handles failures gracefully and gets approval before committing.
  5. Week 7, Sunday: Add authentication, authorization, and adversarial testing. Your agent is now security-ready.
  6. Week 7, Tuesday: Add in-context learning. The agent remembers past successes and applies them to new tasks.
  7. Week 7, Saturday: Full integration test — give the agent 5 real coding tasks and verify the complete pipeline works end-to-end.

🎯 Milestone 3 (End of Phase 3)

A fully functional coding agent built on enterprise agentic patterns. It takes a feature request, reads the codebase using RAG, plans via an orchestrator agent, delegates to specialist agents, retries failures adaptively, and requires human approval before committing. Each capability is a verified module derived from the book's architectural patterns.

Phase 4: Iteration <br> Refinement

Weeks 8+

With the coding agent working on basic tasks, you'll inevitably hit limitations. This phase is about iterating based on real development experience, applying additional patterns from the book only where they solve actual problems.

Patterns to Add Based on Dev Feedback

  1. Agent Fine-Tuning for Capability Enhancement (from Chapters 2-3): As you discover the agent struggles with specific types of code (e.g., React components vs. Go backends), fine-tune the model on those domains for persistent capability upgrades.
  2. Advanced Multi-Agent Protocols (from Chapter 5): If the agent processes complex tasks slowly, add parallel delegation — where multiple specialist agents work simultaneously instead of sequentially.
  3. Compliance & Explainability (from Chapter 6): If the agent needs to run in environments where changes must be auditable (e.g., enterprise codebases), add detailed trace logging for every agent decision.
  4. Adversarial Hardening (expanded from Chapter 7): Build a comprehensive red-teaming suite that continuously tests the agent against new attack vectors — prompt injection, tool misuse, context poisoning.

Iterative approach: Don't implement all patterns upfront. Add them based on actual agent failures. The book's own guidance is pattern-first, not implementation-first — patterns solve real problems, not hypothetical ones. Track which patterns your agent actually needs through production use.

Iteration Loop

  1. Test the agent on diverse task types and codebases
  2. Identify failure patterns — where does the agent struggle?
  3. Match the failure to a pattern from the book
  4. Implement the corresponding capability
  5. Retest and verify the agent handles the task better
  6. Document lessons learned in the agent's knowledge base

🎯 Milestone 4 (End of Phase 4)

A production-ready coding agent built on a comprehensive set of agentic architectural patterns from the book. It handles diverse coding tasks, self-improves through in-context learning, and has robust safety mechanisms. The entire system is a demo of how enterprise-grade patterns from published research can be systematically converted into working software.

Prioritization Framework

Not every pattern is equally urgent. Use the Eisenhower matrix — which the book itself references in its governance and orchestration patterns — to decide what to implement first:

🔴 DO FIRST (Critical + Urgent)

Multi-Agent Coordination (orchestrator pattern), Function Calling, RAG, Agent Calls Human, Adaptive Retry

These are the agent's core capabilities. Without them, the agent doesn't function.

🟡 SCHEDULE (Critical + Not Urgent)

LLM Selection, Agent Protocol (MCP), In-Context Learning, Agent Authentication

Important for quality and scaling but not needed for V1.

🟠 DEPRIORITIZE (Not Critical + Urgent)

Agent Fine-Tuning, Advanced Multi-Agent Protocols

Useful but add only after the agent proves valuable in basic form.

⚪ ICEBOX (Not Critical + Not Urgent)

Adversarial Testing, Compliance & Explainability, Advanced Red Teaming

Production-hardening patterns — add when deploying to real users.

Recommended Tech Stack

The book uses the open-source Agent Development Kit (ADK) for its code examples. Here's the stack for our implementation:

Component Technology Why
Language Python 3.12+ Industry standard for agents; matches the book's ADK examples
Agent Framework LangGraph + ADK State-based graph with maximum control; book uses ADK
LLM APIs OpenAI + Anthropic Multiple providers for cost optimization and failover
Vector Store (RAG) PostgreSQL + pgvector Proven, queryable, fits your existing stack
MCP Tool Server FastMCP (LangChain) Standard tool protocol implementation for agent tools
API FastAPI Same stack as ThinkSmart; async support, auto-docs
Testing pytest + adversarial suite Unit tests for each pattern module; red teaming for robustness
Deployment Docker + VPS Simple, cost-effective; you already know this stack

Common Pitfalls to Avoid

❌ Implementing patterns without understanding them

Don't code a pattern based on its name alone. Read the full chapter, understand the design rationale from the book, then implement. Each pattern has nuances — the difference between a simple retry and an adaptive retry with prompt mutation matters a lot in practice.

❌ Over-engineering the requirements extraction

Start with a simple prompt that extracts the 7+ patterns as a feature list. You can always refine the requirements later. Don't spend weeks on requirements that take hours to produce.

❌ Skipping the coordination pattern

The book's core insight is that agents need orchestration, not just individual capabilities. Don't build a single-agent system — implement the multi-agent orchestration pattern early. It's the difference between an agent and a system of agents.

❌ Ignoring the three-layer architecture

The book prescribes: (1) function calling, (2) MCP tool protocols, (3) A2A collaboration. Your agent needs all three layers. Many coding agents stop at layer 1. Don't build a one-layer agent and pretend it's production-ready.

❌ Skipping the iteration loop

The biggest mistake is building all patterns in sequence without testing and iterating. Build a pattern, test it with real agent tasks, fix what breaks, then move on. Use the book's adversarial testing pattern to proactively find weaknesses.

Complete Timeline Summary

Phase Weeks Focus Deliverable
Phase 1 1–2 Requirements Extraction Structured requirements from the book's patterns
Phase 2 3–5 Capability Implementation 10+ tested pattern modules (orchestrator, RAG, retry, auth, etc.)
Phase 3 6–7 Build the Coding Agent Functional coding agent assembled from pattern modules
Phase 4 8+ Iterate & Harden Production-ready agent with fine-tuning and adversarial testing

The big picture: 8+ weeks, ~8 hours per week (~64 hours total) gets you from zero to a working coding agent built on enterprise-grade agentic architectural patterns. Each pattern is a standalone, tested module that could be reused in future agent projects. You're not just building a coding agent — you're building a pattern library for agentic systems, derived from published research.