ai-agents-from-scratch
AgentFreeDemystify AI agents by building them yourself. Local LLMs, no black boxes, real understanding of function calling, memory, and ReAct patterns.
Capabilities12 decomposed
local-llm-inference-via-node-llama-cpp
Medium confidenceExecutes quantized GGUF language models locally using node-llama-cpp bindings to the llama.cpp C++ runtime, with platform-specific acceleration (Metal on macOS, CUDA/Vulkan on Linux/Windows). Models run entirely on-device without cloud API calls, enabling privacy-preserving inference with configurable temperature, token limits, and streaming output. The architecture abstracts the underlying C++ runtime through JavaScript bindings, handling model loading, memory management, and token generation.
Uses node-llama-cpp bindings to llama.cpp's optimized C++ runtime rather than pure JavaScript inference, enabling hardware acceleration (Metal/CUDA/Vulkan) and efficient token generation on consumer hardware. The repository explicitly teaches this as the foundation layer, with examples showing model loading, context window management, and streaming token iteration.
Faster and more memory-efficient than pure JavaScript LLM implementations (e.g., ONNX Runtime), and more transparent than cloud APIs because the entire inference pipeline runs locally with visible code.
function-calling-with-tool-schema-binding
Medium confidenceImplements structured function calling by embedding tool schemas in system prompts and parsing LLM-generated function calls from text output. The architecture defines tools as JavaScript objects with name, description, and parameters, then instructs the LLM to output function calls in a parseable format (typically JSON or XML). A tool execution framework intercepts these outputs, validates them against the schema, and executes the corresponding JavaScript functions, returning results back to the LLM for further reasoning.
Implements function calling as a text-parsing pattern rather than relying on proprietary APIs, making it transparent and portable across any LLM. The repository includes explicit examples (simple-agent module) showing schema definition, prompt engineering for tool calls, and error handling — teaching the mechanics rather than hiding them in a framework.
More transparent and educational than OpenAI's function_calling API, and works with any local LLM; less reliable than native function calling because it depends on text parsing, but enables understanding of how function calling actually works.
hybrid-local-cloud-model-switching
Medium confidenceEnables switching between local LLMs (via node-llama-cpp) and cloud APIs (OpenAI, Anthropic) through a unified interface, allowing developers to compare quality/speed tradeoffs or fall back to cloud when local inference is insufficient. The architecture abstracts the model backend behind a common interface, with conditional logic to route requests to either local or cloud providers based on configuration. This pattern allows the same agent code to work with different model sources without modification.
Demonstrates hybrid architectures through the openai-intro module, showing how to use OpenAI API as an alternative to local inference. The repository explicitly compares local vs cloud approaches, enabling developers to understand when each is appropriate.
More flexible than pure local or pure cloud approaches, enabling experimentation and fallback; requires more code to manage multiple providers, but enables informed decision-making about deployment strategy.
progressive-learning-path-with-modular-examples
Medium confidenceStructures agent development as a nine-module learning progression, where each module introduces exactly one new concept (basic LLM interaction → function calling → memory → ReAct). The architecture uses consistent module structure (executable .js file, detailed CODE.md walkthrough, conceptual CONCEPT.md explanation) to enable self-paced learning with multiple entry points. Each module builds on previous ones, creating a scaffolded learning experience from fundamentals to autonomous agents.
Structures the entire repository as a deliberate learning progression with consistent documentation (CODE.md for implementation details, CONCEPT.md for conceptual understanding), making it explicitly educational rather than just a collection of examples. Each module is self-contained but builds on previous ones.
More pedagogically structured than most open-source agent projects, with explicit focus on understanding over frameworks; less comprehensive than production frameworks like LangChain, but more transparent and suitable for learning.
persistent-conversation-memory-with-message-history
Medium confidenceMaintains conversation state by storing message history (user and assistant messages) in memory or persistent storage, then including the full or windowed history in each LLM prompt. The architecture uses a message buffer that tracks role (user/assistant), content, and optionally metadata (timestamps, tool calls). Between turns, the system appends new user messages and LLM responses to this buffer, then passes the entire history to the LLM context window, enabling multi-turn reasoning and context awareness.
Implements memory as simple message history appended to each prompt, without vector databases, RAG, or external storage — making it transparent and suitable for educational purposes. The simple-agent-with-memory module explicitly shows how to maintain state across turns and handle context window constraints.
Simpler and more transparent than RAG-based memory systems, but less scalable for long-term memory; suitable for session-level context but not for persistent knowledge bases across multiple conversations.
react-pattern-agent-orchestration
Medium confidenceImplements the ReAct (Reasoning + Acting) pattern by orchestrating a loop where the LLM reasons about the next step, decides whether to call a tool or return a final answer, executes the tool if needed, and incorporates the result back into the conversation history. The architecture maintains a reasoning trace (visible to the LLM) that shows thought processes, tool calls, and observations, enabling the agent to self-correct and refine its approach iteratively. Each loop iteration appends the LLM's reasoning and tool results to the message history, creating a transparent audit trail.
Implements ReAct as an explicit loop in JavaScript code rather than hiding it in a framework, showing exactly how reasoning, tool selection, and action execution are orchestrated. The react-agent module includes the full loop with error handling, reasoning trace management, and termination logic, making the pattern transparent and modifiable.
More transparent and educational than LangChain's agent executors because the entire loop is visible and modifiable; less robust than production frameworks because error handling and optimization are manual, but enables deep understanding of agent mechanics.
streaming-token-generation-with-async-iteration
Medium confidenceStreams LLM output tokens in real-time using async iterators, allowing applications to display partial responses as they are generated rather than waiting for the full completion. The architecture uses node-llama-cpp's streaming API to yield tokens as they are produced by the inference engine, enabling progressive rendering, early stopping, and responsive user interfaces. Each token is yielded individually, allowing callers to accumulate them into a full response or process them incrementally.
Exposes node-llama-cpp's streaming API directly through JavaScript async iterators, making token-by-token generation transparent and composable. The coding module demonstrates streaming for code generation, showing how to accumulate tokens and handle partial outputs.
More efficient than buffering full responses before rendering, and more transparent than cloud APIs that abstract streaming details; requires more manual handling of async patterns but enables fine-grained control over token processing.
system-prompt-specialization-for-task-adaptation
Medium confidenceAdapts LLM behavior by injecting task-specific system prompts that define role, constraints, output format, and reasoning style. The architecture treats system prompts as the primary control mechanism for agent specialization, allowing different prompts to transform the same base model into different specialized agents (translator, reasoner, code generator, etc.). System prompts are prepended to the message history and remain constant across conversation turns, establishing the agent's persona and operational guidelines.
Treats system prompts as the primary mechanism for agent specialization, with examples (translation, think modules) showing how different prompts transform the same model. The repository emphasizes prompt engineering as a core skill for agent development, with explicit CONCEPT.md documentation for each module's prompt strategy.
More flexible and transparent than model fine-tuning, and faster to iterate than training custom models; less reliable than fine-tuning for complex behaviors, but enables rapid experimentation and task switching without retraining.
batch-parallel-processing-with-concurrent-inference
Medium confidenceProcesses multiple independent requests concurrently using Promise.all() or similar patterns, allowing multiple inference tasks to run in parallel (subject to hardware constraints). The architecture spawns multiple LLM inference tasks simultaneously, each with its own prompt and context, then collects results as they complete. This pattern is useful for embarrassingly parallel workloads (e.g., processing a batch of documents, generating multiple variations) where tasks are independent and can share the same model instance.
Demonstrates concurrent inference using standard JavaScript Promise patterns (Promise.all) rather than specialized frameworks, showing how to parallelize LLM tasks with explicit concurrency control. The batch module includes examples of processing multiple requests and handling results/errors.
Simpler and more transparent than distributed inference frameworks, but limited by single-machine resources; suitable for batch processing on local hardware, not for large-scale distributed workloads.
model-selection-and-quantization-strategy-guidance
Medium confidenceProvides educational guidance on selecting appropriate quantized GGUF models based on task requirements, hardware constraints, and quality/speed tradeoffs. The architecture documents model characteristics (parameter count, quantization level, context window, inference speed) and helps developers choose between models like Mistral, Llama 2, Phi, and others. The repository includes a model download utility (npx node-llama-cpp pull) that surfaces model options and their specifications, enabling informed selection without trial-and-error.
Provides explicit educational guidance on model selection and quantization through DOWNLOAD.md and Model Management documentation, teaching the reasoning behind choices rather than prescribing a single model. The repository includes concrete examples of different models (Mistral, Llama 2, Phi) used across modules.
More transparent and educational than cloud APIs that abstract model selection, and more practical than academic papers on quantization; lacks automated benchmarking but enables informed decision-making through clear documentation.
temperature-and-sampling-parameter-control
Medium confidenceExposes temperature, top-p, and other sampling parameters to control LLM output randomness and creativity. The architecture allows developers to tune these parameters per request, enabling different behaviors for different tasks (e.g., low temperature for deterministic code generation, high temperature for creative writing). Parameters are passed to the node-llama-cpp inference engine, which uses them to control the probability distribution over next tokens during generation.
Exposes sampling parameters directly through node-llama-cpp API, with examples (think, coding modules) showing how different parameters affect output for reasoning vs code generation tasks. The Advanced Topics documentation explains parameter tuning strategies.
More transparent and controllable than cloud APIs that abstract sampling, enabling fine-grained tuning; requires more manual experimentation than APIs with built-in optimization.
token-counting-and-context-window-management
Medium confidenceProvides utilities and patterns for tracking token usage and managing context window constraints to prevent exceeding model limits. The architecture includes token counting logic (either through node-llama-cpp's built-in tokenizer or external libraries) that estimates prompt and response token counts before generation. Developers can use this information to implement context windowing strategies (e.g., dropping oldest messages when approaching limit) or warn users when approaching capacity.
Addresses token management as an explicit concern in the learning path, with Advanced Topics documentation on token counting and cost optimization. Shows how to integrate token counting into agent loops to prevent context overflow.
More transparent than cloud APIs that abstract token counting, enabling developers to understand and optimize token usage; requires manual implementation of windowing strategies, unlike some frameworks with built-in context management.
Capabilities are decomposed by AI analysis. Each maps to specific user intents and improves with match feedback.
Related Artifactssharing capabilities
Artifacts that share capabilities with ai-agents-from-scratch, ranked by overlap. Discovered automatically through the match graph.
LMQL
LMQL is a query language for large language...
gpt4all
A chatbot trained on a massive collection of clean assistant data including code, stories and dialogue.
Private GPT
Tool for private interaction with your documents
outlines
Structured Outputs
Kilo Code
Open-source AI coding assistant for VS Code, JetBrains, and the CLI. [#opensource](https://github.com/Kilo-Org/kilocode)
LMQL
LMQL is a query language for large language models.
Best For
- ✓developers building privacy-sensitive AI agents
- ✓educators teaching LLM fundamentals without cloud dependencies
- ✓teams prototyping agents with cost constraints
- ✓researchers experimenting with model quantization and inference optimization
- ✓developers learning agent architecture from first principles
- ✓teams building agents with local LLMs that lack native function calling
- ✓educators demonstrating tool use patterns without cloud API dependencies
- ✓builders prototyping custom tool ecosystems for specialized domains
Known Limitations
- ⚠Inference speed depends on local hardware; CPU-only inference is 10-50x slower than GPU-accelerated cloud APIs
- ⚠Memory footprint scales with model size; 7B parameter models require ~8GB RAM minimum
- ⚠No built-in batching or request queuing — single-threaded inference per model instance
- ⚠Platform-specific binary compilation adds ~5-10 minutes to npm install on first setup
- ⚠Limited to GGUF quantized models; cannot load full-precision or other formats without conversion
- ⚠Parsing function calls from text is fragile — LLM may generate malformed JSON or hallucinate function names
Requirements
Input / Output
UnfragileRank
UnfragileRank is computed from adoption signals, documentation quality, ecosystem connectivity, match graph feedback, and freshness. No artifact can pay for a higher rank.
Repository Details
Last commit: Apr 19, 2026
About
Demystify AI agents by building them yourself. Local LLMs, no black boxes, real understanding of function calling, memory, and ReAct patterns.
Categories
Alternatives to ai-agents-from-scratch
Are you the builder of ai-agents-from-scratch?
Claim this artifact to get a verified badge, access match analytics, see which intents users search for, and manage your listing.
Get the weekly brief
New tools, rising stars, and what's actually worth your time. No spam.
Data Sources
Looking for something else?
Search →