Home
Back to Overview
GitHub Tutorial
View Code & Lessons

AI Agents Framework Tutorial

Build a lightweight, educational version of LangChain.js

Learn to rebuild LangChain's core patterns with clear, educational code. Understand what frameworks are actually doing, making you far more effective at using them.

What You'll Build

Core Concepts

  • ✓ Runnable interface (LangChain's composability pattern)
  • ✓ Message types (structured conversations)
  • ✓ LLM wrappers (model integration)
  • ✓ Chains (composing operations)
  • ✓ Agents (decision-making loops)
  • ✓ Graphs (LangGraph state machines)

What Makes This Different

  • • LangChain-compatible API
  • • Simpler implementations
  • • Educational focus
  • • Real, working code
  • • Understand frameworks deeply
  • • Use LangChain confidently

Build it yourself. Understand it deeply. Use LangChain confidently.

Before You Start: Why This Tutorial Exists

You've just built AI agents with node-llama-cpp. You know how to call LLMs, format prompts, parse responses, and create agent loops. That's awesome—you understand the fundamentals!

But you probably noticed some friction:

  • • Copy-pasting prompt formatting everywhere
  • • Manually building message arrays each time
  • • Hard to test individual components
  • • Difficult to swap out models or reuse patterns
  • • Agent code that works but feels messy

This tutorial fixes those problems. Instead of jumping straight into LangChain's complex codebase, you'll rebuild its core patterns yourself with clear, educational code. You'll transform the script-style code you wrote into clean, composable abstractions.

The Approach:

1

Start with problems you've encountered

2

Build the abstraction that solves it

3

See how it connects to LangChain's API

4

Understand frameworks deeply

Part 1: From Scripts to Abstractions

Transform the patterns you already use into reusable components.

Agent code getting messy?

→ Build the Runnable pattern for composability

Message formatting tedious?

→ Create Message types for structure

Model switching hard?

→ Design LLM wrappers for flexibility

Managing conversation state?

→ Implement Context for memory

Lessons:

01
Runnable
The composability pattern ← Start here
02
Messages
Structured conversation data
03
LLM Wrapper
Model abstraction layer
04
Context
Conversation state management

Part 2: Composition

Dive deeper into prompt engineering and chain complex operations together.

Copy-pasting prompts everywhere?

→ Build reusable PromptTemplates with variables

Need structured LLM outputs?

→ Create OutputParsers for reliable data extraction

Repeating prompt + LLM patterns?

→ Design LLMChain to compose operations

Want to chain operations together?

→ Use piping to connect Runnables

Lessons:

01
Prompts
Template-based prompt engineering
02
Parsers
Structured output extraction
03
LLM Chain
Composing prompts with models - Coming soon
04
Piping
Building data transformation pipelines - Coming soon
05
Memory
Persistent conversation history - Coming soon

Part 3: Agents [Coming Soon]

Agents and tools for decision-making and action execution.

01
Tools
Coming soon
02
Tool Executor
Coming soon
03
Simple Agent
Coming soon
04
ReAct Agent
Coming soon
05
Structured Agent
Coming soon

Part 4: Graphs [Coming Soon]

State machines and workflows for complex agent orchestration.

01
State Basics
Coming soon
02
Channels
Coming soon
03
Conditional Edges
Coming soon
04
Executor
Coming soon
05
Checkpointing
Coming soon
06
Agent Graph
Coming soon

Capstone Projects

Complete these capstone projects to solidify your learning:

Smart Email Classifier

After Part 1

Research Agent

Coming soon

Task Automation

Coming soon

Approval Workflow

Coming soon

How to Use This Tutorial

1️⃣
Start with Part 1
Work sequentially
2️⃣
Read Lessons
Markdown format
3️⃣
Complete Exercises
Practice hands-on
4️⃣
Check Solutions
When stuck
5️⃣
Build Projects
Apply knowledge

Happy learning! 🚀