ANCI AI

AGENT ARCHITECTURE PATTERNS

10 patterns · ANCI AI
HANDS-ON WORKSHOP SERIES

AI Agent Architecture Patterns

Ten agent architectures explained — with hands-on workshops to build them yourself. Pick a workshop below, or explore the pattern reference underneath.

Type 1 · Agentic

Basic Agent + Tools

A single AI agent wired to external tools — calendar, email, contacts, memory. The agent plans multi-step tasks autonomously using these tools. The simplest useful agent architecture.

▶  Build it — Gemini Executive Assistant · 10 min
Data Flow
AI Agent
plan · execute · reflect
Memory
Contacts
G Calendar
Gmail
Component Breakdown
ComponentRoleNotes
TriggerEntry point for user input or eventChat, webhook, cron, or UI event
AI AgentReasons, selects tools, chains callsRuns a plan-execute-observe loop internally
MemoryInjects past context into promptsVector or key-value; scoped per user
Tool SetStructured APIs the agent can callEach tool = function signature + description
Tradeoffs
Strengths
  • Dead simple to build and debug
  • Works well for single-domain tasks
  • Predictable token budget
  • Easy to add tools incrementally
Limitations
  • Bottleneck — one agent, no parallelism
  • Context window fills fast with many tools
  • No fallback if agent loops or fails
  • Doesn't scale to complex workflows
When to Use

Best For

  • Personal assistants (email, calendar)
  • Single-domain Q&A with lookups
  • Prototypes and MVPs
  • Tasks needing 2–5 tool calls max

Complexity

Implementation effort:

Operational complexity:

Type 2 · Agentic

Agent + MCP Servers

Instead of hard-coded tool functions, the agent connects to MCP (Model Context Protocol) servers — standardized sidecars that expose tools from any service. The agent discovers and calls tools dynamically at runtime.

▶  Build it — AI PM Agent · 15 min
Data Flow
AI Agent
tool discovery
Response to
Webhook
mcp action
OpenAI · model
Memory · context
Atlassian · project mgmt
Atlassian · knowledge base
+ any MCP server
What MCP Changes
Without MCPWith MCP
Tools hard-coded as functions in promptTools discovered dynamically from servers
Each tool needs custom integration codeServers implement standard protocol
Tool list is fixed at build timeTool list extends at runtime
Limited to your API integrationsAccess any MCP-compatible service
MCP Architecture

MCP Server = Sidecar Process

  • Runs alongside your app
  • Exposes tools via standard protocol
  • Handles auth to external services
  • Stateless or stateful (your choice)

Agent ↔ Server Contract

  • Agent calls tools/list to discover
  • Agent calls tools/call to execute
  • Server returns structured results
  • Agent decides next action
Strengths
  • Extensible — add servers without code changes
  • Ecosystem of pre-built integrations
  • Separation of agent logic and tool impl
  • Servers can be swapped independently
Limitations
  • Runtime dependency on external processes
  • More infrastructure to manage
  • Latency overhead per tool call
  • Debugging spans multiple processes
Type 5 · Agentic

Agent + Router

The agent acts as an AI traffic controller — it classifies the incoming request and dispatches it to the appropriate downstream workflow or webhook. Decision logic lives in the model, not in code.

Data Flow
AI Agent
classify intent
IF
Response to Webhook 1
matched route
Response to Webhook 2
fallback route
Routing Strategies
StrategyHow It WorksBest For
Intent ClassificationModel classifies input into predefined categoriesSupport routing, FAQ triage
Entity ExtractionPull key entities; route based on entity type/valueMulti-tenant apps, data pipelines
Confidence ThresholdHigh confidence → auto-route; low → human reviewAutomation with safety net
Semantic SimilarityEmbed input; nearest neighbor to route definitionsOpen-ended input spaces
Strengths
  • Routes complex natural language inputs
  • Single decision point — easy to monitor
  • Routes are swappable without model change
  • Works well with n8n / Make / Zapier backends
Limitations
  • Routing errors cascade — misclassify = wrong path
  • Hard to test all edge cases
  • Model must know all route options upfront
  • No graceful degradation without fallback
Type 6 · Agentic

Human in the Loop + Tools

The agent plans and prepares actions, but pauses at defined checkpoints for human approval before executing. Critical for high-stakes operations where errors have real cost.

▶  Build it — AI Scheduling Executive Assistant · 20 min
Data Flow
AI Agent
plan actions
Slack Approve
human checkpoint
Response to Webhook 1
approved path
Response to Webhook 2
rejected / revised
Checkpoint Design Patterns
PatternTrigger ConditionHuman Action
Always-AskEvery executionApprove / reject / edit
Threshold-BasedAction exceeds risk/cost thresholdApprove high-stakes only
SamplingRandom % of executionsAudit trail, quality checks
Uncertainty-TriggeredModel confidence below thresholdClarify ambiguous inputs
First-TimeNovel entity / action typeEstablish precedent
Strengths
  • Prevents costly irreversible mistakes
  • Builds operator trust in automation
  • Creates audit log of human decisions
  • Graceful degradation when AI is uncertain
Limitations
  • Approval latency breaks async flows
  • Human bottleneck reduces throughput
  • Approval fatigue leads to rubber-stamping
  • Needs reliable async notification system
Type 3 · Multi-Agent

Sequential Agents

Multiple specialized agents wired in series — each agent handles one concern, passes its output to the next. Like an assembly line: each stage transforms the data before handing off.

▶  Build it — Sequential AI Agent Pipeline · 10 min
Data Flow
Loop Over
items
Plan & Review
agent 1
Do the Work
agent 2
MCP Notion
write output
Stage Design
StageResponsibilityInputOutput
Loop / IteratorFan out over list of itemsArray of itemsSingle item per iteration
Planner AgentAnalyze, decompose, create planRaw item + contextStructured plan / review
Executor AgentCarry out the planPlan from prior stageAction result / artifact
Writer / SinkPersist result to target systemFinal artifactConfirmation / ID
Strengths
  • Each stage is focused and testable
  • Earlier stages can gate / validate before cost
  • Easy to insert/remove stages
  • Clear data contracts between agents
Limitations
  • Latency = sum of all stage latencies
  • Errors in early stages corrupt all downstream
  • Context from stage 1 may be lost by stage 3
  • No parallelism within a chain
Type 4 · Multi-Agent

Parallel Agent Execution

A coordinator agent fans out subtasks to multiple specialized agents running concurrently. Results are merged by an aggregator. Dramatically reduces wall-clock time on decomposable tasks.

▶  Build it — Parallel AI Agent Pipeline · 20 min
Data Flow
Coordinator
fan-out
Jira
Slack
Email
Trello ×3
Merge &
Aggregate
Response
Data Bridge Example
Read Cities
Read US Cities
Read Job Names
Cross Join
Loop Over
Concurrency Considerations
ConcernIssueMitigation
Rate LimitsParallel calls exhaust API quotasSemaphore / token bucket
Partial FailuresOne branch fails, others succeedFan-out with fallback per branch
Result OrderingBranches return out of orderTag results with branch ID before merge
Context IsolationBranches share stale contextPass immutable snapshot per branch
Strengths
  • Wall-clock time ≈ slowest branch (not sum)
  • Independent branches are fault-isolated
  • Scales naturally to more parallel tasks
  • Great for I/O-bound workloads
Limitations
  • Aggregation logic can be complex
  • Cost = sum of all branch costs
  • Not suitable for tasks with dependencies
  • Debugging requires distributed tracing
Type 7 · Multi-Agent

Dynamic Agent — Sub-Agent Orchestrator

A main orchestrating agent dynamically decides it needs help and spawns specialized sub-agents. Unlike parallel execution, the orchestrator is adaptive — sub-agent selection is a runtime decision, not a static fan-out.

▶  Build it — Sub-Agent Orchestrator · 20 min
Data Flow
Main Agent
orchestrate
Sub-Agent A
specialist
Sub-Agent B
specialist
Sub-Agent C
specialist
Final Output
merged result
Orchestrator vs Parallel Execution
Parallel ExecutionOrchestrator
Fan-out DecisionStatic — defined at build timeDynamic — decided at runtime
Sub-agent SelectionAll branches always runOnly needed sub-agents spawn
Inter-Agent CommsNone (isolated branches)Orchestrator can relay context between subs
ComplexityMediumHigh — orchestrator needs clear sub-agent specs
Cost EfficiencyPays for all branchesOnly pays for needed subs
Strengths
  • Handles highly variable task complexity
  • Sub-agents are independently versioned
  • Orchestrator can retry with different sub-agents
  • Cleanest model for deep specialization
Limitations
  • Orchestrator is a central point of failure
  • Spawning latency adds up at scale
  • Hard to predict total cost upfront
  • Requires careful sub-agent interface design
Pattern 08 · RAG

Naïve RAG

The user's query is passed directly as the retrieval query — no reformulation. Simple, fast, and effective for straightforward lookups when queries are already well-formed.

Data Flow
Pinecone
vector store
Embeddings
query embed
Aggregate
top-k chunks
OpenAI
generate
Response
RAG Pipeline Components
StageComponentKey Decision
Embed QueryEmbedding model (same as index)Must match index embedding model exactly
RetrieveVector store (Pinecone, Weaviate, pgvector)Top-k value; similarity threshold
AggregateRe-ranker or simple concatenationOrder matters — best chunks first
GenerateLLM with context windowSystem prompt quality determines answer quality
Strengths
  • Minimal latency — no query rewrite step
  • Predictable and debuggable
  • Works well for keyword-rich queries
  • Easy baseline to beat
Limitations
  • Fails on vague or ambiguous queries
  • Poor on multi-hop questions
  • Query embedding ≠ document embedding style
  • No query expansion or reformulation
Pattern 09 · RAG

Smarter RAG

An agent first decides whether retrieval is even needed. If yes, it formulates an optimized retrieval query separate from the user's raw input. Produces significantly better results on complex or ambiguous questions.

Data Flow
AI Agent
route decision
Answer without RAG
no retrieval needed
Respond ↑
Output Parser
extract RAG query
Pinecone
Embeddings
Aggregate
OpenAI
Respond ↓
The Two Key Improvements

1. Retrieval Gate

Agent first asks: "Do I need external knowledge?" If the model's parametric knowledge suffices, it answers directly — saving a full retrieval round-trip and avoiding context pollution.

2. Query Reformulation

Instead of embedding the user's raw question, the model generates a retrieval-optimized query — typically more specific, keyword-rich, and aligned with how documents are written.

Strengths
  • Higher answer quality on complex questions
  • Avoids retrieval when not needed (saves cost)
  • Handles ambiguous / conversational queries
  • Can do multi-hop query expansion
Limitations
  • One extra LLM call per request
  • Reformulation can hallucinate query terms
  • More complex to evaluate and debug
  • Gate calibration requires tuning
Pattern 10 · Data Pipeline

Vector Indexing Pipeline

An event-driven pipeline that automatically embeds and indexes documents whenever they're added or modified. The RAG patterns above depend on this pipeline to have fresh, queryable knowledge.

Data Flow
+
Loop Over
changed files
Google Drive
fetch file
Data Loader
parse content
Text Splitter
chunk
Pinecone
upsert
Embeddings
generate
Chunking Strategy
StrategyHowBest For
Fixed SizeSplit every N tokens with overlapHomogeneous prose documents
Sentence / ParagraphSplit on sentence/paragraph boundariesNarrative text, articles
SemanticEmbed then split on similarity dropsMixed-topic documents
HierarchicalIndex full doc + child chunksLong docs with structure (papers, books)
By SectionUse headings / metadata as boundariesStructured docs (wikis, docs sites)
Index Maintenance

Triggers

  • Webhook on file create/update/delete
  • Scheduled full re-index
  • Manual trigger for bulk imports

Metadata to Store Per Chunk

  • Source doc ID + URL
  • Chunk index within doc
  • Created / modified timestamps
  • Access control tags (for RBAC)