Back to the curriculum

L3-M01 · Level 3 · ~14 h

Agent Architecture and Execution Lifecycle

What you build: Agent architecture map

lessons
5
lesson hours (estimate)
≈ 9.5 h
0/5 lessons marked done · Progress is saved in this browser only. No account, nothing is sent to a server.
In review. The curriculum, module overviews and Levels 1–3 lessons are drafts written with AI assistance and reviewed by AI. Human review is still pending. English translation: AI-assisted, not human-reviewed.

Levels 1–3 lessons, exercises and quizzes are published as drafts, in Vietnamese with an AI-assisted English translation. They may change after human review.

Module path

  1. Lesson 1 · L3-M01-L01≈ 2 h

    What makes an agent: model, tools, loop, environment

    What you build: Classifies systems as workflow or agent

    Needs: L2-M08-L04

    Key terms (6)
    • AgentHệ thống trong đó model tự điều khiển quy trình và việc dùng tool [R1]
    • WorkflowHệ thống điều phối model và tool bằng đường mã định sẵn [R1]
    • Simulated policyChính sách mô phỏng: hàm tất định thay cho model, do tác giả lab viết
    • SandboxVùng cách ly cho tool: ở lab là một thư mục tạm cùng quy tắc tên và giới hạn
    • End-state oracleCơ chế chấm pass/fail dựa trên trạng thái cuối của môi trường và câu trả lời cuối
    • Excessive agencyQuyền tự quyết thừa của agent: chức năng, quyền hoặc tự chủ vượt mức cần thiết [R3]
  2. Lesson 2 · L3-M01-L02≈ 2 h

    The agent loop and stop conditions

    What you build: Traces a loop and finds its exit conditions

    Needs: L3-M01-L01

    Key terms (8)
    • Agent loopVòng lặp agent: hỏi model, chạy tool, đưa kết quả lại, lặp
    • StepBước: một lần gọi model cộng nhiều nhất một lần gọi tool
    • Stop condition / stop reasonĐiều kiện dừng / lý do dừng của vòng lặp
    • Budget (cu)Ngân sách tính bằng đơn vị chi phí giả
    • Loop guardChốt kiểm vòng lặp: từ chối lời gọi lặp cùng khóa khi trạng thái không đổi
    • State fingerprintDấu vân tay trạng thái: mã băm nội dung sandbox
    • Scripted policyChính sách phát lại một danh sách hành động cố định, dùng để test
    • Fail closedĐóng khi lỗi: giới hạn sai thì không chạy
  3. Lesson 3 · L3-M01-L03≈ 2 h

    Planning patterns such as reasoning-and-acting loops (sources verified at authoring)

    What you build: Compares two patterns on one task

    Needs: L3-M01-L02

    Key terms (7)
    • PatternMẫu tổ chức vòng lặp: direct, plan_execute, react
    • Reason-act loop (ReAct)Vòng lặp suy nghĩ-hành động-quan sát [R1]
    • ThoughtSuy nghĩ: văn bản lập luận của model, không đổi môi trường [R1]
    • Plan-then-executeLập kế hoạch trước rồi thực hiện (chính sách `plan_execute` của lab không lập lại kế hoạch; hệ thật có thể)
    • Plan lintLint kế hoạch: kiểm cấu trúc, tool, tham số, tham chiếu
    • Forward referenceTham chiếu trước: dùng kết quả của một tool khi chưa bước nào gọi nó
    • Seed / slipChuỗi rút số giả ngẫu nhiên tất định / lỗi mô phỏng làm hỏng JSON tham số
  4. Lesson 4 · L3-M01-L04≈ 2 h

    Observability: traces, spans, logs

    What you build: Instruments a mock agent

    Needs: L3-M01-L03

    Key terms (9)
    • ObservabilityKhả năng quan sát: trả lời về một lần chạy cụ thể từ bản ghi
    • MonitoringGiám sát: theo dõi chỉ số tổng hợp theo thời gian
    • TraceDấu vết: cây span của một lần chạy
    • SpanĐoạn việc có điểm bắt đầu và kết thúc, nằm trong cây của một trace
    • Span eventSự kiện trên span: ghi chú có cấu trúc tại một thời điểm
    • Log recordBản ghi nhật ký có thời điểm, mức nghiêm trọng, thân và thuộc tính
    • Logical clockĐồng hồ logic: bộ đếm thay cho giờ thật
    • RedactionChe dữ liệu nhạy cảm trước khi ghi
    • Trace lintLint trace: kiểm cấu trúc, quan hệ, thời gian, log và dữ liệu nhạy cảm còn sót
  5. Lesson 5 · L3-M01-L05≈ 1.5 h

    Architecture map and risk analysis

    What you build: Risk-annotated architecture map

    Needs: L3-M01-L04

    Key terms (7)
    • Agent architecture mapBản đồ kiến trúc agent: nút, cạnh, ranh giới tin cậy, giới hạn vòng lặp, rủi ro, ở dạng dữ liệu
    • Risk annotationGhi chú rủi ro: rủi ro gắn vào một nút hoặc cạnh của bản đồ
    • Trust boundaryRanh giới tin cậy: cạnh nối nút trusted với nút untrusted
    • ControlBiện pháp kiểm soát: việc làm giảm một rủi ro
    • Risk scoreĐiểm rủi ro: mức nghiêm trọng nhân khả năng xảy ra, thang 1 đến 9 của lab
    • Declared testTest đã khai: mã test ghi trong bản đồ; chưa chắc tồn tại hay chạy
    • ApprovalDuyệt: điều kiện người hoặc sandbox cho phép tool có tác động chạy

A. Module overview

Field Value
Module ID L3-M01
Level 3 - AI Agent Quality Engineer
Description Opens Level 3 by looking inside an agent before testing it: telling a workflow (models and tools orchestrated through predefined code paths) from an agent (the model directs its own process and tool use) using a sourced definition, the four parts of an agent (model, tools, loop, environment), the tool layer running in a sandbox, the loop with six stop reasons (maximum steps, budget, final answer, consecutive-error limit, loop guard, policy error), three planning patterns (direct, plan-then-execute, reason-act) compared on the same task, the observability layer (trace, span, log, logical clock, redaction of sensitive data, trace lint) and an architecture map with risk annotations. The module lab is a small, deterministic simulated agent that runs offline: no model calls, no API key, and tools run only inside a temporary sandbox directory. What is known about real agents is quoted from sources read on 2026-11-04 (the ReAct paper, the "Building effective agents" article, the Claude tool use documentation, the OpenTelemetry concept pages on traces and logs, the OWASP Excessive Agency entry; the Plan-and-Solve paper was read as an abstract only); the reading level of each source is recorded in §12 of each lesson.
Why this module matters Agents fail in ways a single model call cannot: they do not stop, they repeat a call, they use up the budget before recording a result, they leak secrets into logs, or they have write permissions that are too broad. Most of these failures live in the loop code and the tool layer, so ordinary tests can catch them if you know where to look. This module teaches where to look, and lays the groundwork for the Level 3 modules on tool contracts, multi-step scenarios, trajectories, state, reliability and safety.
Target professional competency Level 3, learning outcome 1: "Map an agent's architecture and execution lifecycle, and identify the risk at each step".
Estimated duration 5 lessons (120 + 120 + 120 + 120 + 90 minutes) = 9.5 hours + module assignment ~4 hours + quiz 0.5 hours ≈ 14 hours for someone who has completed L2-M08. The figure is higher than the Level 3 plan's average of ~80 minutes per lesson because each lesson has a long independent exercise. An estimate, not yet measured with real learners.
Prerequisites L2-M08 (the Level 2 capstone; the first lesson needs L2-M08-L04). The module reuses, without repeating: the tool_use / tool_result protocol, parameter validation and a chat agent with fake tools (L1-M05-L03 to L05), prompt injection (L1-M04-L04), the test oracle (L1-M01-L01), pytest and exit codes (L1-M07), the fail-closed gate and the paired comparison (L2-M07, L2-M08). No API key needed.
Module output (deliverable) An agent architecture map with risk annotations: a data file describing nodes, edges, trust boundaries, loop limits and a list of risks (score, control, test), passed through the lab's validator; plus the small products of each lesson: a workflow-or-agent label with reasons, a stop-condition test suite, a comparison of two patterns on one task, a redacted trace that passes lint
Cost 0 VND

What learners build. Step by step, in code-labs/l3-m01: (L01) a tool layer in a sandbox with exact tool-name matching and strict JSON parameters, a workflow-or-agent classifier over six self-declared fields, nine fake tasks with an end-state oracle and three simulated policies; (L02) a loop with six stop reasons, a loop guard with a canonical call key and a state fingerprint, a limits lint; (L03) a plan lint and a comparison of three patterns on the same task, seed and limits, with and without simulated faults; (L04) a trace writer with a logical clock, redaction of sensitive data, a trace lint and an agent-convention lint; (L05) an architecture map as data, a validator, a risk table and declared-test coverage. The lab is independent of the earlier labs and needs only pytest.

What the module does not do. It does not measure real models or agents, it states no price, speed or reliability for any model or vendor, and it does not rank or recommend any framework: every number in the lab describes the simulation. It does not run shell commands, network calls or files outside the temporary sandbox directory. It does not create or edit an automatically running workflow in the repository. It gives no legal opinion. Lints and validators only flag; the loop guard and the limits lint block the run (fail closed); a person decides the thresholds and every real-world effect.

Terms reused with a different meaning (each lesson has a sentence that separates the senses). agent has the same meaning as in L1-M05-L05; oracle (the mechanism that decides pass or fail) differs from the oracle context of L2-M06; the agent's plan differs from the "comparison plan" of L2-M07; trace is the span tree of one run, different from the transcript of L1-M05-L05 and the trajectory of L3-M04; span differs from the evidence span of L2-M06; observability (answering questions about one run) differs from monitoring (aggregate metrics over time); step, loop and state take their meaning from the agent loop; the loop guard (blocks a repeated call at run time) differs from the guard of L2-M03-L02, a deterministic check placed next to a similar point; declared-test coverage (the share of risks that declare a test) differs from the coverage of the confidence interval (L2-M01-L04) and the dataset coverage (L2-M02-L02).

B. Learning objectives

ID Objective
MO1 Classify a system as a workflow or an agent using a sourced definition, identify the four parts of an agent, and test the tool layer in the sandbox with bad calls.
MO2 Read one run of the loop, list every stop reason, compute by hand the stopping point at edge cases, and evaluate a loop guard together with its blind spot.
MO3 Compare planning patterns on the same task, seed and limits, lint a plan, and read simulation results without inferring anything about real models.
MO4 Attach traces, spans and logs to a simulated agent, redact sensitive data before writing, and lint a trace, stating what the lint does not check.
MO5 Draw an architecture map with risk annotations, run the validator, and turn risks that have no test yet into work for later modules.

C. Lessons

ID Lesson Duration Prerequisite Concepts Practical output
L3-M01-L01 What an agent is: model, tools, loop and environment 120' L2-M08-L04 workflow and agent, four parts, tool layer in a sandbox, end-state oracle, excessive agency Classify a system as workflow or agent
L3-M01-L02 The agent loop and stop conditions 120' L01 six stop reasons, edge cases for step count and budget, loop guard, limits lint Trace a loop and find its exit conditions
L3-M01-L03 Planning patterns: direct, plan-then-execute and reason-act 120' L02 ReAct and Plan-and-Solve as sourced, plan lint, comparing patterns under fair conditions Compare two patterns on one task
L3-M01-L04 Observability: traces, spans and logs 120' L03 trace, span, log, logical clock, redaction of sensitive data, trace lint Attach observability to a fake agent
L3-M01-L05 Architecture map and risk analysis 90' L04 map as data, trust boundaries, risk annotations, validator An architecture map with risk annotations

D. Module assignment

The module assignment (exercises.md): build an architecture map with risk annotations for HocVui Assistant v2 (adding the share_note tool) together with four accompanying products (classification and tool layer, a stop-condition test suite, a comparison of three patterns, a redacted trace), five reports generated by one script, a decision by one person, acceptance criteria AC1-AC6 and a 100-point rubric; plus one independent challenge (SachMo). The five independent per-lesson exercises are in code-labs/l3-m01/exercises/ and in §9 of each lesson. Module quiz: quiz.md (12 questions, 20 points, pass mark 14).

E. Module assessment

The practice for each lesson is in practice-01.md to practice-05.md (with .en.md versions). The module quiz, the module assignment rubric and the acceptance criteria AC1-AC6 are in quiz.md and exercises.md. The solutions, answer key and instructor guide are for instructors only and are not published.

F. References

The shared list is in references.md (seven sources, access dates, how much of each source was read); each lesson also has its own references table in §12.

Objective ↔ assessment matrix

Objective Lesson Independent exercise (§9) Quiz question Module assignment criterion
MO1 L01 exercises/test_l01_agent.py Q1, Q6 AC1
MO2 L02 exercises/test_l02_loop.py Q2, Q3, Q10 AC2
MO3 L03 exercises/test_l03_planning.py Q4, Q7, Q9 AC3
MO4 L04 exercises/test_l04_trace.py Q8, Q11 AC4
MO5 L05 exercises/test_l05_archmap.py Q5, Q12 AC5 (AC6 is reproduction, shared by all objectives)