AI Agents from First Principles: A Practical Python Guide to Tools, Memory, and RAG
Paperback
Publisher: Independently Published
Published: Oct 19 2026
Pages: 272
Weight: 0.81
Height: 0.57 Width: 6.00 Depth: 9.00
Language: English
Build an AI agent in plain Python. No frameworks, no magic, no API key required to start.
Everyone talks about AI agents. Few people can explain what happens inside one: how it decides, when it should ask a human for permission, what it should remember, and how it answers from documents without making things up.
This book answers those questions by building one. You'll follow Rosa, who runs a small neighborhood bakery and wants an AI assistant to take cake orders. Chapter by chapter, her assistant learns to use tools, wait for approval before acting, avoid recording the same order twice, remember customers without leaking their data, and look things up in documents while citing its sources.
What makes this book different
- No frameworks. No LangChain, LangGraph, or CrewAI. You build each piece in plain Python and see exactly what frameworks hide, so learning and debugging any of them becomes much easier.
- Starts from everyday life. Part I has almost no code. Concepts come with examples everyone understands, before the technical vocabulary.
- Tested, open-source code. Five hands-on projects on GitHub, MIT-licensed, with automated tests. The local examples run without an API key, even in Google Colab.
- Honest about limits. Every hands-on chapter ends with What's missing for production, and one chapter covers when not to use an agent at all.
What you'll learn
- What an agent is, and isn't: environments, goals, the five classic agent types, and how much autonomy to give one
- The agent loop: tool calling, ReAct, planning, self-review, budgets, and how loops fail
- Safe tools: structured calls, validation, permissions, human approval, and idempotent actions that never charge a customer twice
- Context and memory: what the model needs now, what to save for later, what to forget, and how memory can become an attack surface
- RAG: keyword and semantic search, access filters, answers with citations, and an honest I couldn't find it
Who this book is for
Developers who use agent frameworks and want to understand what's underneath; computer science students; and managers and tech leads who need to make decisions about AI agents. Basic Python helps in the later hands-on chapters, and an appendix walks you through setting up your environment.
About the author
Humberto Jorge de Moura Costa, PhD, is a professor and researcher at the Federal Institute of Rio Grande do Sul (IFRS), Brazil, and an IEEE Senior Member. He leads a software lab where he teaches AI to developers.
Also in
Programming
Interactive Theorem Proving and Program Development: Coq'art: The Calculus of Inductive Constructions
Bertot, Yves
Castéran, Pierre
Hardcover
The Legend of Zelda(tm) Tears of the Kingdom - The Complete Official Guide: Collector's Edition
Piggyback
Hardcover
The Legend of Zelda(tm) Tears of the Kingdom - The Complete Official Guide: Standard Edition
Piggyback
Paperback
Python Crash Course, 3rd Edition: A Hands-On, Project-Based Introduction to Programming
Matthes, Eric
Paperback
Crisis Engineering: Time-Tested Tools for Turning Chaos Into Clarity
Dickerson, Mikey
Nitze, Marina
Weaver, Matthew
Paperback
Accelerate: The Science of Lean Software and DevOps: Building and Scaling High Performing Technology Organizations
Forsgren Phd, Nicole
Humble, Jez
Kim, Gene
Paperback
Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C: Fourth Edition
Zhu, Yifeng
Paperback
Fundamentals of Software Architecture: A Modern Engineering Approach
Ford, Neal
Richards, Mark
Paperback
Make: Electronics: Learning by Discovery: A Hands-On Primer for the New Electronics Enthusiast
Platt, Charles
Paperback
Site Reliability Engineering: How Google Runs Production Systems
Leng, Christof
Beyer, Betsy
Jones, Chris
Paperback
The Manager's Path: A Guide for Tech Leaders Navigating Growth and Change
Fournier, Camille
Paperback
Vibe Coding: Building Production-Grade Software with Genai, Chat, Agents, and Beyond
Yegge, Steve
Kim, Gene
Paperback
AI Projects with Raspberry Pi: High-Performance Artificial Intelligence for Robotics, Security, Home Automation, and Vision
Jepson, Brian
Hattersley, Lucy
Paperback
I Have an App Idea: The Essential Guide to Building an App Without Tech Skills
Spann, Amanda
Paperback
The Devops Handbook, 2nd Edition: How to Create World-Class Agility, Reliability, & Security in Technology Organizations
Debois, Patrick
Kim, Gene
Humble, Jez
Paperback
The Return on AI: From Promise to Profit in the Age of Intelligent Business
Sawhney, Mohanbir
Mittal, Ashwin
Paperback
The Staff Engineer's Path: A Guide for Individual Contributors Navigating Growth and Change
Reilly, Tanya
Paperback
Evals for AI Engineers: Systematically Measuring and Improving AI Applications
Shankar, Shreya
Husain, Hamel
Paperback
The Developer's Guide to AI: A Field Guide for the Working Developer
Orshalick, Jacob
Reghunadh, Jerry M.
Thompson, Danny
Paperback
Forecasting: Principles and Practice, the Pythonic Way
Hyndman, Rob J.
Athanasopoulos, George
Paperback
Building Applications with AI Agents: Designing and Implementing Multiagent Systems
Albada, Michael
Paperback
Software Architecture: The Hard Parts: Modern Trade-Off Analyses for Distributed Architectures
Sadalage, Pramod
Ford, Neal
Richards, Mark
Paperback
Observability Engineering: Achieving Production Excellence
Majors, Charity
Fong-Jones, Liz
Miranda, George
Paperback
Cracking the Coding Interview: 189 Programming Questions and Solutions
McDowell, Gayle Laakmann
Paperback
Learning Web Design: A Beginner's Guide to Html, Css, Javascript, and Web Images
Robbins, Jennifer
Paperback
Linux Basics for Hackers, 2nd Edition: Getting Started with Networking, Scripting, and Security in Kali
Occupytheweb
Paperback
The New AI Cold War: Liberty vs. Tyranny in the Age of Machine Empires
Maginnis, Ltc Robert L.
Paperback
Building Safer Technology: A Field Guide to Failing Well
Coles, Neil
Kissner, Lea
Zunger, Yonatan
Paperback
The Pragmatic Programmer: Your Journey to Mastery, 20th Anniversary Edition
Hunt, Andrew
Thomas, David
Hardcover
SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL
Shields, Walter
Hardcover
Building Resilient Distributed Systems: Patterns and Practices for Stable Software
Newman, Sam
Paperback
A Human's Guide to Machine Intelligence: How Algorithms Are Shaping Our Lives and How We Can Stay in Control
Hosanagar, Kartik
Paperback
Grokking Algorithms, Second Edition: An Illustrated Guide for Programmers and Other Curious People
Bhargava, Aditya Y.
Paperback
Java in a Nutshell: A Desktop Quick Reference
Flanagan, David
Evans, Benjamin J.
Clark, Jason R.
Paperback
Learning Domain-Driven Design: Aligning Software Architecture and Business Strategy
Khononov, Vlad
Paperback
Concrete Mathematics: A Foundation for Computer Science
Knuth, Donald
Graham, Ronald
Patashnik, Oren
Hardcover
Generative AI Design Patterns: Solutions to Common Challenges When Building Genai Agents and Applications
Hapke, Hannes
Lakshmanan, Valliappa
Paperback
The Official Raspberry Pi Handbook 2026: Astounding Projects with Raspberry Pi Computers
Makers of Raspberry Pi Official Magazine, The
Paperback
Signals & Levers: Systems Thinking Tools to Unblock Software Delivery
Hendrickson, Elisabeth
Tosi, Joel
Paperback
The Software Architect Elevator: Redefining the Architect's Role in the Digital Enterprise
Hohpe, Gregor
Paperback
Head First Design Patterns: Building Extensible and Maintainable Object-Oriented Software
Freeman, Eric
Robson, Elisabeth
Paperback
Learning Generative AI Tools for Excel: Speed Up Your Everyday Tasks with Microsoft Excel, Copilot, Chatgpt, and Beyond
Duca, Angelica Lo
Paperback
AI Agents with MCP: Model Context Protocol for Building Clients, Servers, and End-To-End Agents
Stratis, Kyle
Paperback
Build an AI Agent (from Scratch): Agents That Reason, Plan, and ACT Autonomously
Hur, Jungjun
Song, Younghee
Paperback
Building AI-Powered Products: The Essential Guide to AI and Genai Product Management
Nika, Marily
Paperback
Inteligencia Artificial Con Python: Sistemas de aprendizaje, Machine Learning y Deep Learning explicados de forma clara y práctica.
Selles Rodenas, Juan Ignacio
Paperback
The Multiplier Mindset: How to Move from Senior Engineer to Tech Leader in the Age of AI
Ojstersek, Gregor
Paperback
Arduino Programming for Beginners: A Comprehensive Beginner's Guide to Learn the Realms of Arduino Programming from A-Z
Protosmith, Ada
Paperback
Living a Jewish Life, Revised and Updated: Jewish Traditions, Customs, and Values for Today's Families
Diamant, Anita
Cooper, Howard
Paperback
Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems
Agans, David J.
Paperback
Software Engineering at Google: Lessons Learned from Programming Over Time
Manshreck, Tom
Wright, Hyrum
Winters, Titus
Paperback
The Book of Debugging: A Systematic Workflow for Finding and Fixing Bugs
Kuhlmann, Johannes
Paperback
Learning Php, MySQL & JavaScript: A Step-By-Step Guide to Creating Dynamic Websites
Nixon, Robin
Paperback
Frictionless: 7 Steps to Remove Barriers, Unlock Value, and Outpace Your Competition in the AI Era
Forsgren, Nicole
Noda, Abi
Paperback
Programming Massively Parallel Processors: A Hands-On Approach
El Hajj, Izzat
Hwu, Wen-Mei W.
Kirk, David B.
Paperback
Certified Associate in Project Management (Capm)(R) Exam Official Cert Guide
Lechler, Thomas
Kanabar, Vijay
Thomas, Arthur
Paperback
Python Programming for Young Coders: A Hands-On, Project-Based Introduction to Coding for Beginners, Kids, and Teens
Pandey, Anand
Paperback
Creación de Aplicaciones Con Agentes de Ia (Spanish Edition): Diseño E Implementación de Sistemas Multiagente
Albada, Michael
Paperback
Programming Rust: Fast, Safe Systems Development
Blandy, Jim
Orendorff, Jason
Tindall, Leonora F. S.
Paperback
Electronic Music and Sound Design - Theory and Practice with Max 9 - Volume 1 (Fifth Edition)
Maurizio, Giri
Cipriani, Alessandro
Paperback
Computer Science from Scratch: Building Interpreters, Art, Emulators and ML in Python
Kopec, David
Paperback
Head First Algorithms and Data Structures: A Learner's Guide to the Foundations of Computing
Freeman, Eric
Robson, Elisabeth
Paperback
