AI Agents from Scratch
Build one agent step by step from a single local LLM call — no frameworks, no cloud APIs, no hidden reasoning.
- Source repo
- pguso/agents-from-scratch
- Stars
- ★ 1.1k
- Last updated
- 4mo ago
- FARS reviewed
- Nov 08, 2026
- License
- MIT
- Primary language
- Python
- FA score
- 47/100 · Major gaps
At a glance
- How it runs
- Works with
- Universal · cross-platform
- Cost
- Free, no paid service needed
- Setup effort
- Medium · a few setup steps
- You'll need
- Typical use
- Backend developers who can code but are lost on how agent loops, state and tools actually fit together
- Not a fit if
- Teams wanting a ready-made demo or SaaS starter kit
- Users unwilling to download a GGUF model into a local models/ folder
- Projects needing production-grade, hosted best practices
- Maintenance
- Commits in the last 6 monthslast commit 2026-07-25
- Source review
- 47/100 · Major gaps 3 safety controls not found
What does this agent do, and when should you use it?
agents-from-scratch is a local-first educational repository that grows a single agent across 12 lessons, starting from one local LLM call and ending with memory, planning, evals and telemetry. The implementation lives in the Agent class in agent/agent.py, which gains new methods in each chapter; supporting modules include memory.py, planner.py, state.py, tools.py, evals.py and telemetry.py, with shared LLM and prompt utilities under shared/. Execution is plain Python against a local GGUF model — no OpenAI or cloud API, no API keys — and complete_example.py runs each of the 12 lessons as a standalone function. evals/golden_datasets.py holds known-good cases for regression testing. The project is explicitly framed as teaching material rather than a production framework.
The curriculum evolves one agent in order: 01 text in / text out; 02 roles via system prompts; 03 structured output enforced by JSON contracts; 04 routing-based decision making; 05 tools from tools.py; 06 the observe → decide → act agent loop; 07 short- and long-term memory through memory.py; 08 planning stored as data rather than thoughts (planner.py); 09 safe execution of atomic actions; 10 Atom of Thought dependency graphs; 11 regression testing with agent/evals.py against evals/golden_datasets.py; 12 runtime observability via agent/telemetry.py, emitting structured logs, latency and traces. Running python complete_example.py isolates each lesson; LLM traffic goes through the shared layer to a local GGUF model. Outputs are text, structured JSON, tool results, and evaluation/telemetry records.
- Backend developers who can code but are lost on how agent loops, state and tools actually fit together
- Educators and trainers who need an offline-capable walkthrough of agent architecture for a classroom or workshop
- Engineers experimenting with local GGUF models on prompts and structured JSON output
- Learners who want a concrete model for adding evals and telemetry to an existing Python project
- Curriculum designers building a staged course around agent fundamentals
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Install / run
pip install -r requirements.txt
How do you install or deploy this agent?
The README's quick start is three steps: install dependencies, download a GGUF model into models/, and run the example.
pip install -r requirements.txtThen place a GGUF model file into the repository's models/ directory. The README does not name a specific model or download source — that piece must be supplied by you. A detailed setup guide is provided in QUICKSTART.md.
How do you use this agent?
Run the bundled example to see all 12 lessons demonstrated. Proceed in order through the lessons; the README explicitly advises against skipping ahead.
python complete_example.pyTo study the evolving implementation, start with the Agent class in agent/agent.py and read lessons/01_basic_llm_chat.md through lessons/12_telemetry.md. For regression testing, compare agent behavior against the known-good cases in evals/golden_datasets.py using agent/evals.py.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
FARS trust-control audit
- confirmation before acting — Turn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
- sensitive-data handling — Use dedicated, low-privilege, revocable API keys — never production credentials — and keep secrets out of logs.
- rollback or recovery path — Back up first, or work on a git branch or snapshot, so its changes can be undone.
What are this agent's strengths and limitations?
- A single
agent/agent.pyevolves across all 12 lessons, so each capability's addition is traceable to one file - Fully local: no OpenAI or cloud API, no API keys, no rate limits
- Relies on JSON contracts and explicit constraints instead of prompt cleverness, per the stated 'structure over prompting' principle
- Ships both a regression eval harness (
agent/evals.py+ golden datasets) and a telemetry module - MIT licensed, with
complete_example.pygiving a runnable demo per lesson
- Self-described as educational, not production — it does not teach deployment or best practices
- You must source a GGUF model yourself; the README names no model or download URL
- No packaging: usage means cloning the repo and running Python scripts
- No cloud or hosted-model path; switching to a remote API means rewriting the shared LLM layer
- Python only — the JavaScript variant lives in a separate repository
How does this agent compare with similar options?
The README explicitly positions the project against 'just use LangChain' and excludes frameworks by design: where LangChain abstracts models, tools and control flow, this repository keeps them as explicit Python to make the loop, state and constraints visible, trading production scaffolding for transparency.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| AI Agents from Scratch This agent | 47 · Major gaps | CLIFree | ★ 1.1k | 4mo ago | Python | — |
| AI Agents From Scratch | 55 · Major gaps | CLIFree | ★ 4.9k | 4mo ago | JavaScript | — |
| Agent Design Patterns (ADPS) | 72 · Some gaps | Library / SDKFree | ★ 363 | 16d ago | HTML | — |
| Build AI Agents from First Principles | 58 · Major gaps | FrameworkFree + model costs | ★ 402 | 29d ago | Python | OpenAI API · Claude API |
How does FollowAgents rate this agent?
Why each dimension lost points
The code shows a local GGUF model, one llama-cpp-python dependency, and explicit tool calls, making the described data flow reasonably clear (2). The dependency has no version or security details. The supplied material does not adequately establish tool permissions, sensitive-data handling, confirmation, rollback, or maintainer identity, so those criteria score only 0–1.
Structured output and decisions retry up to three times and return None on failure, showing a limited recovery path. README and code comments disagree on the lesson count (12 versus 10), the dependency is unpinned, and failure reporting is thin, so these criteria score 1.
The README identifies learners, educators, and engineers, and states who the project is not for, supporting strong audience and scenario coverage. The supplied code excerpt shows some capabilities, but trigger conditions, full capability boundaries, and environment compatibility are only partly described.
The README provides a lesson index, repository structure, and key-file explanations; it points to a separate QUICKSTART, and the MIT license text is complete. The lesson-count mismatch, lack of a visible version or changelog, and absence of a named maintainer or clear update path justify deductions.
The progressive lessons, examples, and readable single-agent code have direct educational use. The materials position the project as educational rather than production guidance, but provide no measured time or resource costs, so utility and cost-benefit score moderately.
README claims about lessons and key files are partly traceable to the listed paths and supplied agent/agent.py excerpt; the license is independently represented. The sample cannot corroborate the full implementation, and static materials cannot verify runtime outcomes. The project distinguishes its educational purpose from production use, supporting a score of 2 for separating fact from inference.
- Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
- Not found in source: sensitive-data handlingUse dedicated, low-privilege, revocable API keys — never production credentials — and keep secrets out of logs.
- Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
- The README claims 12 lessons while agent/agent.py comments list 10; the supplied sample is incomplete and cannot establish all tool, data-handling, or runtime behavior.
- The dependency is unpinned; README statements about safety or observability should not be treated as verified runtime guarantees.
FAQ
Does running it cost anything or require API keys?
Which model and hardware do I need?
models/ and install the Python dependencies from requirements.txt. The README does not specify a model name, size, or VRAM requirement, so that choice is yours.Can I use it in production?
What do the evals and telemetry lessons actually provide?
agent/evals.py with golden datasets in evals/golden_datasets.py for prompt regression testing; lesson 12 adds agent/telemetry.py for structured logging of latency, success rates and traces.Is there a JavaScript version?
ai-agents-from-scratch repository for a JavaScript counterpart; this repository is the Python implementation.Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.