Back to the curriculum

L1-M05 · Level 1 · ~30 h

Structured Output, Tool Calling and a First Chat Agent

What you build: Schema and function-call validation tests

lessons
5
lesson hours (estimate)
≈ 15 h
lessons with a public video
5/5
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 · L1-M05-L01≈ 3 hVideo

    JSON and JSON Schema for testers

    What you build: Writes a schema and validates samples

    Needs: L1-M04-L01

    Key terms (5)
    • JSON SchemaLược đồ mô tả JSON hợp lệ
    • InstanceTài liệu JSON được kiểm tra
    • KeywordTừ khóa của schema (`type`, `required`...)
    • Validation errorLỗi kiểm tra hợp lệ
    • JSON pathĐường dẫn tới phần tử trong JSON (`$.priority`)
  2. Lesson 2 · L1-M05-L02≈ 3 hVideo

    Structured-output features and validation in code

    What you build: Validates model JSON with a schema library; tests failure paths

    Needs: L1-M05-L01

    Key terms (5)
    • Structured outputsOutput có cấu trúc theo schema
    • Strict tool useTool có tham số được ràng buộc theo schema
    • RefusalModel từ chối trả lời
    • Characterization testTest ghi lại hành vi hiện tại của một thành phần
    • ConstraintRàng buộc (ví dụ `maximum`)
  3. Lesson 3 · L1-M05-L03≈ 3 hVideo

    Function calling basics: tool definitions and tool-call responses

    What you build: Reads and asserts tool-call blocks

    Needs: L1-M05-L02

    Key terms (6)
    • Tool use / function callingGọi công cụ / gọi hàm
    • Tool definitionĐịnh nghĩa công cụ
    • Client toolCông cụ do ứng dụng chạy
    • Parallel tool useGọi nhiều công cụ trong một response
    • Manual loop / tool runnerVòng lặp tự viết / vòng lặp có sẵn của SDK
    • Side effectTác dụng phụ (thay đổi dữ liệu thật)
  4. Lesson 4 · L1-M05-L04≈ 3 hVideo

    Validating tool-call arguments and handling bad calls

    What you build: Argument validation tests (types, ranges, missing fields)

    Needs: L1-M05-L03

    Key terms (5)
    • Excessive AgencyTrao quá nhiều quyền hành động cho model
    • Business ruleQuy tắc nghiệp vụ
    • Human-in-the-loop / approval gateCon người phê duyệt / cổng phê duyệt
    • RollbackHoàn tác lịch sử về trạng thái trước
    • Side effectTác dụng phụ
  5. Lesson 5 · L1-M05-L05≈ 3 hVideo

    Testing a tool-using chat agent (single agent, mock tools)

    What you build: Tests for tool choice, arguments and multi-turn conversation regression

    Needs: L1-M05-L04

    Key terms (5)
    • AgentVòng lặp model gọi tool và đọc kết quả
    • TrajectoryChuỗi tool được gọi
    • TranscriptBản ghi một cuộc hội thoại
    • Golden fileOutput đã review, dùng làm oracle
    • Conversation regressionPhát hiện thay đổi hành vi qua kịch bản nhiều lượt

A. Module overview

Field Value
Module ID L1-M05
Level 1 - AI QA Engineer
Description Testing the structured output and tool use of an LLM feature: JSON Schema; structured outputs and the constraints the API does not enforce; tool definitions, tool_use and tool_result; parameter checks, business rules and approval for tools with side effects; multi-turn conversation regression for a tool-using agent. All labs use the real SDK (anthropic 2.3.0) with a local fake API.
Why this module matters When model output is used to take action (create a return order, issue a refund), integration defects become real data changes. This is the part that can be tested deterministically.
Target professional competencies Level 1: "Structured-output validation", "Tool-call and single-agent conversation testing".
Estimated duration 5 lessons (165 + 180 + 180 + 180 + 180 minutes) ≈ 15 hours + module assignment ~14 hours + quiz 0.5 hours ≈ 30 hours for someone new to Python. Estimate, not yet measured with real learners.
Prerequisites L1-M01 to L1-M04. No API key needed.
Module output Schema and function-call validation tests for ShopEasy Order Agent v2
Cost 0 VND

B. Learning objectives

ID Objective
MO1 Write and verify a JSON Schema as an oracle for structured output.
MO2 Verify a structured output integration across every response path.
MO3 Assert the request, tool_use and tool_result against the tool use rules, including parallel calls.
MO4 Verify the layers of protection around tools with side effects.
MO5 Build a multi-turn conversation regression with a reviewed golden transcript.

C. Lessons

ID Lesson Duration Prerequisites Concepts Hands-on output
L1-M05-L01 JSON and JSON Schema for testers 165' L1-M04-L01 keyword, iter_errors, samples that break one rule Schema + verification samples
L1-M05-L02 Structured output and validation in code 180' L01 output_config.format, unsupported keywords, stop reason, parse() Tests for six paths
L1-M05-L03 Function calling basics 180' L02 tool use flow, tool_result rules, tool_choice Protocol tests
L1-M05-L04 Parameter checks and handling bad calls 180' L03 Excessive Agency, four layers of protection, is_error, rollback Parameter and approval tests
L1-M05-L05 Testing a tool-using chat agent 180' L04 trajectory, state, golden transcript Regression scenario

D. Hands-on assignment (module assignment)

Schema and function-call validation tests for ShopEasy Order Agent v2 (fictional). Details in exercises.md.

E. Module assessment

Component Weight Content
Knowledge quiz 20% quiz.md: 12 questions, 20 points
Practical assignment 40% Rubric: Test design + Implementation
Applied QA analysis 20% Rubric: Contract analysis + Defect analysis
Review/reflection 20% Rubric: Reporting + Reflection

Formula: module score = 0.2 × quiz% + 0.8 × assignment rubric score (out of 100). Pass conditions: quiz ≥ 70% and every mandatory acceptance criterion and total ≥ 70%.

F. References

See references.md.

Objective ↔ assessment matrix

Objective Lesson Module quiz Assignment
MO1 L01 Q1, Q6 Contract analysis K1
MO2 L02 Q2, Q9 K1; D9
MO3 L03 Q3, Q4 A2, A8; AC3; D2, D10
MO4 L04 Q5, Q7, Q10 A3-A7; AC2; D1, D3-D7
MO5 L05 Q8, Q11, Q12 A1; three-turn scenario; D8