Chapter 6 — Agent Loop & Capstone
Câu hỏi trung tâm: Agent chỉ là một vòng lặp — nhưng vòng lặp đó hoạt động thế nào?
🔒 Chapter chưa mở
Nội dung chi tiết sẽ được unlock dần. Dưới đây là outline.
Outline
6.1 — Agent ≠ Magic
- Mọi agent đình đám (Claude Code, Manus, Perplexity) đều là while loop
- Core loop:
Observe → Think → Act → Observe → ... - Sự khác biệt giữa "workflow" (Chapter 5) và "agent" — ranh giới nằm ở đâu
- Agent = workflow mà model tự quyết định bước tiếp theo
6.2 — Anatomy of an Agent
- System prompt — xác định persona, constraints, available tools
- Tool belt — tập hợp tool mà agent có thể gọi
- Memory / State — conversation history, scratchpad
- Loop control — max iterations, stopping conditions, human-in-the-loop
6.3 — Stopping Conditions & Guardrails
- Khi nào agent dừng: task complete, max steps, error threshold, user cancel
- Guardrails: giới hạn tool access, content filter, cost limit
- "Agent gone rogue" — case study và cách phòng tránh
6.4 — Capstone — Build Your Own Famous Agent
Chọn 1 trong 3 track:
Track A — Code Agent (kiểu Claude Code / Cursor)
- Tools: file read/write, shell execute, code search
- System prompt: coding assistant với access vào codebase
- Challenge: agent sửa code, chạy test, tự fix nếu fail
Track B — Computer Use Agent (kiểu Manus / Operator)
- Tools: screenshot, mouse click, keyboard input, browser navigate
- System prompt: task executor trên desktop/browser
- Challenge: agent hoàn thành task trên web interface
Track C — Deep Research Agent (kiểu Perplexity)
- Tools: web search, page fetch, note-taking
- System prompt: researcher tổng hợp nhiều nguồn
- Challenge: agent research một topic, output báo cáo có source
6.5 — Demo & Review
- Structure demo: problem → approach → live run → lessons learned
- Peer review: đọc code của nhau, feedback về agent design
Insight quan trọng
Cả ba track dùng chung một agent loop
while not done:
observation = get_current_state()
thought = llm.think(system_prompt, history, observation)
action = llm.choose_tool(thought, available_tools)
result = execute_tool(action)
history.append(observation, thought, action, result)
done = check_stopping_condition(result, history)
Khác nhau chỉ ở toolbelt và system prompt. Và đó là thứ bạn đã nắm xuyên suốt Chapter 1–5.
Checkpoint
- Giải thích sự khác biệt giữa workflow (Ch.5) và agent — bằng ví dụ
- Agent của bạn có bao nhiêu tool? Mỗi tool làm gì?
- Stopping condition của agent bạn là gì? Nếu agent "loop mãi" thì sao?
🎉 Hoàn thành Module 1! Tiếp theo: Module 2 — Context & Memory (RAG, Vector Store, Long-term Memory)