Agent architecture · field guideKiến trúc agent · cẩm nang
Six shapes.That is all.Sáu hình.Chỉ có vậy.
Every agent architecture is one of these six, or two of them chained. Your task's shape picks the pattern — not you. Read the problem first, choose the architecture second.Mọi kiến trúc agent đều là một trong sáu hình này, hoặc hai hình ghép lại. Hình dạng của task chọn pattern — không phải bạn. Đọc bài toán trước, chọn kiến trúc sau.
Pick the shapeChọn hình
Work down the list. The first question you answer yes to gives you your primary shape.Đọc từ trên xuống. Câu đầu tiên bạn trả lời "có" chính là hình chính của bạn.
Can a single LLM call solve this?Một lời gọi LLM giải quyết được không?Use no patternKhông cần pattern
Do different input types need different handling?Các loại input khác nhau cần xử lý khác nhau?Routing
Do the steps depend on each other, in a known order?Các bước phụ thuộc nhau, theo thứ tự biết trước?Chaining
Independent subtasks — and you know the count?Các việc độc lập — và bạn biết số lượng?Parallelization
Independent subtasks — count unknown until you look?Các việc độc lập — không biết số lượng cho tới khi nhìn vào?Orchestrator
Is there a clear bar for "good enough" you must hit?Có tiêu chí "đủ tốt" rõ ràng phải đạt bằng được?Evaluator Loop
Need broad coverage and independent verification?Cần vừa phủ rộng vừa thẩm định độc lập?Diamond
The sixSáu pattern
One primary shape. Everything else is bolted on afterwards.Một hình chính. Phần còn lại chỉ gắn thêm về sau.
01
Prompt Chaining
ONE PATH
Fixed steps, run in order. Each step's output feeds the next, and you know the whole chain before you write any code. A gate can stop a bad run early.Các bước cố định, chạy tuần tự. Output bước trước là input bước sau, và bạn biết cả chuỗi trước khi viết dòng code nào. Gate cho phép dừng sớm khi kết quả xấu.
High accuracy per step; failures point at an exact step.Chính xác cao ở từng bước; lỗi lộ ra đúng bước.
Cheap steps can use a small model.Bước dễ dùng model nhỏ, tiết kiệm.
CostsMất
Latency accumulates across steps.Độ trễ cộng dồn qua từng bước.
Error cascade — small drift at step 1 ruins step 4.Lỗi lan truyền — lệch nhỏ ở bước 1 hỏng bước 4.
Recognition signalDấu hiệu nhận biếtYou can draw the steps on paper before writing code. Keep it under 5.Bạn vẽ được các bước ra giấy trước khi code. Giữ dưới 5 bước.
02
Routing
ONE PATH
A classifier reads the input, then hands it to exactly one specialised handler. The other branches never run.Một classifier đọc input rồi giao cho đúng một handler chuyên biệt. Các nhánh còn lại không chạy.
Use forDùng cho
Support inbox triage. Routing by difficulty: easy → small model, hard → large model.Phân loại hộp thư hỗ trợ. Định tuyến theo độ khó: dễ → model nhỏ, khó → model lớn.
GainsĐược
Each branch gets its own prompt, tools and model.Mỗi nhánh có prompt, tool, model riêng.
Routing by difficulty can cut cost substantially — often by more than half when most traffic takes the cheap route.Định tuyến theo độ khó có thể giảm chi phí đáng kể — thường hơn một nửa khi phần lớn lưu lượng đi vào nhánh rẻ.
CostsMất
A wrong classification poisons everything after it.Phân loại sai là hỏng toàn bộ phía sau.
Hybrid inputs fit no single branch.Input lai không thuộc nhánh nào.
Recognition signalDấu hiệu nhận biếtMixing input types into one prompt degrades all of them. Always ship a fallback branch.Trộn các loại input vào một prompt làm giảm chất lượng tất cả. Luôn có nhánh fallback.
03
Parallelization
MANY AT ONCE
Fully independent subtasks run at the same time, then get merged. The precondition: you know the count in advance.Các subtask độc lập hoàn toàn chạy cùng lúc rồi gộp lại. Điều kiện: bạn biết trước số lượng.
Use forDùng cho
Sectioning — 3 competitor pages at once. Voting — same input, 3 angles, take consensus.Sectioning — 3 trang đối thủ cùng lúc. Voting — cùng input, 3 góc nhìn, lấy đồng thuận.
GainsĐược
Ten 3-second jobs still finish in ~3 seconds.Mười việc 3 giây vẫn xong trong ~3 giây.
Beats context-window limits by slicing input.Vượt giới hạn context window bằng cách chia nhỏ.
The merge step is the real bottleneck.Bước gộp mới là nút thắt thật sự.
Recognition signalDấu hiệu nhận biếtThe subtasks never need each other's results. If B needs A, that's Chaining.Các subtask không bao giờ cần kết quả của nhau. Nếu B cần A, đó là Chaining.
04
Orchestrator–Workers
MANY AT ONCE · +N
Same fan-out, but the LLM decides how many subtasks there are and what they contain — at runtime. Dashed edges mean nothing is hardcoded.Cũng fan-out, nhưng LLM tự quyết có bao nhiêu subtask và nội dung là gì — ngay lúc chạy. Nét đứt nghĩa là không có gì hardcode.
Use forDùng cho
Fixing a bug across a codebase. Deep research. Refactors. Close to plan-and-execute.Sửa bug xuyên codebase. Research sâu. Refactor. Gần với plan-and-execute.
GainsĐược
Handles tasks you cannot enumerate ahead of time.Xử lý được task không thể liệt kê trước.
Scales with the input's real complexity.Mở rộng theo độ phức tạp thật của input.
CostsMất
Unpredictable cost — 3 workers or 300.Chi phí khó đoán — 3 worker hay 300.
A bad plan wastes every worker under it.Kế hoạch sai làm mọi worker bên dưới vô ích.
Recognition signalDấu hiệu nhận biết"You cannot know how many until you look." Always set hard caps on workers, tokens and time."Không nhìn vào thì không biết bao nhiêu việc." Luôn đặt trần cứng cho worker, token và thời gian.
05
Evaluator Loop
GOES BACKWARDS
One model produces, another grades it and names specific problems, then it goes back for revision. Repeat until it passes or you run out of attempts.Một model tạo kết quả, model khác chấm và nêu vấn đề cụ thể, rồi quay lại sửa. Lặp đến khi đạt hoặc hết lượt.
Use forDùng cho
Generate code → run tests → fix. Draft copy → grade it → revise. Literary translation.Sinh code → chạy test → sửa. Viết nháp → chấm → sửa. Dịch văn học.
GainsĐược
Very high reliability; the go-to for quality on subjective work.Độ tin cậy rất cao; lựa chọn hàng đầu cho chất lượng ở việc mang tính chủ quan.
The evaluator can be plain code — tests, linters, schemas.Evaluator có thể là code thuần — test, linter, schema.
CostsMất
Cost and latency multiply by iteration count.Chi phí và độ trễ nhân theo số vòng lặp.
Oscillation: v2 fixes A and breaks B; v3 undoes it.Dao động: v2 sửa A làm hỏng B; v3 lại lật ngược.
Recognition signalDấu hiệu nhận biếtYou can write "good enough" as a checklist. Cap at 2–3 rounds, and keep the best draft — not the last.Bạn viết được "đủ tốt" thành checklist. Giới hạn 2–3 vòng, và giữ bản tốt nhất — không phải bản cuối.
06
Diamond
TWO, CHAINED
Two parallel phases chained: go broad to gather, merge, then go broad again to verify through independent lenses. Wide → narrow → wide → narrow.Hai pha song song nối tiếp: mở rộng để thu thập, gộp lại, rồi mở rộng lần nữa để thẩm định qua các lăng kính độc lập. Rộng → hẹp → rộng → hẹp.
Use forDùng cho
Deep research with fact-checking. Due diligence. Medical, legal and financial content.Research sâu có fact-check. Due diligence. Nội dung y tế, pháp lý, tài chính.
GainsĐược
Very high reliability; catches systematic errors.Độ tin cậy rất cao; bắt được lỗi hệ thống.
Multiple angles reduce single-thread bias.Nhiều góc nhìn giảm thiên lệch của một luồng.
CostsMất
8–12× a single call. Slowest of the six.Gấp 8–12 lần một lời gọi. Chậm nhất trong sáu.
Two merge points, two bottlenecks.Hai điểm gộp, hai nút thắt.
Recognition signalDấu hiệu nhận biếtGive each reviewer a distinct lens. Upgrade from plain Parallelization only after you've measured escaped errors.Mỗi reviewer một lăng kính riêng. Chỉ nâng từ Parallelization lên khi đã đo được lỗi lọt lưới là vấn đề thật.
What each one costs youCái giá của mỗi hình
Reliability is never free. Every step down this table you trade money and time for confidence.Độ tin cậy không bao giờ miễn phí. Càng xuống dưới bảng, bạn càng đổi tiền và thời gian lấy độ chắc chắn.
PatternPattern
FlowLuồng
Steps known?Biết trước bước?
CostChi phí
LatencyĐộ trễ
ReliabilityTin cậy
DebuggingGỡ lỗi
1 · Chaining
SequentialTuần tự
✅
LowThấp
MediumTrung bình
HighCao
EasyDễ
2 · Routing
BranchingRẽ nhánh
✅
LowThấp
LowThấp
MediumTrung bình
EasyDễ
3 · Parallelization
ParallelSong song
✅
MediumTrung bình
LowThấp
HighCao
MediumTrung bình
4 · Orchestrator
Dynamic parallelSong song động
❌
UnpredictableKhó đoán
MediumTrung bình
MediumTrung bình
HardKhó
5 · Evaluator Loop
LoopVòng lặp
❌
Med–HighTB–Cao
HighCao
Very highRất cao
MediumTrung bình
6 · Diamond
Two phasesHai pha
✅
Very highRất cao
HighCao
Very highRất cao
HardKhó
Ways this goes wrongNhững cách làm hỏng
Most broken agent systems fail on one of these, not on the model.Phần lớn hệ agent hỏng là vì một trong những điều này, không phải vì model.
Reaching for an agent when a workflow sufficesDùng agent khi workflow đã đủ
Expensive, slow, hard to debug — and no upside.Đắt, chậm, khó gỡ lỗi — và chẳng được gì thêm.
Start with patterns 1–3Bắt đầu từ pattern 1–3
Chaining four patterns on day oneGhép bốn pattern ngay ngày đầu
You can't tell which one is actually contributing.Không biết pattern nào thật sự đóng góp.
One primary shape, measure, then addMột hình chính, đo, rồi mới thêm
Parallelizing dependent workSong song hoá việc có phụ thuộc
Worker B never sees A's output, so the result is wrong.Worker B không thấy output của A, kết quả sai.
Switch to ChainingChuyển sang Chaining
A loop with no iteration capVòng lặp không có trần
It runs until your budget is gone.Nó chạy đến khi hết sạch ngân sách.
Cap at 2–3 roundsGiới hạn 2–3 vòng
The generator grading itselfGenerator tự chấm chính nó
Shared blind spots mean it almost always passes.Mù điểm chung khiến nó gần như luôn cho đạt.
Different model, or code-based checksModel khác, hoặc kiểm tra bằng code
Not logging routing decisionsKhông log quyết định routing
When an answer is wrong, you'll never find out why.Khi trả lời sai, bạn không bao giờ biết vì sao.
Log category and confidence every timeLog category và confidence mọi lần
Deeply nested agent hierarchiesAgent lồng nhau nhiều tầng
Context dilutes at every layer until nobody knows the goal.Ngữ cảnh loãng dần qua từng tầng cho đến khi không ai còn biết mục tiêu.
Two levels, maximumTối đa hai tầng
Three things to rememberBa điều cần nhớ
The task's shape picks the pattern, not you.Hình dạng của task chọn pattern, không phải bạn.Read the problem first, choose the architecture second.Đọc bài toán trước, chọn kiến trúc sau.
Simple before complex.Đơn giản trước, phức tạp sau.A complex pattern has to earn its place with numbers, not with a feeling.Pattern phức tạp phải chứng minh chỗ đứng bằng số liệu, không phải bằng cảm tính.
One primary shape; everything else is bolted on.Một hình chính; phần còn lại chỉ gắn thêm.Nobody builds an agent by combining all six at once.Không ai xây agent bằng cách ghép cả sáu hình cùng lúc.