Kế Hoạch Xây Dựng Khoá Học AI Agents
Target: Junior JS/TS Developer | Tool: LangChain.js + LangGraph.js | LLM:
gemini-2.5-flash
Thông Số Cốt Lõi
| Thông số | Giá trị |
|---|---|
| Đối tượng | Junior Dev có kinh nghiệm JS/TS web |
| Công cụ demo | LangChain.js + LangGraph.js (JS/TS native) |
| LLM backend | gemini-2.5-flash — tiết kiệm, đủ mạnh |
| Approach | Full Course, build tuần tự |
| Format | Docs reference trên Docusaurus |
| Tổng bài dự kiến | ~34 bài (Phase 0 đã có nội dung riêng) |
| Timeline ước tính | 4–5 tháng (2 bài/tuần) |
Quy Tắc Bám Sát Tài Liệu
Mỗi bài học PHẢI được viết dựa trực tiếp vào file nguồn trong:
sources/documentations/docs.langchain.com/oss/javascript/
langchain/— LangChain.js core (tools, models, memory, structured output...)langgraph/— LangGraph.js (agents, workflows, multi-agent, persistence...)Demo code BẮT BUỘC dùng
gemini-2.5-flash(thayChatAnthropictrong nguồn gốc).
Kiến Trúc Khoá Học
Phase 1: AI Agents 101
Thời gian: 5 tuần | Số bài: 9
Bài 1.1 — Chatbot vs AI Agent
- Concept: Workflow (cố định) vs Agent (động), 5 Agentic Patterns
- LLM Augmentations: Tool calling, Structured output, Memory
- Nguồn tài liệu:
langgraph/workflows-agents.md— định nghĩa chính thức, sơ đồ patternslangchain/agents.md— agent architecture tổng quan
- Đã tạo:
docs/ai-agents/01-chatbot-vs-agent.md - Độ ưu tiên: Critical
Bài 1.2 — Agent Loop Trong Code
- Concept: StateGraph, Node, Edge, MessagesValue, ReducedValue
- Demo JS: Graph API + Functional API với
gemini-2.5-flash - Nguồn tài liệu:
langgraph/quickstart.md— NGUỒN CHÍNH (Graph API + Functional API step-by-step)langgraph/thinking-in-langgraph.md— mental model Node/State/Edgelanggraph/workflows-agents.md— ToolNode pattern
- Đã tạo:
docs/ai-agents/02-agent-loop-in-code.md - Độ ưu tiên: Critical
Bài 1.3 — Tools: Công Cụ Của Agent
- Concept: Tool schema (Zod), tool binding, tool routing
- Demo JS: Custom tool, built-in tools (search, calculator)
- Nguồn tài liệu:
langchain/tools.md— NGUỒN CHÍNH (tool() API, schema, ToolNode)langgraph/workflows-agents.md— ToolNode prebuilt
- Độ ưu tiên: Critical
Bài 1.4 — Messages: Ngôn Ngữ Của Agent
- Concept: HumanMessage, AIMessage, ToolMessage, SystemMessage, message roles
- Demo JS: Message types, trimming, filtering
- Nguồn tài liệu:
langchain/messages.md— NGUỒN CHÍNH (toàn bộ message types và usage)
- Độ ưu tiên: Critical
Bài 1.5 — Models: Chọn Và Cấu Hình LLM
- Concept: Chat models, model parameters (temperature, max_tokens), provider switching
- Demo JS:
ChatGoogleGenerativeAIvớigemini-2.5-flash, so sánh providers - Nguồn tài liệu:
langchain/models.md— NGUỒN CHÍNH (providers, parameters, streaming, structured output)langchain/install.md— package dependencies
- Độ ưu tiên: Critical
Bài 1.6 — Structured Output: Trả Lời Đúng Format
- Concept:
withStructuredOutput(), Zod schema, JSON mode, tool-based extraction - Demo JS: TypeScript type-safe output từ LLM
- Nguồn tài liệu:
langchain/structured-output.md— NGUỒN CHÍNH (withStructuredOutput, schema binding)
- Độ ưu tiên: Critical
Bài 1.7 — Short-term Memory: Bộ Nhớ Trong Một Session
- Concept: In-context memory, message history, trimming, summarization
- Demo JS: ConversationChain với message history
- Nguồn tài liệu:
langchain/short-term-memory.md— NGUỒN CHÍNH (buffer, summary, token limit strategies)langgraph/add-memory.md— memory trong LangGraph graph
- Độ ưu tiên: Important
Bài 1.8 — Long-term Memory: Bộ Nhớ Cho Nhiều Session
- Concept: External storage, semantic memory, episodic memory, stores
- Demo JS: LangGraph Stores + vector memory
- Nguồn tài liệu:
langchain/long-term-memory.md— NGUỒN CHÍNH (overview long-term memory types)langgraph/stores.md— LangGraph Store APIlanggraph/add-memory.md— thêm memory vào agent
- Đã tạo:
docs/ai-agents/08-long-term-memory.md - Độ ưu tiên: Important
Bài 1.9 — Project: Research Assistant
- Project: Agent search web + summarize + trả lời câu hỏi
- Stack: LangChain.js +
gemini-2.5-flash+ Tavily search tool - Nguồn tài liệu:
langchain/tools.md— search tool integrationlanggraph/quickstart.md— agent setuplangchain/streaming.md— streaming response
- Đã tạo:
docs/ai-agents/09-project-research-assistant.md - Độ ưu tiên: Critical (Capstone Phase 1)
Phase 2: Agentic Patterns
Thời gian: 5 tuần | Số bài: 9
Bài 2.1 — Streaming: Real-time Agent Response
- Concept: Token streaming, event streaming, StreamingTextResponse
- Demo JS: Agent phát stream từng token ra giao diện
- Nguồn tài liệu:
langchain/streaming.md— NGUỒN CHÍNH (stream, streamEvents)langgraph/streaming.md— streaming trong LangGraphlanggraph/event-streaming.md— event types chi tiết
- Độ ưu tiên: Critical
Bài 2.2 — Retrieval-Augmented Generation (RAG)
- Concept: Retrieval-Augmented Generation, indexing pipeline, retrieval strategies
- Demo JS: RAG pipeline đầy đủ từ document đến answer
- Nguồn tài liệu:
langchain/rag.md— NGUỒN CHÍNH (naive RAG, advanced retrieval, re-ranking)langchain/retrieval.md— retriever typeslangchain/knowledge-base.md— knowledge base management
- Độ ưu tiên: Critical
Bài 2.3 — Agentic RAG: Agent Chủ Động Tìm Kiếm
- Concept: Agent quyết định khi nào cần retrieve, self-corrective RAG
- Demo JS: Agent với retrieval tool, iterative search
- Nguồn tài liệu:
langgraph/agentic-rag.md— NGUỒN CHÍNH (agentic RAG patterns)
- Độ ưu tiên: Important
Bài 2.4 — Context Engineering: Tối Ưu Prompt
- Concept: Context window management, prompt compression, few-shot selection
- Demo JS: Dynamic prompt assembly, context trimming
- Nguồn tài liệu:
langchain/context-engineering.md— NGUỒN CHÍNH (38KB — rất đầy đủ)
- Độ ưu tiên: Important
Bài 2.5 — Fault Tolerance: Khả Năng Chịu Lỗi
- Concept: Retry policies, error handling, graceful degradation
- Demo JS: Node với retry config, fallback branches
- Nguồn tài liệu:
langgraph/fault-tolerance.md— NGUỒN CHÍNH (retry, error handling trong LangGraph)
- Độ ưu tiên: Critical
Bài 2.6 — Checkpointing & Persistence
- Concept: Save/restore state, resume interrupted workflows
- Demo JS: MemorySaver, SQLite checkpointer
- Nguồn tài liệu:
langgraph/checkpointers.md— NGUỒN CHÍNH (checkpointer types, durability modes)langgraph/persistence.md— persistence overview
- Độ ưu tiên: Important
Bài 2.7 — Interrupts: Human-in-the-Loop
- Concept:
interrupt(), approval gates, resume execution - Demo JS: Agent dừng chờ user confirm trước khi thực thi
- Nguồn tài liệu:
langgraph/interrupts.md— NGUỒN CHÍNH (interrupt(), Command, resume)langchain/human-in-the-loop.md— HITL patterns
- Độ ưu tiên: Critical
Bài 2.8 — Middleware & Guardrails
- Concept: Input/output validation, prompt injection defense, PII detection
- Demo JS: Middleware chain bao quanh agent
- Nguồn tài liệu:
langchain/guardrails.md— NGUỒN CHÍNH (guardrail patterns, validation)langchain/middleware.md— middleware architecture
- Độ ưu tiên: Critical
Bài 2.9 — Project: Coding Assistant
- Project: Agent đọc file, phân tích code, suggest fix
- Stack: LangChain.js +
gemini-2.5-flash+ file system tools - Nguồn tài liệu:
langchain/tools.md— file toolslanggraph/use-graph-api.md— advanced graph patternslangchain/streaming.md— streaming output
- Độ ưu tiên: Critical (Capstone Phase 2)
Phase 3: Multi-Agent Systems
Thời gian: 4 tuần | Số bài: 8
Bài 3.1 — Multi-Agent Architecture
- Concept: Tại sao multi-agent? Context limit, specialization, parallelism
- So sánh: Single agent vs Multi-agent trade-offs
- Nguồn tài liệu:
langchain/multi-agent.md— NGUỒN CHÍNH (architecture overview)
- Độ ưu tiên: Critical
Bài 3.2 — Subgraphs: Agent Trong Agent
- Concept: Subgraph isolation, state scoping, nested workflows
- Demo JS: Agent gọi một sub-agent chuyên biệt
- Nguồn tài liệu:
langgraph/use-subgraphs.md— NGUỒN CHÍNH (subgraph patterns)
- Độ ưu tiên: Important
Bài 3.3 — Supervisor Pattern
- Concept: Orchestrator điều phối nhiều worker agents
- Demo JS: Supervisor → Research Agent + Writer Agent
- Nguồn tài liệu:
langchain/multi-agent.md— supervisor patternlanggraph/workflows-agents.md— orchestrator-worker diagramlanggraph/use-graph-api.md— Send API cho parallel workers
- Độ ưu tiên: Critical