@GitTrend0x: AI Agent from Newbie to Master Pro-Grade Artifact https://github.com/pguso/ai-agents-from-scratch… This is ai-agents-from-scratch, a 3.9k star hit that 'truly explains AI Agent…'

X AI KOLs Timeline Tools

Summary

Introduces a 3.9k star open-source tutorial project, ai-agents-from-scratch, which builds AI Agents from scratch using local LLM and Node.js, covering core concepts such as system prompts, tools, memory, and reasoning patterns.

AI Agent from Newbie to Master Pro-Grade Artifact https://github.com/pguso/ai-agents-from-scratch… This is ai-agents-from-scratch, a 3.9k star popular open-source tutorial project that "truly makes AI Agent clear"! It's not another encapsulated Agent framework, but a step-by-step guide to building your own Agent from scratch, using local LLM + Node.js. It dissects all core components: LLM + System Prompt + Tools + Memory + Reasoning Pattern, showing them to you one by one. From the most basic implementations to advanced patterns like Tree of Thought, Graph of Thought, ReAct, AoT, etc., completely leaving behind the black box!
Original Article
View Cached Full Text

Cached at: 05/26/26, 01:12 PM

AI Agent from Zero to Hero – Advanced Boost Tool https://github.com/pguso/ai-agents-from-scratch… This is ai-agents-from-scratch, a 3.9k-star blockbuster open-source tutorial project that truly demystifies AI Agents! It’s not another wrapper-style Agent framework – it teaches you how to build your own Agent from scratch, hand-by-hand. Using a local LLM + Node.js, it breaks down every core component (LLM + System Prompt + Tools + Memory + Reasoning Pattern) and shows them to you step by step, starting from the very basics all the way up to advanced patterns like Tree of Thought, Graph of Thought, ReAct, AoT, etc. Say goodbye to black boxes forever!


pguso/ai-agents-from-scratch

Source: https://github.com/pguso/ai-agents-from-scratch

AI Agents From Scratch

Learn to build AI agents locally without frameworks. Understand what happens under the hood before using production frameworks.

Agent architecture overview

Purpose

This repository teaches you to build AI agents from first principles using local LLMs and node-llama-cpp. By working through these examples, you’ll understand:

  • How LLMs work at a fundamental level
  • What agents really are (LLM + tools + patterns)
  • How different agent architectures function
  • Why frameworks make certain design choices

A Python version of this tutorial is available here: https://github.com/pguso/agents-from-scratch

Philosophy: Learn by building. Understand deeply, then use frameworks wisely.

Companion Website

This repository now has a matching companion website: https://agentsfromscratch.com

The website is not a replacement for this repo, but a conceptual companion that:

  • Explains why each example exists
  • Visualizes the learning path from raw LLM calls to full agents
  • Separates code, explanations, and core concepts
  • Helps you understand agent architectures before using frameworks

Recommended workflow:

  • Use GitHub for running, modifying, and studying the code
  • Use the website for mental models, explanations, and progression

Think of the site as the map and this repo as the terrain.

Agent Fundamentals - From LLMs to ReAct

Prerequisites

  • Node.js 18+
  • At least 8GB RAM (16GB recommended)
  • Download models and place in ./models/ folder, details in DOWNLOAD.md

Installation

npm install

Run Examples

node intro/intro.js
node simple-agent/simple-agent.js
node react-agent/react-agent.js

Learning Path

Follow these examples in order to build understanding progressively:

1. Introduction - Basic LLM Interaction intro/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Loading and running a local LLM
  • Basic prompt/response cycle Key concepts: Model loading, context, inference pipeline, token generation

2. (Optional) OpenAI Intro - Using Proprietary Models openai-intro/ | Code | Code Explanation | Concepts

What you’ll learn:

  • How to call hosted LLMs (like GPT-4)
  • Temperature Control
  • Token Usage Key concepts: Inference endpoints, network latency, cost vs control, data privacy, vendor dependence

3. Translation - System Prompts & Specialization translation/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Using system prompts to specialize agents
  • Output format control
  • Role-based behavior
  • Chat wrappers for different models Key concepts: System prompts, agent specialization, behavioral constraints, prompt engineering

4. Think - Reasoning & Problem Solving think/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Configuring LLMs for logical reasoning
  • Complex quantitative problems
  • Limitations of pure LLM reasoning
  • When to use external tools Key concepts: Reasoning agents, problem decomposition, cognitive tasks, reasoning limitations

5. Batch - Parallel Processing batch/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Processing multiple requests concurrently
  • Context sequences for parallelism
  • GPU batch processing
  • Performance optimization Key concepts: Parallel execution, sequences, batch size, throughput optimization

6. Coding - Streaming & Response Control coding/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Real-time streaming responses
  • Token limits and budget management
  • Progressive output display
  • User experience optimization Key concepts: Streaming, token-by-token generation, response control, real-time feedback

7. Simple Agent - Function Calling (Tools) simple-agent/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Function calling / tool use fundamentals
  • Defining tools the LLM can use
  • JSON Schema for parameters
  • How LLMs decide when to use tools Key concepts: Function calling, tool definitions, agent decision making, action-taking This is where text generation becomes agency!

8. Simple Agent with Memory - Persistent State simple-agent-with-memory/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Persisting information across sessions
  • Long-term memory management
  • Facts and preferences storage
  • Memory retrieval strategies Key concepts: Persistent memory, state management, memory systems, context augmentation

9. ReAct Agent - Reasoning + Acting react-agent/ | Code | Code Explanation | Concepts

What you’ll learn:

  • ReAct pattern (Reason → Act → Observe)
  • Iterative problem solving
  • Step-by-step tool use
  • Self-correction loops Key concepts: ReAct pattern, iterative reasoning, observation-action cycles, multi-step agents This is the foundation of modern agent frameworks!

10. AoT Agent - Atom of Thought Planning aot-agent/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Atom of Thought methodology
  • Atomic planning for multi-step computations
  • Dependency management between operations
  • Structured JSON output for reasoning plans
  • Deterministic execution of plans Key concepts: AoT planning, atomic operations, dependency resolution, plan validation, structured reasoning

11. Error Handling - Resilience for LLM + Tools error-handling/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Typed error taxonomy (validation, LLM, tools, workflow) with stable codes
  • Timeouts, retries with backoff/jitter, and classifying transient failures
  • Graceful degradation when the LLM path fails (deterministic tool fallback)
  • Orchestration-level errors (AgentWorkflowError) and correlation ids for support Key concepts: Error taxonomy, retry policies, timeouts, fallbacks, degraded mode, observability, user-safe messaging

12. Tree of Thought - Search over reasoning branches tree-of-thought/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Generating multiple candidate next actions from the same partial plan
  • Ranking and pruning branches with a deterministic score in code
  • Running a compact beam search loop with inspectable kept/pruned decisions
  • Verifying the winning path with explicit sanity checks Key concepts: Tree of Thought, beam search, branch pruning, verifiable objectives, search controllers

13. Graph of Thought - DAG merge for multi-source outputs graph-of-thought/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Modeling reasoning as a DAG: parallel source extracts → merge rules → final draft
  • Resolving conflicts explicitly before generation (must_include, must_avoid, conflict_notes)
  • Adding deterministic merge and draft compliance checks
  • Running independent nodes in parallel to reduce latency Key concepts: Graph of Thought, DAG orchestration, multi-source fusion, merge-before-generate, policy reconciliation Decision guide: use ToT when you need to search competing paths; use GoT when you need to combine multiple sources into one consistent policy. Compare both in:
  • ToT concept
  • GoT concept

14. Chain of Thought - Auditable stepwise decisioning chain-of-thought/ | Code | Code Explanation | Concepts

What you’ll learn:

  • Splitting a high-stakes decision into explicit reasoning phases
  • Preventing early bias with a facts-only extraction step
  • Balancing fraud signals with legitimacy evidence before policy application
  • Producing an auditable final decision with customer-safe and internal outputs Key concepts: Chain of Thought, structured reasoning traces, policy-constrained decisions, explainability, review-ready workflows

Documentation Structure

Each example folder contains:

  • .js - The working code example
  • CODE.md - Step-by-step code explanation
    • Line-by-line breakdowns
    • What each part does
    • How it works
  • CONCEPT.md - High-level concepts
    • Why it matters for agents
    • Architectural patterns
    • Real-world applications
    • Simple diagrams

Core Concepts

What is an AI Agent?

AI Agent = LLM + System Prompt + Tools + Memory + Reasoning Pattern
   ─┬─     ──────┬──────    ──┬──   ──┬───   ────────┬────────
    │            │             │      │              │
   Brain       Identity      Hands  Memory        Strategy

Evolution of Capabilities

1. intro          → Basic LLM usage
2. translation    → Specialized behavior (system prompts)
3. think          → Reasoning ability
4. batch          → Parallel processing
5. coding         → Streaming & control
6. simple-agent   → Tool use (function calling)
7. memory-agent   → Persistent state
8. react-agent    → Strategic reasoning + tool use

Architecture Patterns

Simple Agent (Steps 1-5)

User → LLM → Response

Tool-Using Agent (Step 6)

User → LLM ⟷ Tools → Response

Memory Agent (Step 7)

User → LLM ⟷ Tools → Response
                          ↕
                       Memory

ReAct Agent (Step 8)

User → LLM → Think → Act → Observe
                ↑      ↓      ↓       ↓
                └──────┴──────┴───────┘
                      Iterate until solved

️ Helper Utilities

PromptDebugger

helper/prompt-debugger.js Utility for debugging prompts sent to the LLM. Shows exactly what the model sees, including:

  • System prompts
  • Function definitions
  • Conversation history
  • Context state

Usage example in simple-agent/simple-agent.js

️ Project Structure - Fundamentals

ai-agents/
├── README.md               ← You are here
├─ examples/
│   ├── 01_intro/
│   │   ├── intro.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 02_openai-intro/
│   │   ├── openai-intro.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 03_translation/
│   │   ├── translation.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 04_think/
│   │   ├── think.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 05_batch/
│   │   ├── batch.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 06_coding/
│   │   ├── coding.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 07_simple-agent/
│   │   ├── simple-agent.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 08_simple-agent-with-memory/
│   │   ├── simple-agent-with-memory.js
│   │   ├── memory-manager.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 09_react-agent/
│   │   ├── react-agent.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 10_aot-agent/
│   │   ├── aot-agent.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 11_error-handling/
│   │   ├── error-handling.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 12_tree-of-thought/
│   │   ├── tree-of-thought.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 13_graph-of-thought/
│   │   ├── graph-of-thought.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
│   ├── 14_chain-of-thought/
│   │   ├── chain-of-thought.js
│   │   ├── CODE.md
│   │   └── CONCEPT.md
├── helper/
│   └── prompt-debugger.js
├── models/                ← Place your GGUF models here
└── logs/                  ← Debug outputs

Additional Resources

  • node-llama-cpp: GitHub (https://github.com/withcatai/node-llama-cpp)
  • Model Hub: Hugging Face (https://huggingface.co/models?library=gguf)
  • GGUF Format: Quantized models for local inference

Contributing

This is a learning resource. Feel free to:

  • Suggest improvements to documentation
  • Add more example patterns
  • Fix bugs or unclear explanations
  • Share what you built!

License

Educational resource - use and modify as needed for learning.


Built with ❤️ for people who want to truly understand AI agents

Start with intro/ and work your way through. Each example builds on the previous one. Read both CODE.md and CONCEPT.md for full understanding. Happy learning!

GitTrend (@GitTrend0x): Reddit stories turned into viral shorts – open-source tool

https://t.co/5DIeenCfmj

This is RedditVideoMakerBot, a fully automatic bot that turns Reddit stories into viral videos! Auto-fetches hot Reddit posts (AITA, TIFU, confessions, etc.) → AI natural voiceover → Smart matching of background videos/footage → One-click generation for TikTok / YouTube Shorts.

Similar Articles

@GitHub_Daily: Many tutorials teach AI Agent development by jumping straight into frameworks — you install it and it runs, but you don't really understand what's going on underneath. ai-agents-from-scratch takes the opposite approach, starting from the most basic model call and gradually building up core patterns like tool calling, memory, and ReAct loops. It uses local models throughout…

X AI KOLs Timeline

GitHub_Daily recommends an open-source project called ai-agents-from-scratch. It starts from zero and uses local models to gradually implement core patterns such as tool calling, memory, and ReAct loops, helping developers understand the underlying principles of AI Agents without directly using frameworks.

@FakeMaidenMaker: Full-Stack AI Engineer Roadmap: From Zero to Math, LLMs, and Agents – Covers Everything. There’s tons of AI material online, but it's all fragmented—one article on fine-tuning, another agent demo, every search yields "Build a RAG in 5 minutes" fast food. A coherent system from math to LLM to agent is nearly impossible to find.

X AI KOLs Timeline

A free, open-source AI engineering curriculum that covers math, LLMs, and agents across 20 phases and 435 lessons in Python, TypeScript, Rust, and Julia, designed to fill gaps in fragmented AI tutorials.

@FakeMaidenMaker: If you really want to understand how the underlying of AI Agents like Claude Code is built, this open-source project writes one from scratch for you to see. GitHub has garnered 66.5K Stars, and also made it to the Trendshift hot list. The intelligence of an Agent comes from the model itself; what you can do is not "building intelligence"...

X AI KOLs Timeline

An open-source project teaches you to build a simplified version of Claude Code from scratch, thoroughly explaining the harness engineering of AI Agents. It has received 66.5K Stars.

@Smartpigai: Anyone using AI for coding should bookmark this 113K stars open-source project: The Agency: a ready-made AI expert team. It organizes 232 specialized agents across 16 fields including frontend, backend, DevOps, product, design, marketing, security, testing, and more.

X AI KOLs Timeline

The Agency is a GitHub repository with 232 specialized AI agent prompts and workflows for roles like frontend, backend, DevOps, and more, designed to help developers use AI coding tools more effectively.

@FakeMaidenMaker: Folks, we've dug up another AI engineering treasure: Hands-On-AI-Engineering. Just open-sourced, it already hit 2.3K stars. One repo stuffed with over 50 real AI projects that you can run directly. The most practical part is it doesn't talk about vague theories; each project is a complete little…

X AI KOLs Timeline

Recommends the freshly open-sourced GitHub repo Hands-On-AI-Engineering with 2.3K stars, containing over 50 runnable AI projects covering RAG, AI agent, OCR, and more. Each project provides full code and instructions, suitable for hands-on learning.