← Back to Leaderboard
Apguso

pguso/ai-agents-from-scratch

Build local JavaScript agents from GGUF inference to tools, memory, and ReAct

View on GitHub ↗
AI FrameworkQuickstart ↓
Engineering Health (Methodology)
B · 60/100
Maintenance Activity
● Updated 4mo ago
Latest Release
Rolling commits (main)
Commercial License Check
MIT · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance12/35
Fork Adoption22/25
Release Cadence6/20
License Clarity20/20
Local AICLI
Total Stars
★ 4,930
24h Growth
+0
7d Growth
+6
Forks
714

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

pguso/ai-agents-from-scratch Star History (2025-10-22 - 2026-12-04) ALL-TIME STAR HISTORY (2025-10 – 2026-12) +4.9k in 408d · avg +12/day 5.2k 2.6k 0 2025-10-22: ★ 12025-11-22: ★ 1,4362025-12-20: ★ 2,1092026-01-17: ★ 2,6162026-02-14: ★ 3,0072026-03-14: ★ 3,2272026-04-11: ★ 3,3222026-05-09: ★ 3,4402026-06-06: ★ 4,1802026-07-04: ★ 4,3302026-08-01: ★ 4,4112026-08-29: ★ 4,5322026-09-26: ★ 4,7882026-10-24: ★ 4,8662026-11-18: ★ 4,9152026-12-04: ★ 4,930 ★ 4.9k 2025-10 2026-05 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

This is a set of runnable JavaScript examples, not a shared agent runtime. The main path starts with node-llama-cpp loading a local GGUF model and progresses from prompt and response to application-owned function handlers. Tool parameters are declared with JSON Schema. The memory example brings retrieved facts and preferences from earlier sessions back into context; ReAct adds a loop that feeds tool observations into the next step.

The manifest contains three dependencies: node-llama-cpp, openai, and dotenv. The OpenAI SDK is used in a separate, optional hosted inference example, not presented as a drop-in backend for every workflow. The integration points are the example scripts and their tool definitions. In particular, helper/prompt-debugger.js lets you inspect what actually reaches the model, including system prompts, function definitions, history, and context state.

Key Capabilities & Differentiators

The examples cover system-prompt specialization, streaming with token limits, and batching across context sequences. At the orchestration layer, Atom of Thought produces structured plans with atomic operations and dependencies for validation and deterministic execution. Tree of Thought uses code-defined scoring to rank and prune branches in a beam search. Graph of Thought extracts from independent sources in parallel, resolves conflicts before drafting, and checks the result against explicit constraints.

The later examples also show phased evidence extraction and policy decisions with separate internal and customer-facing outputs, plus typed errors, timeouts, retries with backoff and jitter, and deterministic tool fallback. Embedding-based routing compares requests with tool exemplars using cosine similarity and passes only the top-k tools, plus any pinned tools, to session.prompt. That can shrink the tool definitions in context, but a low k can hide a needed tool on a multi-intent request.

Trade-offs & Limitations

Compared with a production-oriented agent framework, these scripts trade reusable orchestration and integrations for visibility into prompts, tool calls, state updates, and control flow. That is useful when those mechanics are what you want to learn or test. It's less useful when you need a service: you'll need to define tool permissions and isolation, govern persistent state, and build operational monitoring. The error-handling example is a reference implementation, not a runtime-wide reliability guarantee.

Local inference avoids per-request hosted inference charges and keeps the prompt on the local inference path, but puts model setup and resource sizing on the operator; it does not guarantee that tools or debug output stay local. Hosted inference moves model execution off the machine in exchange for network latency, token costs, and provider data-handling requirements. The code is MIT-licensed, but downloaded models have separate terms.

Hardware & Deployment Guide

For a local run, use Node.js 18 or newer, run npm install, and place the required GGUF files in ./models/ following DOWNLOAD.md. From the repository root, start with node examples/01_intro/intro.js; the ReAct entry point is node examples/09_react-agent/react-agent.js. The project lists at least 8 GB of system RAM and recommends 16 GB. Actual memory demand depends on the model, quantization, context length, concurrent sequences, and CPU/GPU placement; no fixed VRAM requirement is given.

Once the required files and dependencies are installed, the local inference path does not need a hosted inference endpoint. The optional OpenAI example requires API access and connectivity. The delivery path is a local Node process, not a packaged service or container deployment. No GitHub release is listed; the later numbered examples show the curriculum extending into recovery, structured planning and search, and embedding-based routing, not a tagged release history.

Local runtime: JavaScript examples load GGUF models through node-llama-cpp, with a separate optional OpenAI SDK example.
Prompt visibility: helper/prompt-debugger.js exposes system prompts, function definitions, conversation history, and context state.
Agent state: JSON Schema tool definitions, cross-session memory in examples/08_simple-agent-with-memory/, and a separate ReAct loop make each layer inspectable.
Planning and search: AoT validates atomic operations and dependencies; Tree of Thought ranks and prunes a beam; Graph of Thought merges parallel extracts before drafting.
Resilience: examples/11_error-handling/ demonstrates typed errors, timeouts, backoff with jitter, deterministic fallback, and correlation IDs.
Tool routing: Cosine similarity over embedded exemplar phrases selects top-k tools, with optional always-include entries and an explicit multi-intent recall caveat.
Best For

JavaScript engineers learning agent internals or prototyping a local workflow where they need to inspect prompts, tool choices, and state transitions.

Skip If

You need a drop-in production runtime with managed integrations, tool isolation, and service operations, or only need a direct hosted model call.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

Local AICLI
npm install

Comparison vs. Top Agents & Frameworks Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
ai-agents-from-scratch ★4.9k+6JavaScriptMITBuild local JavaScript agents from GGUF inference to tools, memory, and ReAct
agentscope37.2k+322PythonApache-2.0Python ReAct SDK and FastAPI service for observable, interruptible agent workflo
browser-use122.7k+477PythonMITPython REPL and CDP for adaptive browser automation
ag-ui22.6k+611TypeScriptMITA typed event protocol and SDKs that connect agent backends to interactive apps

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/pguso/ai-agents-from-scratch.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

pguso/ai-agents-from-scratch Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about ai-agents-from-scratch

How do I integrate a custom tool and inspect what the model receives?

Start with examples/07_simple-agent/simple-agent.js for JSON Schema tool parameters and examples/09_react-agent/react-agent.js for an iterative tool loop. Adapt the examples as source code rather than assuming a stable plugin API. Use helper/prompt-debugger.js to inspect the rendered prompt, tool definitions, and conversation context; keep sensitive inputs out of shared debug output.

What hardware do I need for local GGUF inference?

The local examples list 8 GB of system RAM as a minimum and recommend 16 GB. Neither figure is a VRAM requirement or a guarantee for every GGUF model. Size for the specific model and quantization, context length, concurrent sequences, and CPU/GPU placement. Start with one sequence and measure memory use before increasing batch size or concurrency.

Can I use the code commercially or run it in a restricted environment?

The MIT license permits commercial use and modification of the repository code, with the copyright and license notices retained when redistributing copies or substantial portions. Check the license of each downloaded model and any dependencies you redistribute separately. Local inference avoids sending prompts to OpenAI for inference, but compliance still depends on tool network access, persistent memory, and debug output. The optional OpenAI example follows a hosted data path.

When is this a better choice than an agent framework or a direct API call?

Prefer this repository when you want to see which tools reach the model, how state re-enters the prompt, and why a workflow retries or falls back. Prefer a production-oriented agent framework when reusable integrations and workflow lifecycle management matter more than inspecting the mechanics. If you only need a hosted model response, a direct API call is simpler than adopting either an agent framework or a local GGUF runtime.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining pguso/ai-agents-from-scratch? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature pguso/ai-agents-from-scratch on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare