Build Your Own Coding Agent

Build Your Own Coding Agent

J. Owen
This is a sample of the book's content.Buy on Leanpub

Table of Contents

Build Your Own Coding Agent

  • Preface
    • Who This Book Is For
    • What You Will Build
    • Testing Approach
    • Code Examples
    • Conventions Used in This Book
  • Part I: The Brain
  • Chapter 1: The Zero Magic Manifesto
    • What is an Agent, Really?
    • What We Are Building
    • Project Setup
    • The AgentStop Exception
    • The Agent Class
    • Defining Success with Tests
    • The Main Loop
    • Run It
    • Wrapping Up
  • Chapter 2: The Raw Request
    • Get an API Key
    • The Vault (.env)
    • The Anatomy of a Request
    • The Code
    • Run It
    • Troubleshooting
    • Cleaning Up
    • Wrapping Up
  • Chapter 3: The Infinite Loop
    • The Illusion of Memory
    • The Testing Problem
    • Response Types
    • The FakeBrain Pattern
    • Defining Success
    • The Claude Class
    • The Agent Class (Updated)
    • The Main Loop (Updated)
    • Verify the Tests Pass
    • Test the Memory
    • The Context Window Problem
    • Wrapping Up
  • Chapter 4: The Universal Adapter
    • The Adapter Pattern
    • HTTP Resilience
    • The Brain Interface
    • The FakeBrain (Updated)
    • The Claude Brain (Refactored)
    • The DeepSeek Brain
    • The BRAINS Registry
    • The Agent Class (Updated)
    • Tests for Multi-Brain Support
    • The Main Loop (Updated)
    • Setting Up DeepSeek
    • Try It
    • “We Just Moved Code Around”
    • Wrapping Up
  • Part II: The Hands
  • Chapter 5: The Tool Protocol
    • How Tools Actually Work
    • Defining the Tool Interface
    • The ReadFile Tool
    • The WriteFile Tool
    • Tool Helpers
    • Updating the Thought Class
    • Updating the Claude Class
    • The Agent Class with Tools
    • The Main Loop
    • Test It
    • Wrapping Up
  • Chapter 6: The Scratchpad (Memory)
    • The “Zero Magic” Memory
    • The Memory Class
    • The ToolContext Class
    • The SaveMemory Tool
    • Updating the Claude Class
    • Crafting the System Prompt
    • Updating the Agent Class
    • The Main Loop (Updated)
    • Testing Persistence
    • Wrapping Up
  • Chapter 7: The Safety Harness (Plan Mode)
    • The Concept
    • Tests First
    • The WritePlan Tool
    • One List, Two Views
    • Telling the Brain What Mode It’s In
    • The Agent Class (Updated)
    • The Main Loop (Updated)
    • Testing the Harness
    • The Psychology of the “Plan”
    • Wrapping Up
  • Chapter 8: The Context Pipeline (Map & Search)
    • The ListFiles Tool
    • The SearchCodebase Tool
    • Update the Tools List
    • The “Zoom In” Test
    • Wait, is this RAG?
    • Wrapping Up
  • Chapter 9: The Reality Check (Running Code)
    • The Feedback Loop
    • Tests First
    • The RunCommand Tool
    • The Interactive Trap
    • The Self-Healing Demo
    • The TDD Workflow
    • The Surgical Edit
    • The Closed Loop
    • Hardening the Loop
    • Context Compaction
    • Security Considerations
    • Wrapping Up
  • Part III: The Frontier
  • Chapter 10: Going Dark (Local Models)
    • The Trade-off
    • Installing Ollama
    • The Ollama Brain Class
    • Running with Ollama
    • The “Infinite Loop” Experiment
    • The Practical Differences
    • The Hybrid Workflow
    • Model Selection
    • Troubleshooting Ollama
    • Wrapping Up
  • Chapter 11: The Extension (Web Search)
    • Step 1: The Meta-Prompt
    • Step 2: The Surgery
    • Step 3: The Reference Implementation
    • Step 4: The Tests
    • Self-Modification
    • Wrapping Up
  • Chapter 12: The Capstone (Building a Game)
    • Step 1: Preparation
    • Step 2: The Architect (Plan Mode)
    • Step 3: The Builder (Act Mode)
    • Step 4: The Reality Check
    • Step 5: The Pivot (Feature Creep)
    • Check the Result
    • What Goes Wrong
    • Wrapping Up
    • Epilogue
  • Appendix A: Streaming Responses
    • How Streaming Works
    • The Implementation
    • What Changed from Chapter 11
    • The Trade-Off
    • Running the Code
  • Acknowledgments
Build Your Own Coding Agent/Overview

Build Your Own Coding Agent

Course overview

Build an AI coding agent from scratch in pure Python. Learn tools, memory, testing, and cloud or local models, with source code and a Snake game capstone.

18 chapters
Begin reading
Download
The Book

Build Your Own Coding Agent18 chapters

Begin ›
  1. Preface

  2. Part I: The Brain

  3. Chapter 1: The Zero Magic Manifesto

  4. Chapter 2: The Raw Request

  5. Chapter 3: The Infinite Loop

  6. Chapter 4: The Universal Adapter

  7. Part II: The Hands

  8. Chapter 5: The Tool Protocol

  9. Chapter 6: The Scratchpad (Memory)

  10. Chapter 7: The Safety Harness (Plan Mode)

  11. Chapter 8: The Context Pipeline (Map & Search)

  12. Chapter 9: The Reality Check (Running Code)

  13. Part III: The Frontier

  14. Chapter 10: Going Dark (Local Models)

  15. Chapter 11: The Extension (Web Search)

  16. Chapter 12: The Capstone (Building a Game)

  17. Appendix A: Streaming Responses

  18. Acknowledgments