AI Agents From Scratch

Build AI agents locally without frameworks, demystifying function calling, memory, and ReAct patterns using node-llama-cpp.

Stars
★ 4.9k
Last updated
4mo ago
FARS reviewed
Nov 08, 2026
License
MIT
Primary language
JavaScript

At a glance

How it runs
CLILibrary / SDK
Works with
Platform-specific
Cost
Free, no paid service needed
Setup effort
Medium · a few setup steps
You'll need
Node.js 18+node-llama-cpplocal GGUF modelsShell / CLINetwork accessLocal filesystem
Typical use
A Node.js developer who wants to use local LLMs in their application and needs to understand the underlying mechanisms.
Not a fit if
  • Teams needing a production-ready agent framework out of the box
  • Users with under 8GB RAM or unwilling to download GGUF models manually
  • People who want a hosted API with no local model setup
Maintenance
Commits in the last 6 monthslast commit 2026-07-24+0.9 ★/day over 7 days

What does this agent do, and when should you use it?

This repository is a progressive, educational resource for building AI agents from first principles using local LLMs and node-llama-cpp. It contains 15 examples that start with basic LLM interaction and gradually cover system prompts, reasoning, batch processing, streaming, function calling, persistent memory, ReAct, AoT, error handling, Tree of Thought, Graph of Thought, Chain of Thought, and embedding-based tool routing. Each example includes working code (.js) plus dedicated documentation (CODE.md and CONCEPT.md) explaining the implementation and concepts. The project emphasizes local inference, requiring users to download GGUF models, and provides a companion website for conceptual mapping. The goal is for learners to deeply understand how agents work under the hood so they can use production frameworks wisely.

The repository runs a series of Node.js scripts that load local GGUF models via node-llama-cpp and perform inference. Examples include intro/intro.js (basic prompting), simple-agent/simple-agent.js (function calling), react-agent/react-agent.js (ReAct pattern), and tree-of-thought/tree-of-thought.js (beam search). Each script reads local models, takes input, calls the LLM, and optionally uses tool functions (e.g., function definitions in simple-agent). It provides a PromptDebugger utility (helper/prompt-debugger.js) to inspect the exact prompt sent to the model. Users run scripts via the command line and modify parameters based on CODE.md and CONCEPT.md files in each example folder.

  1. A Node.js developer who wants to use local LLMs in their application and needs to understand the underlying mechanisms.
  2. A developer learning function calling who wants a complete, working example on a local LLM with tool definitions.
  3. An AI engineer looking to deeply understand the ReAct pattern and the reasoning, acting, observing loop.
  4. A developer who wants to add persistent memory to LLM applications and understand state management.
  5. An engineer needing to implement tool routing to reduce context length and observe how embedding similarity selects relevant tools.
  6. A student or hobbyist who wants a hands-on introduction to agent architectures before building with production frameworks.

How do you install or deploy this agent?

First, ensure Node.js 18 or higher is installed. Then clone the repository and run npm install to install dependencies. Next, create a models/ folder in the repository root and download GGUF-format models (e.g., from Hugging Face) into it. Refer to DOWNLOAD.md for specific model recommendations and links.

How do you use this agent?

After installation, run examples from the repository root, such as node intro/intro.js or node react-agent/react-agent.js. Make sure models are downloaded and placed in ./models/. Each example folder contains CODE.md (step-by-step code explanation) and CONCEPT.md (concept overview); for full understanding, read both.

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)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

Local filesystem read/write

Modifies local files; work on a clean Git branch or dedicated worktree.

Outbound network access

Makes outbound requests; verify telemetry settings and model data routing on private repos.

FARS trust-control audit

Not found in source — apply before daily use
  • 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?

Pros
  • All code uses local LLMs via node-llama-cpp, eliminating API dependencies and protecting privacy.
  • Each example includes CODE.md and CONCEPT.md, providing detailed explanations ideal for education.
  • Covers multiple advanced agent patterns (ReAct, ToT, GoT, CoT) offering a broad architectural perspective.
  • Includes a PromptDebugger utility to debug the exact prompt sent to the LLM, enhancing observability.
  • Companion website supplements the repository with conceptual explanations, aiding the learning path.
Limitations
  • Requires familiarity with local model configuration and hardware (at least 8GB RAM).
  • Examples are standalone scripts and lack production deployment integration or standardized APIs.
  • Primarily a tutorial resource, not a production-ready agent framework; additional engineering is needed.
  • Model downloads are manual, adding setup steps.
  • Core dependency on node-llama-cpp and local GGUF models; migrating to other engines requires adaptation.

How does this agent compare with similar options?

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 55 · Major gaps CLIFree ★ 4.9k 4mo ago JavaScript —
AI Agents from Scratch 47 · Major gaps CLIFree ★ 1.1k 4mo ago Python —
KodeAgent 49 · Major gaps Library / SDKFree + model costs ★ 46 4d ago Python OpenAI API · Claude API
Vibe Vibe – AI Coding for Everyone Insufficient evidence Web appFree ★ 6.3k 7mo ago Dockerfile —

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Major gaps
55/ 100 5-point scale 2.8 / 5
Trust 10/29
Reliability 5/14
Adaptability 14/18
Convention 10/18
Effectiveness 12/13
Verifiability 4/8
Why each dimension lost points
Trust10 / 29 · 1.7/5

The README explicitly presents a local-model path, marks the hosted OpenAI example optional, and names privacy, latency, cost, and vendor dependence, supporting a score of 2 for data-flow transparency. Tool calls and persistent memory are central teaching topics, but this packet shows no permission constraints, pre-action confirmation, sensitive-data safeguards, or rollback mechanism. Dependencies have version ranges but no security policy; handling of external side effects is also not shown. The license contains MIT terms, but its copyright holder remains '[Your Name]', weakening attribution evidence.

Reliability5 / 14 · 1.8/5

The README clearly orders 15 topics and points to code, explanation, and concept documents. However, example paths are inconsistent (for example, run commands use simple-agent/ while the body links examples/07_simple-agent/), package.json names index.js as the main entry although it is not shown in this packet, and the test script explicitly exits with failure. Error handling is promised as a topic, but the provided material does not show concrete messages or implementation, so that criterion receives only a thin score.

Adaptability14 / 18 · 3.9/5

The intended audience and purpose are clear: learners seeking to understand local AI agents from first principles, with coverage from basic calls through several reasoning and tool patterns. The README discusses models, memory, tools, and tradeoffs of a hosted API, and notes that multi-intent tool routing can lose recall when k is too small; actual capability boundaries and environment details remain incomplete. Node.js 18+, a memory recommendation, and a model directory provide basic environment guidance.

Convention10 / 18 · 2.8/5

The README provides a clear learning sequence, project structure, per-example code and concept links, plus installation, run, resource, and contribution notes. Commands and directory links are inconsistent; limitations are only lightly documented; the license has an unreplaced copyright placeholder, and package.json declares ISC while the supplied license file is MIT. The packet includes no changelog or clear maintenance responsibility/update path. The publisher's unverified identity is not itself penalized.

Effectiveness12 / 13 · 4.6/5

The learning outputs are concrete and usable: 15 progressive examples cover function calling, memory, ReAct, planning, error handling, and tool routing, with code and concept explanations for each. The marginal value for understanding agents from scratch is clear. Cost-benefit is reduced somewhat by the local-model requirement, 8 GB minimum/16 GB recommended memory, and a model-download procedure delegated to another file whose contents are not in this packet.

Verifiability4 / 8 · 2.5/5

The README maps learning goals to specific examples, code, and explanation documents, making some claims traceable. However, this packet includes only the README, package.json, and LICENSE, not the example source or tests, so cross-source corroboration is limited. The README distinguishes teaching goals from code and concept explanations, but several capability statements remain learning claims and do not establish implementation results.

Risks and how to mitigate them
  • Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
  • This is a low-confidence static review; the packet does not include example implementations, the full model-download instructions, or runnable test evidence.
  • The README, package.json, and license disagree on example paths, entry point, and license identifier; the MIT file still has a placeholder copyright holder.
  • For tool side effects and persistent memory, the packet shows no confirmation, sensitive-data safeguards, or recovery mechanism; tutorial descriptions should not be treated as production safety guarantees.
Evidence confidence: Low Reviewed Nov 08, 2026 Reviewed revision 62e4ac7bf805
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/ai-agents-from-scratch.svg)](https://followagents.com/en/agents/ai-agents-from-scratch)
<a href="https://followagents.com/en/agents/ai-agents-from-scratch"><img src="https://followagents.com/badge/ai-agents-from-scratch.svg" alt="FARS review"></a>

FAQ

How much RAM is needed to run the examples?
At least 8GB, recommended 16GB. Model size and quantization affect actual usage.
Can I use cloud LLMs?
The project primarily uses local LLMs, but an optional example (openai-intro) demonstrates calling hosted models like GPT-4.
How do I choose the right model?
Models must be in GGUF format. Refer to DOWNLOAD.md for links and recommendations, typically choosing quantized models for local inference.
Are these examples suitable for production?
No, they are educational and demonstrate concepts. Production deployment requires additional work like error handling, performance optimization, and integration.
Is there a Python version?
Yes, a Python version is available at https://github.com/pguso/agents-from-scratch.
Was this page helpful?
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts