Beginner-friendly agent architecture

Agentic AI Cookbook For Beginners

A practical, playful, code-first guide to building agentic AI systems using Gemini, orchestration, memory, tools, retrieval, RAG, MCP servers, and multi-agent reasoning patterns.

Agents Memory RAG Tools MCP Orchestration
SETUP

Getting a Gemini API Key

1

Sign in to AI Studio

Go to Google AI Studio and log in with your Google account.

2

Open API Keys

Select API Keys from the left navigation panel.

3

Create an API Key

Click Get API Key and connect a Google Cloud project.

4

Store Securely

Save the key in environment variables or configuration files.

INDEX

Repository Index

Each script introduces one new mental model. Read them in sequence to understand how modern agentic systems evolve from simple prompts into orchestration architectures.

1Foundation

Creating Talking Agents

Basic talking agents and orchestration.

2Memory

Agents with Personality and Memory

Identity, memory, and fact extraction.

3Routing

Which Agent Should Speak?

Moderator controls conversation routing.

4Tools

Agents Using Tools

Tool-calling agents using external functions.

5JSON

Agents Who Return JSON

Structured outputs and machine-readable reasoning.

6Handoff

Reasoning Agents and Handoff

Agents reason and route control dynamically.

7Supervisor

Supervisor Pattern

Supervisor routes work to specialist agents.

8Parallel

Parallel Agents

Fan-out and fan-in reasoning systems.

9Debate

Debate Pattern

Competing agents and judge evaluation.

10Persistent Memory

Long-Term Memory

Persistent database-backed memory systems.

11Shared Memory

Agents with Shared Memory

Collaborative multi-agent memory architecture.

12Extraction

Knowledge Extraction

Transform text into structured entities.

13Embeddings

Chunking and Embedding

Prepare documents for semantic retrieval.

14Vector Search

Vector Search Before Generation

Retrieve vectors before answering.

15RAG

Basic RAG Agent

Retrieval-augmented generation basics.

16Agentic RAG

Agentic RAG

Agent decides when retrieval is needed.

17Multi-hop

Multi-hop Retrieval

Retrieval across multiple reasoning steps.

18MCP

MCP Protocol Walkthrough

Understanding the Model Context Protocol.

19MCP Client

Connecting to an MCP Server

Client-side MCP communication.

20MCP Server

Creating Your Own Tool Server

Build custom MCP-powered servers.

21Integration

Agent + MCP Full Integration

End-to-end architecture with MCP tools.

GUIDE

How to Read the Scripts

Find the Agent Class

Start with the class that wraps Gemini. That is the mind of the pattern.

Trace the State

Look for memory, facts, retrieved context, JSON outputs, and tool results.

Read the Orchestrator

The orchestrator tells you how control moves between agents.

Inspect Prompts

System prompts define roles, routing, constraints, and structured behavior.

Run and Modify

Change one variable at a time: role, memory, tool, retrieval, or routing.

MENTAL MODELS

Pattern Views

Core loop

Agent = prompt + memory + model call

The earliest scripts teach the basic loop: receive input, build context, call Gemini, store response.

Control

Orchestration decides movement

Alternation, moderation, supervisor routing, and handoff are all control-flow patterns.

Grounding

Retrieval gives the agent evidence

Chunking, embedding, vector search, RAG, and multi-hop retrieval prevent blind guessing.

Capability

MCP turns tools into an ecosystem

The MCP patterns separate reasoning from capability, letting agents call external tool servers.

Final Thoughts

This cookbook moves from simple conversations to serious agent architecture: memory, tools, supervision, retrieval, MCP, and full integration.

Read the scripts in order. Each one adds a new capability to the previous mental model. By the end, you are no longer just prompting a model — you are designing an intelligent system.