LangChain + LangGraph — Build và debug model flow như một state machine
Hướng dẫn TypeScript dùng LangChain cho prompt và structured output, LangGraph cho state, branch và loop; rồi debug từng node bằng streaming, trace, breakpoint và time travel.
Filter/Tag
38 entries
Hướng dẫn TypeScript dùng LangChain cho prompt và structured output, LangGraph cho state, branch và loop; rồi debug từng node bằng streaming, trace, breakpoint và time travel.
A bilingual, hype-free guide for frontend developers in the AI era: what actually changed, the 2026 web tech landscape, new ways of working with agents, the skills that rise vs fade, and a concrete 30/60/90 survival playbook.
Từ mindset đúng (agent là cộng sự, không phải autocomplete), công thức CARET cho prompt, chuyển spec thành task, đến 5 patterns thực chiến và anti-patterns khi làm việc với coding agent.
Hệ thống config files điều khiển coding agent (Claude Code + Cursor): CLAUDE.md, settings.json, .mdc rules, MCP servers, commands, sub-agents — ý nghĩa, cách dùng, và setup thực tế.
Tại sao 1 agent không đủ cho dự án lớn, cách dùng Orchestrator pattern với 6 kiểu điều phối (fan-out, validation chain, specialist routing...), setup thực tế, và anti-patterns cần tránh.
Case study end-to-end: implement reading progress indicator cho blog Astro. Đi qua đủ 4 pha (Plan → Scaffold → Build → Polish), dùng Rules + Skills + Sub-agent, review AI output, debug 1 edge case thật. Khép lại series Coding Agents.
Mổ xẻ kiến trúc bên trong 1 AI agent: agent loop, tool use mechanics, 3 tầng memory, planning patterns (ReAct, Plan-and-Execute, Tree of Thoughts), multi-agent system, và 7 cạm bẫy phổ biến.
Vì sao hallucination là bản chất của next-token prediction chứ không phải bug: 4 cơ chế, taxonomy 6 dạng dev gặp, mô hình phòng thủ Swiss-cheese 6 tầng, vụ thật (luật sư, Air Canada, slopsquatting), và cân phòng thủ theo rủi ro.
Vì sao base model "biết mọi thứ nhưng vô kỷ luật", cách alignment thuần hoá nó (RLHF, Constitutional AI, DPO), jailbreak & prompt injection (= SQL injection cho ngôn ngữ tự nhiên), vụ thật, và defense-in-depth cho app của bạn.
Token là đơn vị compression, đơn vị suy nghĩ, và đơn vị tính tiền của LLM. Bài đi sâu BPE tokenization, tiếng Việt đắt 2-3x, thinking tokens, và framework chọn subscription vs API.
Customization stack 5 tầng: Rules, Skills, MCP, Sub-agents, Hooks. Chiến lược progressive customization, khi nào team-share và khi nào giữ personal, và cách maintain để config không biến thành technical debt sau 6 tháng.
Workflow 4 pha để ship feature với AI agent: từ ticket mơ hồ đến PR merge. Nguyên tắc decomposition, spec-first, vertical slice, và những prompt template dùng đi dùng lại cho scaffold + review.
Cấu trúc debug với AI: reproduce trước, hypothesis sau, fix cuối. Kỹ thuật minimal repro, git bisect với AI, stacktrace decoding, heisenbug hunting, và lý do vì sao AI thường fix sai khi bạn chưa verify cause.
Fine-tuning vs prompt vs RAG — quyết định framework. 4 loại fine-tune (full, LoRA, QLoRA, instruction tuning), data preparation, cost analysis, và 6 cạm bẫy phổ biến (overfitting, catastrophic forgetting).
Hành trình 70 năm của AI qua 7 era: symbolic AI, expert systems, statistical learning, deep learning, transformer, LLM, đến reasoning + agentic. Mỗi era có winter và breakthrough — bài học cho dev hôm nay.
Mọi đòn bẩy chi phí LLM quy về 3 nhóm: đừng gọi model, gọi nhẹ hơn, rẻ hơn mỗi token. 10 pattern thực chiến (prompt cache, semantic cache, routing, distillation, batch, quantization, self-host), cost math, và ROI framework.
7 dimension đánh giá model LLM, so sánh thực chiến Claude/GPT/Gemini/Llama family đầu 2026, thinking model vs regular, open-source vs proprietary, và decision framework để chọn model đúng task theo chi phí + chất lượng.
3 tầng của prompt (system/user/assistant), 6 nguyên tắc viết prompt hiệu quả, sampling parameters (temperature, top-p, top-k, stopping criteria), personalization qua system prompt, multi-turn strategy, và template tái dùng cho dev.
4 cơ chế kỹ thuật mà dev nào dùng LLM cũng nên hiểu sâu: BPE tokenization step-by-step, math của temperature scaling, top-p (nucleus) vs top-k sampling, sampling pipeline hoàn chỉnh, và parameter cheatsheet.
Giải thích từ first principles cách một model chỉ hiểu token lại "thấy" được ảnh, "nghe" được tiếng: patch tokenization, CLIP, projection layer, 3 kiểu fusion, dataflow, trade-off, ví dụ production thật, và khi nào KHÔNG nên dùng.
Tổng quan ecosystem LLM open weight 2026: 5 family chính, công cụ chạy local (Ollama, LM Studio, vLLM, llama.cpp), quantization formats (GGUF/GPTQ/AWQ), license gotcha, và hardware budget từ laptop đến cluster.
Mổ xẻ RAG: indexing pipeline, embeddings, vector DB, chunking strategies, retrieval (dense/sparse/hybrid), reranking, 8 failure mode phổ biến, và quyết định khi nào dùng RAG vs long context vs fine-tuning.
Review code AI sinh ra sao cho không bị lừa, self-review trước PR, test pyramid với AI, generate test không phải generate coverage giả, flaky test hunting, và checklist review chi tiết dùng được ngay.
Chiến lược dùng AI để onboard codebase lớn: bird-eye view trước, entry-point mapping, dependency tracing, git history archaeology. So sánh với đọc code tuần tự và grep thủ công — thứ đã cũ từ 2023.
Mổ xẻ embedding từ Word2Vec đến text-embedding-3: hình học của ý nghĩa, distance metrics, evaluation MTEB, visualization (PCA/t-SNE/UMAP), multimodal CLIP, và 6 cạm bẫy practical (anisotropy, drift, dimensionality).
Coding agent khác autocomplete ở chỗ nào, agent loop (observe-think-act) hoạt động ra sao, 4 level autonomy, khi nào để agent tự chạy vs khi nào human-in-the-loop, và những sai lầm của dev mới chuyển sang workflow agent-based.
Tìm hiểu về MCP - chuẩn kết nối mở cho AI Agents như Claude, Cursor, Copilot: transport layer, JSON-RPC 2.0, primitives và sơ đồ kiến trúc đầy đủ.
ReAct, Reflection, and Planning for LLM agents — when to use each, guardrails against runaway loops, and links to tool use and orchestration.
How LLM function calling bridges models to the world: JSON Schema tools, the request→execute→result loop, parallel calls, validation, MCP, and security.
A senior engineer framework for model selection — capability tiers, context, modality, cost, privacy, tool use — plus routing, cascades, and why benchmarks lie.
Why eval is the hardest part of shipping agents — golden datasets, offline vs online metrics, LLM-as-judge rubrics, human agreement, and regression in CI.
When to prompt, retrieve, or fine-tune: knowledge vs behavior, data needs, cost, privacy, SFT/LoRA/DPO — and why most teams start with prompt + RAG.
How senior engineers pack system prompts, tools, history, RAG, and output reserve into a fixed context window — and manage memory when the budget breaks.
EOS tokens, max_tokens, stop sequences, and finish_reason handling for production LLM agents — streaming, truncation, and runaway cost guards.
Agent prompt design: messages/roles, personas, few-shot trade-offs, CoT vs reasoning models, JSON schemas, templates, injection guards, iteration.
How LLMs turn logits into tokens — temperature, top_p, top_k, penalties, seeds — and why agent builders tune sampling differently for tool calls vs brainstorming.
Tokens are the atomic unit of LLM memory and cost. Learn subword tokenization, context window math, and agent budgeting before you ship.
A bilingual guide on the developer mindset for working effectively with AI. From crafting prompts to defining rules and skills — the thinking framework that separates power users from casual prompters.