Bạn không hề tụt lại. Phần lớn những thứ này đã hai năm tuổi.You are not behind. Most of this is two years old.
Model là phần dễ. Vòng lặp là của bạn.The model is the easy part. The loop is yours.
Chín khái niệm dưới đây không phải chín tính năng của model. Chúng là chín lớp hạ tầng bạn tự dựng quanh nó. Nhà cung cấp giao cho bạn một hộp: một lần gọi API, vào chữ ra chữ. Mọi thứ còn lại là phần bạn viết.These nine are not model features. They are nine layers of infrastructure you build around it. The vendor hands you one box: a single API call, text in, text out. Everything else is code you write.
nét đứt = quyết định lúc chạy, không phải luồng cố địnhdashed = decided at runtime, not a fixed path
Chọn cái nàoPick one
Đọc mục này trước phần tra cứu chi tiết. Đây là thứ bạn dùng hằng ngày.Read this before the reference cards. This is the part you use daily.
Trước hết: khi nào KHÔNG cần thứ nào cảFirst: when you need none of this
Phương án rẻ nhất là một lần gọi API, prompt viết tay, một hàm kiểm tra đầu ra, log ra stdout. Giữ nguyên nếu tất cả các điều sau đúng:The cheapest option is one API call, a hand-written prompt, one output check, logs to stdout. Stay there if all of these hold:
Việc gói gọn trong một lượt: tóm tắt, phân loại, trích xuất, viết lại.The work fits in one turn: summarise, classify, extract, rewrite.
Bạn vạch được các bước ra giấy — vậy thì viết code chạy quy trình, chỉ gọi model ở nút suy luận.You can write the steps on paper — so code the process and call the model only at reasoning nodes.
Một nhà cung cấp, dưới ~1000 request/ngày, hoá đơn chưa vào top 5 chi phí.One provider, under ~1000 requests/day, the bill is not in your top five costs.
Đầu vào đến từ nhân viên nội bộ, không phải từ Internet.Input comes from internal staff, not from the Internet.
Mỗi lớp thêm vào là một khoản thuế vĩnh viễn. Thêm khi có triệu chứng, không thêm vì đọc được trên mạng — mỗi card bên dưới đều ghi rõ triệu chứng cần chờ.Every added layer is a permanent tax. Add on symptoms, not on trends — every card below names the symptom to wait for.
Việc xong trong một lượt gọi model?Work finishes in one model call?
DỪNG — không cần gì thêmSTOP — nothing else needed
Số bước không biết trước, không vạch được ra giấy?Step count unknown, cannot be written on paper?
Thứ tự triển khai thực tế cho một đội nhỏ: 06 → 08 → 01 → 05 → 07 → 04 → 02 → 03 → 09. Eval và trace đi trước, vì thiếu chúng thì mọi lớp sau đều được đánh giá bằng cảm giác.Realistic build order for a small team: 06 → 08 → 01 → 05 → 07 → 04 → 02 → 03 → 09. Evals and traces first, because without them every later layer is judged by feel.
Chín khái niệmThe nine
Màu mã hoá họ khái niệm: vòng lặp, đường ống, vận hành. Quy ước ở cuối trang.Colour encodes the family: loop, plumbing, operations. Key at the foot of the page.
01
Agentic Loops
VÒNG LẶPLOOP
Code của bạn gọi model nhiều lần cho một nhiệm vụ, cho tới khi xong — không phải gọi một lần.Your code calls the model repeatedly on one task until it is done — not once.
DÙNG CHOGOOD FOR
Sửa bug qua nhiều fileMulti-file bug fixing
Nghiên cứu tổng hợp nhiều nguồnMulti-source synthesis
Xử lý ticket cần tra nhiều nơiTickets needing several lookups
ĐƯỢCGAIN
Làm được việc không vạch sẵn bướcHandles unplannable work
Tool hỏng thành observation, model thử cách khácFailures become observations; it retries differently
Thêm năng lực = thêm toolNew capability = new tool
MẤTLOSE
Chi phí và thời gian không dự đoán đượcUnpredictable cost and runtime
Lỗi vòng 2 được tin đến vòng 12A turn-2 error is trusted at turn 12
Vòng lặp chết; hành động phụ không hoàn tác đượcDeath loops; side effects cannot be undone
ĐÁNH ĐỔITRADE-OFF
Chọn vòng lặp agentic là đổi tính dự đoán được về chi phí và thời gian chạy lấy khả năng xử lý những việc bạn không thể vạch sẵn các bước.Choosing an agentic loop trades predictable cost and runtime for the ability to handle work whose steps you cannot plan in advance.
DẤU HIỆUSYMPTOM Bạn đang phải bấm “chạy tiếp” cho model bằng tay nhiều lần cho cùng một việc.You are manually clicking “keep going” for the model, repeatedly, on the same task.
02
MCP
ĐƯỜNG ỐNGPLUMBING
Một giao diện chuẩn cho tool: viết server một lần, mọi client dùng được. M × N thành M + N.One standard tool interface: write the server once, any client uses it. M × N becomes M + N.
DÙNG CHOGOOD FOR
Tool nội bộ dùng chung nhiều độiShared internal tooling
Nhiều bề mặt AI: IDE, chatbot, agent nềnSeveral AI surfaces: IDE, chatbot, agent
Nhà cung cấp SaaS ship một server thay vì N pluginA SaaS vendor shipping one server, not N plugins
ĐƯỢCGAIN
4 app × 5 tool: 20 lần tích hợp còn 94 apps × 5 tools: 20 integrations down to 9
Đổi client mà không viết lại toolSwap clients without rewriting tools
Khoá và quyền tập trung một chỗKeys and permissions centralised
MẤTLOSE
Thêm một tiến trình phải nuôi; nó chết là tool biến mấtOne more process; if it dies, tools vanish
Bề mặt prompt injection mới từ server ngoàiA new injection surface from external servers
ĐÁNH ĐỔITRADE-OFF
Chọn MCP là đổi việc tối ưu từng tích hợp riêng lẻ lấy một giao diện chuẩn dùng lại được cho mọi client.Choosing MCP trades per-integration optimisation for one standard interface every client can reuse.
DẤU HIỆUSYMPTOM Bạn vừa viết đoạn code gọi cùng một API lần thứ ba cho ba app khác nhau.You just wrote code calling the same API for the third time, for a third app.
03
Subagents
VÒNG LẶPLOOP
Việc phụ giao cho agent con có ngữ cảnh riêng; chỉ câu trả lời quay về, không phải đống lộn xộn.Side work goes to a child agent with its own context; only the answer comes back, not the mess.
Nghiên cứu song song nhiều chủ đềParallel research on several topics
Kiểm định chéo bằng ngữ cảnh sạchCross-checking from a clean context
ĐƯỢCGAIN
Ngữ cảnh chính giữ sạchThe main context stays clean
Chạy song song, giảm thời gian chờParallelism cuts wall time
Việc cơ học đi model rẻMechanical work goes to a cheap model
MẤTLOSE
Tổng token thường TĂNG, không giảmTotal tokens usually go UP
Tóm tắt sai lan đi không dấu vếtA wrong summary spreads with no trail
Debug N cây lồng nhau thay vì mộtN nested trees to debug instead of one
ĐÁNH ĐỔITRADE-OFF
Chọn subagent là đổi khả năng nhìn xuyên suốt một mạch suy luận duy nhất lấy ngữ cảnh sạch và chi phí gọn ở agent chính.Choosing subagents trades visibility into one continuous chain of reasoning for a clean context and a lean main agent.
DẤU HIỆUSYMPTOM Prompt chính phình lên vì phải nhét kết quả trung gian của một việc phụ.Your main prompt is bloating with the intermediate results of a side task.
04
AI Gateway
ĐƯỜNG ỐNGPLUMBING
Một cửa đến mọi model: một khoá, một hoá đơn, một chỗ để đổi nhà cung cấp.One door to every model: one key, one bill, one place to switch providers.
DÙNG CHOGOOD FOR
Nhiều đội chung ngân sách LLMSeveral teams sharing an LLM budget
Chịu lỗi khi một nhà cung cấp sậpSurviving a provider outage
A/B hai model trên traffic thậtA/B two models on real traffic
ĐƯỢCGAIN
Đổi model = một dòng cấu hìnhSwitching models = one config line
Hạn mức chi tiêu theo độiPer-team spend caps
Thu hồi khoá không cần deployRotate keys without a deploy
MẤTLOSE
+10–50 ms và một điểm chết mới+10–50 ms and a new failure point
Tính năng riêng nhà cung cấp bị san phẳngProvider-specific features flattened away
Prompt vẫn phải chỉnh lại cho model mớiPrompts still need retuning per model
ĐÁNH ĐỔITRADE-OFF
Chọn AI gateway là đổi một chặng mạng thêm và một điểm phụ thuộc mới lấy quyền đổi nhà cung cấp mà không phải deploy lại.Choosing an AI gateway trades an extra network hop and a new dependency for the right to switch providers without redeploying.
DẤU HIỆUSYMPTOM Đổi model phải sửa code và deploy lại.Switching models requires a code change and a deploy.
05
Inference Cost
VẬN HÀNHOPERATIONS
Tính tiền theo token, không theo lượt gọi. Cache phần đầu prompt, không cache câu trả lời.Billed in tokens, not calls. Cache the prompt prefix, not the answer.
DÙNG CHOGOOD FOR
System prompt dài lặp mọi lượtLong system prompts repeated every turn
Agent nhiều tool: schema là khối tĩnh lớn nhấtTool-heavy agents: schemas are the biggest static block
Hỏi 20 câu trên cùng một tài liệuTwenty questions over one document
ĐƯỢCGAIN
~90% chi phí phần prefix~90% off the prefix portion
Token đầu tiên về nhanh hơnFaster time to first token
Không đổi model, chỉ đổi thứ tựNo model change, just ordering
MẤTLOSE
Một dấu thời gian ở đầu là mất sạch cacheOne timestamp at the front wipes it all
Traffic thưa: phí ghi cache lớn hơn tiết kiệmSparse traffic: write fees exceed savings
Không giúp gì cho token đầu raDoes nothing for output tokens
ĐÁNH ĐỔITRADE-OFF
Chọn cache prefix là đổi sự tự do sắp xếp lại prompt lấy một hoá đơn rẻ hơn nhiều lần.Choosing prefix caching trades the freedom to rearrange your prompt for a bill several times smaller.
DẤU HIỆUSYMPTOM Hoá đơn tăng nhanh hơn số người dùng.The bill is growing faster than your user count.
06
Evals
VẬN HÀNHOPERATIONS
Một golden set gác cửa release. Không có điểm số thì không có tiến bộ.A golden set gates the ship. No score, no improvement.
DÙNG CHOGOOD FOR
Trước mỗi lần sửa promptBefore every prompt edit
So sánh model mới hoặc model rẻ hơnComparing a new or cheaper model
Bắt regression sau khi đổi RAG/toolCatching regressions after RAG/tool changes
ĐƯỢCGAIN
Tranh luận chủ quan thành con sốSubjective argument becomes a number
Bắt lỗi trước người dùngCatch regressions before users do
20–50 case đã đủ tín hiệu tốt20–50 cases already give good signal
MẤTLOSE
Bộ mẫu tốn công người và sẽ mốcThe set takes human effort and goes stale
Model chấm (judge) cũng thiên vịModel judges are biased too
Điểm tổng che nhóm 5% hỏngAggregate scores hide the failing 5%
ĐÁNH ĐỔITRADE-OFF
Chọn eval là đổi tốc độ ship hôm nay lấy quyền biết chắc ngày mai mình không làm hỏng thứ đang chạy.Choosing evals trades shipping speed today for the certainty tomorrow that you did not break what already worked.
DẤU HIỆUSYMPTOM Bạn không biết bản mới tốt hơn hay tệ hơn bản cũ, chỉ “cảm thấy”.You do not know whether the new version is better or worse; you only have a feeling.
07
Guardrails
VẬN HÀNHOPERATIONS
Hai bộ lọc, không phải một: prompt injection chặn ở cửa vào, bí mật chặn ở cửa ra.Two filters, not one: injection blocked on the way in, secrets on the way out.
DÙNG CHOGOOD FOR
Chatbot công khaiPublic chatbots
Agent đọc email, web, PDF từ ngoàiAgents reading external mail, web, PDFs
Agent có tool ghi/xoáAgents with write or delete tools
ĐƯỢCGAIN
Chặn loại sự cố một lần là lên báoBlocks the front-page class of incident
Cửa ra bắt cả lỗi vô tình của chính bạnOutbound catches your own accidents too
Log cho biết người ta thử làm gìLogs show what people actually attempt
MẤTLOSE
Chặn nhầm người dùng hợp lệFalse positives block real users
Độ trễ và chi phí trên mọi requestLatency and cost on every request
Cảm giác an toàn giả; không thay được phân quyềnFalse confidence; not a substitute for permissions
ĐÁNH ĐỔITRADE-OFF
Chọn guardrail là đổi một phần tỉ lệ chấp nhận đúng (và chút độ trễ) lấy việc không bao giờ phải xin lỗi vì một lần rò rỉ.Choosing guardrails trades a slice of your true-accept rate (and a little latency) for never having to apologise for a leak.
DẤU HIỆUSYMPTOM Có ô nhập liệu tự do đi thẳng vào prompt, hoặc output đi thẳng ra ngoài.A free-text field goes straight into a prompt, or output goes straight out.
08
Observability
VẬN HÀNHOPERATIONS
Trace, token, feedback — một id duy nhất xuyên mọi chặng, đủ để dựng lại một lần chạy.Traces, tokens, feedback — one id across every hop, enough to reconstruct a run.
DÙNG CHOGOOD FOR
Xem model quyết định gì ở vòng 4Seeing what the model decided at turn 4
Tìm chặng chậm (thường là retrieval hoặc tool)Finding the slow hop (usually retrieval or a tool)
Quy chi phí về đúng tính năng, đúng kháchAttributing cost per feature and customer
ĐƯỢCGAIN
Tìm nguyên nhân: từ ngày xuống phútRoot cause: days down to minutes
Trace bị chấm xấu thành case evalBadly-rated traces become eval cases
Khiếu nại mơ hồ thành lỗi sửa đượcVague complaints become fixable bugs
MẤTLOSE
Chi phí lưu trữ prompt/response là thậtStoring prompts and responses costs real money
Một kho chứa mọi thứ người dùng gõA store of everything users type
Sót một chặng là chuỗi đứt đúng chỗ cầnOne missed hop breaks the chain where it matters
ĐÁNH ĐỔITRADE-OFF
Chọn observability là đổi công sức chuẩn hoá và chi phí lưu trữ lấy khả năng trả lời “vì sao lần chạy này hỏng” trong vài phút thay vì vài ngày.Choosing observability trades instrumentation effort and storage cost for answering “why did this run fail” in minutes instead of days.
DẤU HIỆUSYMPTOM Người dùng báo chậm hoặc sai mà bạn không tái hiện được lần chạy đó.A user reports something slow or wrong and you cannot reproduce that run.
09
Agent Harness
VÒNG LẶPLOOP
Nhà cung cấp ship một hộp, bạn dựng phần còn lại: planner, memory, tool, state. Model chỉ là một phần.The vendor ships one box, you build the rest: planner, memory, tools, state. The model is one part of it.
DÙNG CHOGOOD FOR
Sản phẩm agent nuôi trên một nămAgent products maintained over a year
Miền có quy trình phê duyệt riêngDomains with their own approval rules
Sản phẩm mà chất lượng là lợi thếProducts where quality is the edge
ĐƯỢCGAIN
Đổi model = đổi một adapterSwitching models = swapping an adapter
Chất lượng nằm ở việc chọn ngữ cảnhQuality lives in context selection
Test được bằng model giả, không tốn tiềnTestable with a mock model, at no cost
MẤTLOSE
Vài tuần để bằng framework có sẵnWeeks to match an off-the-shelf framework
Tự viết lại retry, streaming, cắt ngữ cảnhRewriting retries, streaming, context trimming
Lỗi của bạn không Google đượcYour bugs are ungoogleable
ĐÁNH ĐỔITRADE-OFF
Chọn tự xây harness là đổi tốc độ khởi động ban đầu lấy quyền kiểm soát và khả năng thay model mà không phải xây lại sản phẩm.Building your own harness trades initial speed for control and the ability to replace the model without rebuilding the product.
DẤU HIỆUSYMPTOM Bạn muốn đổi model nhưng memory, tool, state đều nằm trong SDK của nhà cung cấp.You want to switch models but memory, tools and state all live inside the vendor SDK.
Bảng đánh đổiTrade-off table
Cột “rút lui” quan trọng hơn cột “chi phí”. Thứ dễ rút lui thì cứ thử; thứ khó rút lui phải quyết đúng ngay từ đầu.Reversibility matters more than cost. Reversible things are worth trying; irreversible ones must be decided correctly up front.
KHÁI NIỆMCONCEPT
CẦN KHINEEDED WHEN
CHI PHÍ THÊMADDED COST
HỎNG GÌ NẾU BỎ QUABREAKS WITHOUT IT
RÚT LUIREVERSIBILITY
01 Agentic Loops
Số bước không biết trướcStep count unknown
Token ×3–20 mỗi nhiệm vụTokens ×3–20 per task
Không làm được việc mởOpen-ended work impossible
DễEasy
02 MCP
≥2 client × ≥2 hệ thống≥2 clients × ≥2 systems
Một tiến trình + token schemaOne process + schema tokens
Tích hợp nhân lên M×NIntegrations multiply M×N
Trung bìnhMedium
03 Subagents
Việc phụ nén được nhiềuSide task compresses well
Tổng token tăngTotal tokens rise
Ngữ cảnh chính nghẹtMain context chokes
DễEasy
04 AI Gateway
≥2 model hoặc ≥2 đội≥2 models or ≥2 teams
+10–50 ms, một điểm chết+10–50 ms, one failure point
Đổi model = một lần releaseModel switch = a release
Trung bìnhMedium
05 Inference Cost
Hoá đơn tăng phi tuyếnBill grows non-linearly
Gần 0, chỉ tốn công sắp xếpNear zero, reordering only
Trả gấp 10 lần cần thiếtPaying 10× what you need
Rất dễVery easy
06 Evals
Từ lần sửa prompt đầu tiênFrom the first prompt change
Vài giờ người + tiền chạyHuman hours + run cost
Bay mù, regression âm thầmFlying blind, silent regressions
Rất dễVery easy
07 Guardrails
Đầu vào từ người lạInput from strangers
Độ trễ + false positiveLatency + false positives
Rò rỉ, prompt injection, sự cố lên báoLeaks, injection, front-page incident
DễEasy
08 Observability
Từ vòng lặp đầu tiênFrom the first loop
Lưu trữ + lắp xuyên suốtStorage + full instrumentation
Không debug được, không có evalNo debugging, no eval material
KhóHard
09 Agent Harness
Sản phẩm sống > 1 nămProduct lives > 1 year
Vài tuần kỹ sưWeeks of engineering
Lock-in vào SDK nhà cung cấpLock-in to a vendor SDK
KhóHard
← vuốt ngang để xem hết bảng← swipe to see the full table
Anti-patterns
Những sai lầm hay gặp nhất, kèm cách sửa.The most common mistakes, with the fix.
SAI LẦMMISTAKE
VÌ SAO SAIWHY IT IS WRONG
SỬA THẾ NÀOFIX
Vòng lặp không có trầnA loop with no caps
Chi phí và thời gian không có đáy; lặp chết là chuyện thườngCost and duration have no floor; death loops are normal
Ba trần: vòng, token, giây. Thêm phát hiện lặp bằng hash tool callThree caps: turns, tokens, seconds. Plus repetition detection by hashing tool calls
Dùng agentic loop cho quy trình cố địnhAgentic loop for a fixed process
Trả token và sự bất định để mua thứ một câu if đã làm đượcPaying tokens and uncertainty for what an if already did
Vạch bước ra giấy; vạch được thì viết codeWrite the steps on paper; if you can, code them
Dựng MCP server cho một appAn MCP server for one app
M+N chỉ thắng khi cả hai > 1M+N only wins when both exceed 1
Viết tool trực tiếp; đợi client thứ haiWrite tools directly; wait for the second client
Dùng subagent để tiết kiệm tiềnSubagents to save money
Subagent làm tổng token tăng; nó tiết kiệm ngữ cảnhSubagents raise total tokens; they save context
Dùng khi cần nén nhiều thành ít; muốn rẻ thì xem 05Use for many-to-few compression; for cost see 05
Chèn thời gian ở đầu system promptA timestamp at the top of the system prompt
Huỷ 100% cache prefix, mọi request thành missDestroys 100% of prefix caching; every request misses
Đẩy mọi thứ động xuống cuối; đo tỷ lệ cache hitPush dynamic content to the end; measure the hit rate
Cache câu trả lời thay vì cache prefixCaching responses instead of prefixes
Trả đáp án cũ cho ngữ cảnh mới; sai lặng lẽStale answers for new contexts; fails silently
Cache phần đầu prompt, để model vẫn suy luận lạiCache the prefix; let the model reason afresh
Chỉ nhìn điểm tổng của evalReading only the aggregate eval score
95% che mất việc 5% hỏng nằm ở nhóm khách quan trọng95% hides that the failing 5% is your key segment
Xem từng case hỏng; phân nhóm điểm theo loại người dùngRead failing cases; segment scores by user type
Chỉ đặt guardrail ở cửa vàoGuardrails only inbound
Rò khoá API và PII xảy ra ở cửa raKey and PII leaks happen outbound
Hai chiều; làm cửa ra trước nếu chỉ làm được mộtBoth directions; do outbound first if only one
Coi guardrail là phân quyềnTreating guardrails as permissions
Bộ lọc văn bản không ngăn tool có quyền xoá DBA text filter cannot stop a tool that drops the database
Giới hạn quyền ở tầng hệ thống trướcConstrain permissions at the system level first
Lắp observability sau khi xongAdding observability at the end
Phải sờ lại mọi hàm; luôn sót một chặngYou touch every function and still miss a hop
Sinh trace_id từ ngày đầuGenerate trace_id from day one
Thêm cả chín lớp cùng lúcAdding all nine layers at once
Chín điểm hỏng mới, không cái nào được hiểu kỹNine new failure points, none understood
Thêm theo triệu chứng; dùng “dấu hiệu” làm điều kiện kích hoạtAdd on symptoms; use each card's symptom as the trigger
← vuốt ngang để xem hết bảng← swipe to see the full table
Ba câu cần nhớThree sentences to remember
01Model là phần dễ. Vòng lặp, việc chọn ngữ cảnh và cách kiểm chứng mới là sản phẩm — và đó là phần bạn viết.The model is the easy part. The loop, the context selection and the way you verify it are the product — and that part is code you write.
02Mỗi lớp là một khoản thuế vĩnh viễn. Thêm khi có triệu chứng, không thêm vì thấy trên mạng.Every layer is a permanent tax. Add on symptoms, not on trends.
03Không có eval và trace thì mọi cải tiến chỉ là cảm giác. Nếu chỉ làm được hai mục trong chín, hãy làm 06 và 08.Without evals and traces, every improvement is a feeling. If you can only do two of the nine, do 06 and 08.