Build AI agents from first principles using a local LLM - no frameworks, no cloud APIs, no hidden reasoning.
Python
1,048
11 commits
updated Jul 25, 2026
A gentle, local-first introduction to AI agents.
This repository teaches how AI agents actually work by building one agent step by step from a single local LLM call.
No frameworks. No cloud APIs. No hidden reasoning. No magic.
Learn AI product development fundamentals with local LLMs. Covers prompt engineering, structured output, multi-step reasoning, API design, and frontend integration through 10 comprehensive lessons with visual diagrams.

Agents are not personalities. They are loops, state, and constraints.
If something feels like magic, open the file — there is no hidden logic in this repo.
This repository builds one continuously evolving agent across 12 lessons:
| Lesson | Capability Added | Link |
|---|---|---|
| 01 | Text in / text out | lessons/01_basic_llm_chat.md |
| 02 | Roles and behavior (system prompts) | lessons/02_system_prompt.md |
| 03 | Structured output (JSON contracts) | lessons/03_structured_output.md |
| 04 | Decisions (routing logic) | lessons/04_decision_making.md |
| 05 | Tools (external capabilities) | lessons/05_tools.md |
| 06 | Agent loop (observe → decide → act) | lessons/06_agent_loop.md |
| 07 | Memory (short and long-term) | lessons/07_memory.md |
| 08 | Planning (as data, not thoughts) | lessons/08_planning.md |
| 09 | Atomic actions (safe execution) | lessons/09_atomic_actions.md |
| 10 | AoT - Atom of Thought (dependency graphs) | lessons/10_atom_of_thought.md |
| 11 | Evals (regression testing) | lessons/11_evals.md |
| 12 | Telemetry (runtime observability) | lessons/12_telemetry.md |
This repo is for:
This repo is NOT for:
For detailed setup instructions, see QUICKSTART.md
In short:
pip install -r requirements.txtmodels/ folderpython complete_example.pyNote: The complete_example.py file contains executable code examples demonstrating all 12 lessons. You can use it as a reference to see how all the concepts fit together.
ai-agents-from-scratch/
├─ README.md # You are here
├─ philosophy.md # Why this repo exists
├─ QUICKSTART.md # Detailed setup guide
├─ complete_example.py # Demonstrations of all 12 lessons
├─ requirements.txt # Python dependencies
│
├─ models/ # Place GGUF models here
├─ shared/ # Reusable utilities (LLM, prompts, utils)
├─ agent/ # The evolving agent implementation
│ ├─ agent.py # Main agent class
│ ├─ memory.py # Memory system
│ ├─ planner.py # Planning and atomic actions
│ ├─ state.py # Agent state management
│ ├─ tools.py # Tool definitions
│ ├─ evals.py # Evaluation framework (Lesson 11)
│ └─ telemetry.py # Telemetry system (Lesson 12)
├─ evals/ # Golden datasets for testing
│ └─ golden_datasets.py # Known-good test cases
└─ lessons/ # Step-by-step explanations (01-12)
agent/agent.py - The heart of the repository
Agent class that evolves across all 12 lessonscomplete_example.py - Learning reference
python complete_example.pyagent/evals.py - Regression testing (Lesson 11)
agent/telemetry.py - Runtime observability (Lesson 12)
Relationship:
agent/agent.py = the code you're learning (the implementation)complete_example.py = isolated examples of each lesson (for learning and experimentation)agent.py file grows across lessonsEach lesson builds on the previous one. Do not skip ahead.
The curriculum is designed to build understanding gradually:
This is an educational repository. Contributions should:
MIT License - see LICENSE file
This repository synthesizes best practices from modern agent development while deliberately avoiding complexity that obscures understanding.
If you find this useful, please star the repository and share it with others learning about AI agents.
67 followers · starred Jan 2026
166 followers · starred May 2026
26 followers · starred Jan 2026
168 followers · starred Jan 2026
Build AI agents from first principles using a local LLM - no frameworks, no cloud APIs, no hidden reasoning.
Python
1,048
11 commits
updated Jul 25, 2026
A gentle, local-first introduction to AI agents.
This repository teaches how AI agents actually work by building one agent step by step from a single local LLM call.
No frameworks. No cloud APIs. No hidden reasoning. No magic.
Learn AI product development fundamentals with local LLMs. Covers prompt engineering, structured output, multi-step reasoning, API design, and frontend integration through 10 comprehensive lessons with visual diagrams.

Agents are not personalities. They are loops, state, and constraints.
If something feels like magic, open the file — there is no hidden logic in this repo.
This repository builds one continuously evolving agent across 12 lessons:
| Lesson | Capability Added | Link |
|---|---|---|
| 01 | Text in / text out | lessons/01_basic_llm_chat.md |
| 02 | Roles and behavior (system prompts) | lessons/02_system_prompt.md |
| 03 | Structured output (JSON contracts) | lessons/03_structured_output.md |
| 04 | Decisions (routing logic) | lessons/04_decision_making.md |
| 05 | Tools (external capabilities) | lessons/05_tools.md |
| 06 | Agent loop (observe → decide → act) | lessons/06_agent_loop.md |
| 07 | Memory (short and long-term) | lessons/07_memory.md |
| 08 | Planning (as data, not thoughts) | lessons/08_planning.md |
| 09 | Atomic actions (safe execution) | lessons/09_atomic_actions.md |
| 10 | AoT - Atom of Thought (dependency graphs) | lessons/10_atom_of_thought.md |
| 11 | Evals (regression testing) | lessons/11_evals.md |
| 12 | Telemetry (runtime observability) | lessons/12_telemetry.md |
This repo is for:
This repo is NOT for:
For detailed setup instructions, see QUICKSTART.md
In short:
pip install -r requirements.txtmodels/ folderpython complete_example.pyNote: The complete_example.py file contains executable code examples demonstrating all 12 lessons. You can use it as a reference to see how all the concepts fit together.
ai-agents-from-scratch/
├─ README.md # You are here
├─ philosophy.md # Why this repo exists
├─ QUICKSTART.md # Detailed setup guide
├─ complete_example.py # Demonstrations of all 12 lessons
├─ requirements.txt # Python dependencies
│
├─ models/ # Place GGUF models here
├─ shared/ # Reusable utilities (LLM, prompts, utils)
├─ agent/ # The evolving agent implementation
│ ├─ agent.py # Main agent class
│ ├─ memory.py # Memory system
│ ├─ planner.py # Planning and atomic actions
│ ├─ state.py # Agent state management
│ ├─ tools.py # Tool definitions
│ ├─ evals.py # Evaluation framework (Lesson 11)
│ └─ telemetry.py # Telemetry system (Lesson 12)
├─ evals/ # Golden datasets for testing
│ └─ golden_datasets.py # Known-good test cases
└─ lessons/ # Step-by-step explanations (01-12)
agent/agent.py - The heart of the repository
Agent class that evolves across all 12 lessonscomplete_example.py - Learning reference
python complete_example.pyagent/evals.py - Regression testing (Lesson 11)
agent/telemetry.py - Runtime observability (Lesson 12)
Relationship:
agent/agent.py = the code you're learning (the implementation)complete_example.py = isolated examples of each lesson (for learning and experimentation)agent.py file grows across lessonsEach lesson builds on the previous one. Do not skip ahead.
The curriculum is designed to build understanding gradually:
This is an educational repository. Contributions should:
MIT License - see LICENSE file
This repository synthesizes best practices from modern agent development while deliberately avoiding complexity that obscures understanding.
If you find this useful, please star the repository and share it with others learning about AI agents.
67 followers · starred Jan 2026
166 followers · starred May 2026
26 followers · starred Jan 2026
168 followers · starred Jan 2026