Building AI Agents with Ollama: A Practical Course
Who This Course Is For
What You Will Learn
How This Course Is Structured
Key Takeaways from This Introduction
Lesson 1: Foundations of Local LLMs and Ollama
Why Local AI Matters
What Is an AI Agent?
How Local Inference Works
Understanding GGUF and Quantization
Installing Ollama
Basic Installation
GPU Configuration
Docker Deployment
Understanding the Ollama API
Core Endpoints
Streaming Responses
OpenAI-Compatible Endpoint
Your First Agent: A Minimal Example
Project Setup
The Minimal Agent
How It Works
Running and Testing
Common Pitfalls
Exercise 1
Quiz 1
3 attempts allowed
Lesson 1 Key Takeaways
Lesson 2: Choosing and Managing Models
The Local Model Landscape
Model Families and Their Strengths
Benchmark Interpretation
Hardware Requirements by Model Size
Performance vs Size Tradeoffs
Speed Considerations
Capability vs Task Complexity
Quantization Deep Dive
How Quantization Works
Quantization Quality Comparison
When to Use Higher Quantization
Multi-Model Strategies
Task-Based Model Selection
Model Registry Implementation
Using the Model Registry
Exercise 2
Quiz 2
3 attempts allowed
Lesson 2 Key Takeaways
Lesson 3: Prompt Engineering for Agents
From Prompts to Specifications
The Specification Mindset
System Prompt Architecture
Structured Prompt Design Patterns
Role-Based Prompting
Constraint-Based Prompting
Step-by-Step Decomposition
Guardrails and Safety Instructions
The Layered System Prompt
Few-Shot and Example-Based Prompting
When to Use Few-Shot Prompting
Example Implementation
Testing and Iterating Prompts
The Prompt Test Suite
Iteration Best Practices
Exercise 3
Quiz 3
3 attempts allowed
Lesson 3 Key Takeaways
Lesson 4: Structured Outputs and Tool Calling
JSON Mode and Schema Enforcement
Providing Schema Hints
Pydantic Models for Type Safety
Function Calling with Ollama
Basic Tool Calling
How Tool Calling Works
Building a Tool Registry
Error Recovery for Bad Outputs
Retry with Correction Prompt
Tool Call Validation
Exercise 4
Quiz 4
3 attempts allowed
Lesson 4 Key Takeaways
Lesson 5: Memory Systems and Context Management
The Memory Problem
Short-Term Conversation Memory
Sliding Window Memory
Summarization-Based Memory
Long-Term Memory Architectures
Episodic Memory
Semantic Memory
Procedural Memory
Context Window Optimization
Token Budget Management
Selective Context Pruning
Implementing a Memory Manager
Exercise 5
Quiz 5
3 attempts allowed
Lesson 5 Key Takeaways
Lesson 6: Retrieval-Augmented Generation and Vector Search
Why RAG Is Essential for Agents
Embeddings and Vector Spaces
How Embeddings Work
Using Ollama for Embeddings
Embedding Models Available in Ollama
Vector Database Options
In-Memory Vector Store
ChromaDB for Production
Document Ingestion Pipelines
Text Chunking Strategies
Complete Ingestion Pipeline
Building a RAG Agent
Hybrid Search and Re-Ranking
Combining Vector and Keyword Search
Re-Ranking with Cross-Encoders
Exercise 6
Quiz 6
3 attempts allowed
Lesson 6 Key Takeaways
Lesson 7: Planning, Reasoning, and Complex Tasks
Beyond Single-Turn Responses
Chain of Thought and Reasoning
Zero-Shot Chain of Thought
Structured Reasoning with Explicit Steps
The ReAct Pattern
ReAct Implementation
How ReAct Works
Task Decomposition Strategies
Hierarchical Task Decomposition
Reflection and Self-Correction
Exercise 7
Quiz 7
3 attempts allowed
Lesson 7 Key Takeaways
Lesson 8: Multi-Agent Architectures
Why Multiple Agents?
Specialization and Roles
Researcher Agent
Writer Agent
Reviewer Agent
Communication Patterns
Sequential Pipeline
Fan-Out / Fan-In
Orchestration Strategies
Supervisor Pattern
Building an Agent Team
Exercise 8
Quiz 8
3 attempts allowed
Lesson 8 Key Takeaways
Lesson 9: Deployment, Security, and Production Practices
Packaging Agents as Services
Running with Docker
Securing Your Agent
Input Validation and Sanitization
Tool Execution Safety
Rate Limiting
Observability and Monitoring
Structured Logging
Performance Metrics
Testing Strategies
Unit Tests for Infrastructure
Integration Tests for Agent Behavior
Production Deployment Checklist
Exercise 9
Quiz 9
3 attempts allowed
Lesson 9 Key Takeaways
Lesson 10: Custom Models and Fine-Tuning
Custom Models with Modelfile
Modelfile Syntax
Key Modelfile Directives
Advanced Modelfile: Few-Shot Baking
Understanding Fine-Tuning
When to Fine-Tune vs Prompt Engineer
LoRA and QLoRA Basics
Creating a Fine-Tuning Dataset
Training with ollama
Evaluating Fine-Tuned Models
Domain-Specific Model Creation
The Custom Model Development Process
Example: Building a Legal Document Analyzer
Exercise 10
Quiz 10
3 attempts allowed
Lesson 10 Key Takeaways
Lesson 11: Workflows, State Machines, and Orchestration
Agents as Workflow Nodes
Defining Workflow Steps
State Machine Design
Implementing an Agent State Machine
Async Processing and Concurrency
Concurrent Agent Requests
Retries, Timeouts, and Circuit Breakers
Retry with Exponential Backoff
Circuit Breaker Pattern
Exercise 11
Quiz 11
3 attempts allowed
Lesson 11 Key Takeaways
Lesson 12: Advanced RAG Techniques
Query Rewriting and Expansion
Hypothetical Document Embeddings (HyDE)
Query Decomposition
Self-Correcting RAG
Hierarchical Retrieval
Graph-Based Knowledge Retrieval
Exercise 12
Quiz 12
3 attempts allowed
Lesson 12 Key Takeaways
Lesson 13: Building Web Interfaces and Desktop Integration
Web Chat Interface
Desktop Integration
System-Level Agent Tools
Real-Time Streaming Dashboard
Exercise 13
Quiz 13
3 attempts allowed
Lesson 13 Key Takeaways
Lesson 14: Performance Optimization and Scaling
Inference Performance Optimization
Key Performance Factors
Measuring Performance
Context Length Optimization
GPU Memory Management
Model Loading Strategies
Concurrent Request Handling
Request Queue Management
Caching Strategies
Response Caching
Scaling Ollama Deployments
Production Configuration Guide
Horizontal Scaling
Exercise 14
Quiz 14
3 attempts allowed
Lesson 14 Key Takeaways
Lesson 15: Capstone Project — Building a Production Coding Agent
Project Overview: CodePilot
Architecture
Step 1: Project Setup
Step 2: The CodePilot Agent
Step 3: Web Interface and API
Step 4: Running CodePilot
Step 5: Using CodePilot
Exercise 15
Quiz 15
3 attempts allowed
Lesson 15 Key Takeaways
Course Conclusion
Where to Go Next
Final Principles
Building AI Agents with Ollama: A Practical Course
Design, Build, and Deploy Production-Ready Local AI Agents with Ollama
Build powerful AI agents without relying on the cloud. In this hands-on course, you'll learn how to create intelligent, production-ready agents that run entirely on your own hardware using Ollama. Starting with the fundamentals and progressing to advanced topics like RAG, tool calling, long-term memory, and multi-agent systems, you'll develop real-world applications through practical, copy-and-run examples. Whether you're building personal assistants, automation tools, or sophisticated AI workflows, this course gives you the knowledge and code to build fast, private, and reliable AI agents with confidence.
Minimum price
$129
$179
You pay
Author earns
About
About the Course
This course teaches you how to design, build, and deploy production-grade AI agents that run entirely on your own hardware using Ollama as the inference engine. You will learn everything from installing Ollama and selecting models through advanced techniques like retrieval-augmented generation (RAG), tool calling, memory systems, multi-agent architectures, and secure deployment. Every section includes complete, working code examples you can copy, run, and extend. Whether you are building personal assistants, coding agents, document analysis tools, or autonomous workflow systems, this course provides the patterns and implementations needed to make them work reliably in the real world.
Instructor
About the Instructor
Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.
Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.
We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.
Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.
If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.
Material
Course Material
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.