Learn AI Agent in 2026
Lesson 04

Planning & Task Decomposition

How agents break down goals, replan on failure, and track sub-tasks.

0:00 / 0:00

Transcript

Lesson 4: Tool Use & Model Context Protocol (MCP) — Full Spoken Transcript (Cantonese)

Original podcast: Cantonese dialogue between two speakers (M = 主持 host 子謙, F = 嘉賓 expert 曉晴). Total spoken duration: ~12 min. The audio above plays the full conversation. The text below is the complete transcript of what was actually said — preserved verbatim, not summarised, not translated.

Course: Eight-lesson course on AI agents · Lesson 4 of 8 · learnagent.lmmlab.com Topic (EN): function-calling contract · MCP design · server lifecycle · registry / discovery. Topic (粵): function call 同 MCP 設計。 Speakers: 主持 M (host 子謙) and 嘉賓 F (expert 曉晴) · 24 spoken turns · ~12 min audio.


How to read this transcript

Each spoken turn from the podcast is shown as a separate paragraph, with the speaker label rendered in bold and an approximate timestamp (MM:SS) indicating where in the audio that turn occurs. Long turns are broken at natural sentence boundaries (。!?) and, where a sentence is still long, at clause boundaries (,;、). No English translation is provided — this is the exact spoken Cantonese audio transcript as it was synthesised for the lesson podcast.

Use browser Ctrl+F / ⌘+F to locate any phrase. On mobile (640 px viewport), the transcript scrolls as a single column.

Note: Sentence-level line breaks are for readability — the Cantonese text itself is preserved verbatim from the original podcast script (script_raw.json). No words have been altered, translated, summarised, or paraphrased.


Index of sections in this lesson

  • 1. Opening & Tool Use Basics (粵: 開場同 Tool Use 基本概念) — turn 01 onwards
  • 2. MCP Design Philosophy (粵: MCP 設計理念) — turn 05 onwards
  • 3. MCP Server Lifecycle & Registry (粵: MCP Server 生命週期同 Registry) — turn 11 onwards
  • 4. Tool Use Best Practice (粵: Tool Use 最佳實踐) — turn 17 onwards
  • 5. Wrap-up & Per-Pattern Implementation Preview (粵: 總結同 Per-Pattern Implementation 預覽) — turn 22 onwards

Section 1/5 — Opening & Tool Use Basics

開場同 Tool Use 基本概念

Section overview: covers turns 01–04 (4 spoken segments).

Topic terms (extracted from spoken text): self-explanatory, architecture, description, get_weather, parameters, structured, documented, ecosystem, reasoning, parameter

Latin/English code-terms in this section (verbatim from speech): self-explanatory, architecture, description

Section character total: 940 characters across 4 spoken turns.

Section duration estimate: ~2:00 of 12:00 total.

Turns in this section: 01, 02, 03, 04.

First spoken sentence of this section (turn 01, verbatim): 各位同學早晨, 我係子謙。

Average characters per turn (this section): ~235 chars.

Cumulative characters through this section: 940 of 7,595 total.

[01 | 00:00] 主持 M (host 子謙):

Turn 1 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 00:00 · section 1 (Opening & Tool Use Basics)

speaker=M · chars=159 · ts=00:00 · terms=architecture, ecosystem, Protocol, function, handling · sentences=3 · clauses=8

Verbatim phrases in this turn: 即係 MCP, 包括 function calling 嘅 schema 設計、 · handling, 同 MCP server 嘅 architecture 同 ecosystem。

各位同學早晨, 我係子謙。歡迎收聽第四課。

First clause (verbatim): 各位同學早晨,

Last clause (verbatim): 同 MCP server 嘅 architecture 同 ecosystem。

各位同學早晨,

我係子謙。

歡迎收聽第四課。

今日嘅主題係 Tool Use 同 Model Context Protocol,

即係 MCP,

包括 function calling 嘅 schema 設計、

error handling,

同 MCP server 嘅 architecture 同 ecosystem。

[02 | 00:30] 嘉賓 F (expert 曉晴):

Turn 2 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 00:30 · section 1 (Opening & Tool Use Basics)

speaker=F · chars=165 · ts=00:30 · terms=reasoning, generate, interact, database, external · sentences=3 · clauses=10

Verbatim phrases in this turn: , 但 agent 需要同外部世界 interact, 包括 search 資料、 · call API、 · nteract, 包括 search 資料、執行 code、call API、更新 database。

nerate text, 但 agent 需要同外部世界 interact, 包括 search 資料、執行 code、call API、更新 database。

First clause (verbatim): 大家好,

Last clause (verbatim): Tool use 係點樣令 LLM 嘅 reasoning 同 external action 接埋一齊。

大家好,

我係曉晴。

今日嘅問題係,

LLM 本身淨係可以 generate text,

但 agent 需要同外部世界 interact,

包括 search 資料、

執行 code、

call API、

更新 database。

Tool use 係點樣令 LLM 嘅 reasoning 同 external action 接埋一齊。

[03 | 01:00] 主持 M (host 子謙):

Turn 3 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 01:00 · section 1 (Opening & Tool Use Basics)

speaker=M · chars=321 · ts=01:00 · terms=parameters, structured, reasoning, function, continue · sentences=3 · clauses=11

Verbatim phrases in this turn: 首先講 tool use 嘅 basic 概念。 · 帶 typed schema, 描述 input parameters 同 return type。 · ontext 入面, LLM 再 base on result continue reasoning。

首先講 tool use 嘅 basic 概念。

First clause (verbatim): 首先講 tool use 嘅 basic 概念。

Last clause (verbatim): LLM 再 base on result continue reasoning。

首先講 tool use 嘅 basic 概念。

一個 LLM agent 嘅 tool 係一個 named function,

帶 typed schema,

描述 input parameters 同 return type。

當 agent 需要 invoke tool,

佢 output 一個 structured tool call,

例如 tool name 同 parameters 嘅 JSON,

runtime 攔截呢個 call,

execute 個 function,

然後 return result 返去 LLM context 入面,

LLM 再 base on result continue reasoning。

[04 | 01:30] 嘉賓 F (expert 曉晴):

Turn 4 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 01:30 · section 1 (Opening & Tool Use Basics)

speaker=F · chars=295 · ts=01:30 · terms=self-explanatory, description, get_weather, documented, parameter · sentences=4 · clauses=14

Verbatim phrases in this turn: 第一, schema 要清晰、 · Tool schema 嘅設計原則。 · arameter 接受 ISO 8601 date string 還是 Unix timestamp。

rameter 要有 description, 例如呢個 parameter 接受 ISO 8601 date string 還是 Unix timestamp。

First clause (verbatim): Tool schema 嘅設計原則。

Last clause (verbatim): 因為 LLM 已經 train 好嚟 parse 個 return format。

Tool schema 嘅設計原則。

第一,

schema 要清晰、

typed、

documented,

每個 parameter 要有 description,

例如呢個 parameter 接受 ISO 8601 date string 還是 Unix timestamp。

第二,

tool name 要 self-explanatory,

例如 get_weather 比起 tool_1 好得多。

第三,

return value 嘅 structure 要 stable,

唔好隨 version 改,

因為 LLM 已經 train 好嚟 parse 個 return format。

End-of-section recap (last spoken sentence of Opening & Tool Use Basics): Tool schema 嘅設計原則。


Section 2/5 — MCP Design Philosophy

MCP 設計理念

Section overview: covers turns 05–10 (6 spoken segments).

Topic terms (extracted from spoken text): one-action-at-a-time, human-in-the-loop, Plan-and-Execute, search_articles, non-recoverable, specification, create_ticket, observability, pre-execution, input_schema

Latin/English code-terms in this section (verbatim from speech): one-action-at-a-time, human-in-the-loop, Plan-and-Execute

Section character total: 2,038 characters across 6 spoken turns.

Section duration estimate: ~3:00 of 12:00 total.

Turns in this section: 05, 06, 07, 08, 09, 10.

First spoken sentence of this section (turn 05, verbatim): OpenAI 嘅 function calling format 同 Anthropic 嘅 tool use format 都係 similar, 但有 detail differences。

Average characters per turn (this section): ~339 chars.

Cumulative characters through this section: 2,978 of 7,595 total.

[05 | 02:00] 主持 M (host 子謙):

Turn 5 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 02:00 · section 2 (MCP Design Philosophy)

speaker=M · chars=373 · ts=02:00 · terms=specification, input_schema, differences, description, abstraction · sentences=4 · clauses=14

Verbatim phrases in this turn: tool use format 都係 similar, 但有 detail differences。 · parameters, parameters 用 JSON Schema specification。 · put_schema, 亦都係 JSON Schema spec 但 minor syntax 唔同。

n calling format 同 Anthropic 嘅 tool use format 都係 similar, 但有 detail differences。

First clause (verbatim): OpenAI 嘅 function calling format 同 Anthropic 嘅 tool use format 都係 similar,

Last clause (verbatim): 呢個係 vendor lock-in 嘅 mitigation。

OpenAI 嘅 function calling format 同 Anthropic 嘅 tool use format 都係 similar,

但有 detail differences。

OpenAI 用 tool 嘅 type function,

name,

description,

parameters,

parameters 用 JSON Schema specification。

Anthropic 用 tool 嘅 name,

description,

input_schema,

亦都係 JSON Schema spec 但 minor syntax 唔同。

LangChain 提供統一 abstraction,

將唔同 vendor 嘅 format 轉換,

呢個係 vendor lock-in 嘅 mitigation。

[06 | 02:30] 嘉賓 F (expert 曉晴):

Turn 6 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 02:30 · section 2 (MCP Design Philosophy)

speaker=F · chars=322 · ts=02:30 · terms=search_articles, create_ticket, parameterize, granularity, probability · sentences=4 · clauses=13

Verbatim phrases in this turn: 應 user-facing action, 例如 search_articles、 · create_ticket、 · Tool 嘅 granularity 設計。

Tool 嘅 granularity 設計。

First clause (verbatim): Tool 嘅 granularity 設計。

Last clause (verbatim): 唔係 internal database operation。

Tool 嘅 granularity 設計。

一個常見嘅 mistake 係將 tool 設計得太細粒度,

例如將 database 嘅每一個 query 做一個 tool,

結果有幾十個 tools,

LLM 揀錯嘅 probability 提升。

另一個 extreme 係將 tool 設計得太粗,

例如一個 mega-tool 做所有嘢,

LLM 唔識得 parameterize 啱用嘅 action。

最佳嘅 granularity 通常係對應 user-facing action,

例如 search_articles、

create_ticket、

send_email,

唔係 internal database operation。

[07 | 03:00] 主持 M (host 子謙):

Turn 7 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 03:00 · section 2 (MCP Design Philosophy)

speaker=M · chars=355 · ts=03:00 · terms=non-recoverable, recoverable, exponential, permission, operation · sentences=4 · clauses=16

Verbatim phrases in this turn: 第一, recoverable error 即係 network timeout、 · rate limit、 · ror 即係 4xx client error 例如 invalid input、

Tool error handling 嘅策略。

First clause (verbatim): Tool error handling 嘅策略。

Last clause (verbatim): 失敗嘅 reason。

Tool error handling 嘅策略。

第一,

recoverable error 即係 network timeout、

rate limit、

5xx server error,

agent 應該 retry with exponential backoff。

第二,

non-recoverable error 即係 4xx client error 例如 invalid input、

permission denied,

agent 應該 surface error 俾 user 或者 reframe query。

第三,

partial success 即係 batch operation 部分成功,

agent 應該 summarize 結果,

例如成功八個、

失敗兩個,

失敗嘅 reason。

[08 | 03:30] 嘉賓 F (expert 曉晴):

Turn 8 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 03:30 · section 2 (MCP Design Philosophy)

speaker=F · chars=344 · ts=03:30 · terms=observability, production, Structured, search_web, out-of-box · sentences=5 · clauses=11

Verbatim phrases in this turn: 每個 tool call 應該 log input、 · status code、 · Tool 嘅 observability 對 production debugging 重要。

Tool 嘅 observability 對 production debugging 重要。

First clause (verbatim): Tool 嘅 observability 對 production debugging 重要。

Last clause (verbatim): structured log 可以快速搵到呢類 issue。

Tool 嘅 observability 對 production debugging 重要。

每個 tool call 應該 log input、

output、

latency、

status code、

retry count。

Structured logging 方便事後 query,

例如 過去一個鐘所有 search_web call 嘅 failure rate。

LangSmith 同 LangGraph Platform 都提供呢類 observability out-of-box。

Agent debugging 嘅經常嘅 failure mode 係 LLM 揀錯 tool 或者 parameter typo,

structured log 可以快速搵到呢類 issue。

[09 | 04:00] 主持 M (host 子謙):

Turn 9 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 04:00 · section 2 (MCP Design Philosophy)

speaker=M · chars=326 · ts=04:00 · terms=one-action-at-a-time, human-in-the-loop, Plan-and-Execute, pre-execution, irreversible · sentences=3 · clauses=8

Verbatim phrases in this turn: 即係刪除 record、 · Tool 嘅 approval gate 對 irreversible action 重要。 · require human-in-the-loop approval 喺 execution 之前。

Tool 嘅 approval gate 對 irreversible action 重要。

First clause (verbatim): Tool 嘅 approval gate 對 irreversible action 重要。

Last clause (verbatim): 呢個係 ReAct 嘅 one-action-at-a-time execution 做唔到嘅。

Tool 嘅 approval gate 對 irreversible action 重要。

即係刪除 record、

轉帳、

發 email,

呢類 tool 應該 require human-in-the-loop approval 喺 execution 之前。

Plan-and-Execute pattern 嘅 plan 可以 pre-execution policy check,

即係 scan 個 plan 嚟 detect prohibited action types 同 unauthorized resource references,

呢個係 ReAct 嘅 one-action-at-a-time execution 做唔到嘅。

[10 | 04:30] 嘉賓 F (expert 曉晴):

Turn 10 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 04:30 · section 2 (MCP Design Philosophy)

speaker=F · chars=318 · ts=04:30 · terms=standardize, programming, connection, Anthropic, Protocol · sentences=4 · clauses=11

Verbatim phrases in this turn: ocol, 用嚟 standardize LLM 同 external tool、 · 好, 講 Model Context Protocol, 即 MCP。 · rdize LLM 同 external tool、data source 嘅 connection。

好, 講 Model Context Protocol, 即 MCP。

First clause (verbatim): 好,

Last clause (verbatim): 令唔同 vendor 嘅 agent 可以 plug and play 唔同嘅 tool。

好,

講 Model Context Protocol,

即 MCP。

MCP 係 Anthropic 喺 2024 年尾提出嘅 open protocol,

用嚟 standardize LLM 同 external tool、

data source 嘅 connection。

呢個 protocol 嘅 design 類似 Language Server Protocol,

即係 LSP,

用於 programming language tooling。

MCP 將 tool provider 同 agent 嘅 contract 標準化,

令唔同 vendor 嘅 agent 可以 plug and play 唔同嘅 tool。

End-of-section recap (last spoken sentence of MCP Design Philosophy): 好, 講 Model Context Protocol, 即 MCP。


Section 3/5 — MCP Server Lifecycle & Registry

MCP Server 生命週期同 Registry

Section overview: covers turns 11–16 (6 spoken segments).

Topic terms (extracted from spoken text): vendor-specific, single-purpose, vendor-neutral, implementation, architecture, capabilities, integrations, declarations, multi-vendor, application

Latin/English code-terms in this section (verbatim from speech): vendor-specific, single-purpose, vendor-neutral

Section character total: 1,889 characters across 6 spoken turns.

Section duration estimate: ~3:00 of 12:00 total.

Turns in this section: 11, 12, 13, 14, 15, 16.

First spoken sentence of this section (turn 11, verbatim): MCP 嘅 architecture 有三個角色。

Average characters per turn (this section): ~314 chars.

Cumulative characters through this section: 4,867 of 7,595 total.

[11 | 05:00] 主持 M (host 子謙):

Turn 11 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 05:00 · section 3 (MCP Server Lifecycle & Registry)

speaker=M · chars=264 · ts=05:00 · terms=architecture, capabilities, application, component, resources · sentences=5 · clauses=13

Verbatim phrases in this turn: st, 即係 LLM application 例如 Claude Desktop、 · ver 暴露 resources 同 tools, client 可以 list、 · MCP 嘅 architecture 有三個角色。

MCP 嘅 architecture 有三個角色。

First clause (verbatim): MCP 嘅 architecture 有三個角色。

Last clause (verbatim): subscribe 呢啲 capabilities。

MCP 嘅 architecture 有三個角色。

第一個係 MCP host,

即係 LLM application 例如 Claude Desktop、

Cline、

Cursor。

第二個係 MCP client,

host 入面嘅一個 component 用嚟同 server 通訊。

第三個係 MCP server,

提供實際嘅 tools 同 data sources。

每個 server 暴露 resources 同 tools,

client 可以 list、

call、

subscribe 呢啲 capabilities。

[12 | 05:30] 嘉賓 F (expert 曉晴):

Turn 12 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 05:30 · section 3 (MCP Server Lifecycle & Registry)

speaker=F · chars=322 · ts=05:30 · terms=description, everywhere, enterprise, implement, compliant · sentences=4 · clauses=10

Verbatim phrases in this turn: rver 用 JSON-RPC 2.0 over stdio 或者 HTTP 同 client 通訊。 · on calling format 兼容, 即係 tool description 可以 reuse。 · pliant MCP client 用, 即係 once write, everywhere use。

MCP server 用 JSON-RPC 2.0 over stdio 或者 HTTP 同 client 通訊。

First clause (verbatim): MCP server 用 JSON-RPC 2.0 over stdio 或者 HTTP 同 client 通訊。

Last clause (verbatim): 呢個係 massive leverage。

MCP server 用 JSON-RPC 2.0 over stdio 或者 HTTP 同 client 通訊。

Server 定義 tools using JSON Schema,

同 OpenAI function calling format 兼容,

即係 tool description 可以 reuse。

MCP 嘅好處係 tool provider 只需要 implement 一個 MCP server,

就可以被所有 compliant MCP client 用,

即係 once write,

everywhere use。

對於 enterprise tool ecosystem,

呢個係 massive leverage。

[13 | 06:00] 主持 M (host 子謙):

Turn 13 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 06:00 · section 3 (MCP Server Lifecycle & Registry)

speaker=M · chars=315 · ts=06:00 · terms=integrations, filesystem, TypeScript, LangGraph, LangChain · sentences=4 · clauses=15

Verbatim phrases in this turn: 以 build 一個 MCP server, 例如 filesystem MCP、 · database MCP、 · ficial SDK, 同時有 community SDK for Python、

MCP 嘅 adoption 已經 2026 年迅速擴展。

First clause (verbatim): MCP 嘅 adoption 已經 2026 年迅速擴展。

Last clause (verbatim): Rust。

MCP 嘅 adoption 已經 2026 年迅速擴展。

LangGraph 透過 LangChain tool integrations 支援 MCP,

CrewAI 有 growing MCP support,

MAF 同 Google ADK 兩者都原生支援 MCP。

即係話,

developer 可以 build 一個 MCP server,

例如 filesystem MCP、

database MCP、

GitHub MCP,

然後喺多個 framework 上面使用。

Anthropic 提供 official SDK,

同時有 community SDK for Python、

TypeScript、

Go、

Rust。

[14 | 06:30] 嘉賓 F (expert 曉晴):

Turn 14 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 06:30 · section 3 (MCP Server Lifecycle & Registry)

speaker=F · chars=337 · ts=06:30 · terms=single-purpose, architecture, dynamically, filesystem, PostgreSQL · sentences=4 · clauses=17

Verbatim phrases in this turn: er 集中一個 domain, 例如 filesystem MCP server、 · PostgreSQL MCP server、 · , 例如 developer tools MCP server 同時提供 git、

MCP server 嘅 design pattern。

First clause (verbatim): MCP server 嘅 design pattern。

Last clause (verbatim): 適合 plugin architecture。

MCP server 嘅 design pattern。

第一,

single-purpose server,

每個 server 集中一個 domain,

例如 filesystem MCP server、

PostgreSQL MCP server、

Slack MCP server。

第二,

multi-tool server,

一個 server 提供多個 related tools,

例如 developer tools MCP server 同時提供 git、

grep、

find。

第三,

composable server,

server 可以 dynamically load 唔同 module 提供 tools,

適合 plugin architecture。

[15 | 07:00] 主持 M (host 子謙):

Turn 15 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 07:00 · section 3 (MCP Server Lifecycle & Registry)

speaker=M · chars=311 · ts=07:00 · terms=instruction, permission, injection, malicious, implement · sentences=4 · clauses=7

Verbatim phrases in this turn: MCP 嘅 security model。 · 行 tools, 呢個 supply chain 有 prompt injection 嘅 risk。 · ious document 嘅 content 可以指使 LLM 去 call 一個危險嘅 tool。

MCP 嘅 security model。

First clause (verbatim): MCP 嘅 security model。

Last clause (verbatim): host 應該 implement permission system 限制邊啲 tool 對邊個 user 開放。

MCP 嘅 security model。

MCP server 對 host 暴露 tools,

host 對 user 嘅 prompt 嘅 instruction 執行 tools,

呢個 supply chain 有 prompt injection 嘅 risk。

例如一個 malicious document 嘅 content 可以指使 LLM 去 call 一個危險嘅 tool。

MCP 規範要求 server 應該明確 document 工具嘅 effect 同 side effect,

host 應該 implement permission system 限制邊啲 tool 對邊個 user 開放。

[16 | 07:30] 嘉賓 F (expert 曉晴):

Turn 16 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 07:30 · section 3 (MCP Server Lifecycle & Registry)

speaker=F · chars=340 · ts=07:30 · terms=vendor-specific, vendor-neutral, implementation, declarations, multi-vendor · sentences=4 · clauses=10

Verbatim phrases in this turn: MCP 同傳統 function calling 嘅分別。 · declarations, 每個 vendor 有自己嘅 format 同 dispatch 機制。 · rver-side 一個 implementation 被多個 vendor 嘅 client 共享。

MCP 同傳統 function calling 嘅分別。

First clause (verbatim): MCP 同傳統 function calling 嘅分別。

Last clause (verbatim): MCP 顯著降低 tool integration 嘅 cost。

MCP 同傳統 function calling 嘅分別。

Function calling 係 vendor-specific,

例如 OpenAI 嘅 tools array,

Anthropic 嘅 tool use block,

Google 嘅 function declarations,

每個 vendor 有自己嘅 format 同 dispatch 機制。

MCP 係 vendor-neutral standard,

server-side 一個 implementation 被多個 vendor 嘅 client 共享。

對於 enterprise multi-vendor strategy,

MCP 顯著降低 tool integration 嘅 cost。

End-of-section recap (last spoken sentence of MCP Server Lifecycle & Registry): MCP 同傳統 function calling 嘅分別。


Section 4/5 — Tool Use Best Practice

Tool Use 最佳實踐

Section overview: covers turns 17–21 (5 spoken segments).

Topic terms (extracted from spoken text): implementation, list_directory, specification, send_message, search_files, recent_files, capabilities, LLM-assisted, productivity, create_file

Latin/English code-terms in this section (verbatim from speech): implementation, list_directory, specification

Section character total: 1,830 characters across 5 spoken turns.

Section duration estimate: ~2:30 of 12:00 total.

Turns in this section: 17, 18, 19, 20, 21.

First spoken sentence of this section (turn 17, verbatim): MCP 嘅 resource 同 tool 嘅分別。

Average characters per turn (this section): ~366 chars.

Cumulative characters through this section: 6,697 of 7,595 total.

[17 | 08:00] 主持 M (host 子謙):

Turn 17 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 08:00 · section 4 (Tool Use Best Practice)

speaker=M · chars=352 · ts=08:00 · terms=send_message, create_file, capability, resources, resource · sentences=5 · clauses=15

Verbatim phrases in this turn: Resource 係 passive data, 例如 file、 · database record、 · Tool 係 active function, 例如 create_file、

MCP 嘅 resource 同 tool 嘅分別。

First clause (verbatim): MCP 嘅 resource 同 tool 嘅分別。

Last clause (verbatim): 即係 reusable prompt snippets server 可以 expose 俾 client。

MCP 嘅 resource 同 tool 嘅分別。

Resource 係 passive data,

例如 file、

database record、

API response,

適合用 read 嘅 access pattern。

Tool 係 active function,

例如 create_file、

send_message,

適合用 invoke 嘅 access pattern。

MCP client 可以 list、

read resources 同 call tools,

兩個 capability 都喺同一個 server 入面。

MCP 仲有 prompt template,

即係 reusable prompt snippets server 可以 expose 俾 client。

[18 | 08:30] 嘉賓 F (expert 曉晴):

Turn 18 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 08:30 · section 4 (Tool Use Best Practice)

speaker=F · chars=354 · ts=08:30 · terms=implementation, list_directory, search_files, recent_files, capabilities · sentences=4 · clauses=11

Verbatim phrases in this turn: er 通常 implement 以下 tools, list_directory、 · read_file、 · write_file、

MCP server implementation 嘅 practical example。

First clause (verbatim): MCP server implementation 嘅 practical example。

Last clause (verbatim): Client connect 之後可以 browse 同 invoke 呢啲 capabilities。

MCP server implementation 嘅 practical example。

一個 filesystem MCP server 通常 implement 以下 tools,

list_directory、

read_file、

write_file、

search_files,

同埋 resources 例如 recent_files index。

Server 啟動嘅時候 enumerate filesystem 嘅 root directory,

每個 operation 都 enforce permission check,

例如 write_file 限制可寫嘅 directory。

Client connect 之後可以 browse 同 invoke 呢啲 capabilities。

[19 | 09:00] 主持 M (host 子謙):

Turn 19 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 09:00 · section 4 (Tool Use Best Practice)

speaker=M · chars=373 · ts=09:00 · terms=LLM-assisted, capability, completion, filesystem, operation · sentences=3 · clauses=6

Verbatim phrases in this turn: 呢個係 server 用嚟做 LLM-assisted operation 嘅 mechanism。 · ranslate natural language query 做 SQL, 然後再 execute。 · , 確保 server 唔可以 access 超出 granted scope 嘅 resource。

ompletion 喺 host 嘅 context 入面, 呢個係 server 用嚟做 LLM-assisted operation 嘅 mechanism。

First clause (verbatim): MCP 嘅 sampling capability 允許 server request LLM completion 喺 host 嘅 context 入面,

Last clause (verbatim): 確保 server 唔可以 access 超出 granted scope 嘅 resource。

MCP 嘅 sampling capability 允許 server request LLM completion 喺 host 嘅 context 入面,

呢個係 server 用嚟做 LLM-assisted operation 嘅 mechanism。

例如一個 database query builder MCP server 可以 sample host 嘅 LLM 嚟 translate natural language query 做 SQL,

然後再 execute。

MCP 嘅 root capability 允許 server request filesystem 同 network access 嘅 boundary,

確保 server 唔可以 access 超出 granted scope 嘅 resource。

[20 | 09:30] 嘉賓 F (expert 曉晴):

Turn 20 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 09:30 · section 4 (Tool Use Best Practice)

speaker=F · chars=400 · ts=09:30 · terms=specification, productivity, third-party, marketplace, filesystem · sentences=5 · clauses=19

Verbatim phrases in this turn: ic 提供官方 reference servers, 包括 filesystem、 · PostgreSQL、 · Puppeteer、

MCP 嘅 ecosystem 2026 年已經成熟。

First clause (verbatim): MCP 嘅 ecosystem 2026 年已經成熟。

Last clause (verbatim): breaking changes 唔再 frequent。

MCP 嘅 ecosystem 2026 年已經成熟。

Anthropic 提供官方 reference servers,

包括 filesystem、

GitHub、

Slack、

PostgreSQL、

SQLite、

Puppeteer、

Google Drive、

YouTube。

Community 已經 build 數千個 third-party server,

涵蓋 productivity tools、

developer tools、

data sources、

enterprise systems。

Smithery 係 MCP server 嘅 marketplace,

developer 可以 browse 同 install server。

Model Context Protocol 嘅 specification 已經去到穩定,

breaking changes 唔再 frequent。

[21 | 10:00] 主持 M (host 子謙):

Turn 21 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 10:00 · section 4 (Tool Use Best Practice)

speaker=M · chars=351 · ts=10:00 · terms=independent, Conditional, Multi-round, Sequential, reasoning · sentences=5 · clauses=12

Verbatim phrases in this turn: Tool use 嘅 advanced pattern。 · independent tool, 例如同時 query 兩個 API, 然後 combine 結果。 · l tool A 拎 result, 再 base on result 決定 call tool B。

Tool use 嘅 advanced pattern。

First clause (verbatim): Tool use 嘅 advanced pattern。

Last clause (verbatim): 即係同一個 reasoning session 入面 iterate tool call。

Tool use 嘅 advanced pattern。

Parallel tool calling,

即係 agent 一個 step 入面 call 多個 independent tool,

例如同時 query 兩個 API,

然後 combine 結果。

Sequential tool calling,

即係 agent call tool A 拎 result,

再 base on result 決定 call tool B。

Conditional tool calling,

即係 agent 根據 context 揀唔同 tool branch。

Multi-round tool calling,

即係同一個 reasoning session 入面 iterate tool call。

End-of-section recap (last spoken sentence of Tool Use Best Practice): Tool use 嘅 advanced pattern。


Section 5/5 — Wrap-up & Per-Pattern Implementation Preview

總結同 Per-Pattern Implementation 預覽

Section overview: covers turns 22–24 (3 spoken segments).

Topic terms (extracted from spoken text): Supervisor-Worker, Plan-and-Execute, Implementation, optimization, Integration, Per-Pattern, Walkthrough, round-trip, validation, End-to-end

Latin/English code-terms in this section (verbatim from speech): Supervisor-Worker, Plan-and-Execute, Implementation

Section character total: 898 characters across 3 spoken turns.

Section duration estimate: ~1:30 of 12:00 total.

Turns in this section: 22, 23, 24.

First spoken sentence of this section (turn 22, verbatim): Tool use 嘅 cost optimization。

Average characters per turn (this section): ~299 chars.

Cumulative characters through this section: 7,595 of 7,595 total.

[22 | 10:30] 嘉賓 F (expert 曉晴):

Turn 22 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 10:30 · section 5 (Wrap-up & Per-Pattern Implementation Preview)

speaker=F · chars=278 · ts=10:30 · terms=optimization, round-trip, redundant, awareness, parallel · sentences=5 · clauses=12

Verbatim phrases in this turn: Tool use 嘅 cost optimization。 · 第一, batch parallel tool call 去 reduce round-trip。 · 第二, cache tool result 去 avoid redundant call。

Tool use 嘅 cost optimization。第一, batch parallel tool call 去 reduce round-trip。

First clause (verbatim): Tool use 嘅 cost optimization。

Last clause (verbatim): 避免超過 API rate limit 觸發 ban。

Tool use 嘅 cost optimization。

第一,

batch parallel tool call 去 reduce round-trip。

第二,

cache tool result 去 avoid redundant call。

第三,

lazy loading tools,

即係 LLM 只係 load 當前 relevant 嘅 tool schema 嘅 subset,

減 context window 消耗。

第四,

tool 嘅 rate limit awareness,

避免超過 API rate limit 觸發 ban。

[23 | 11:00] 主持 M (host 子謙):

Turn 23 of 24 · speaker M (host 子謙 — opens and closes) · audio timestamp 11:00 · section 5 (Wrap-up & Per-Pattern Implementation Preview)

speaker=M · chars=379 · ts=11:00 · terms=Integration, validation, End-to-end, Regression, AgentBench · sentences=6 · clauses=9

Verbatim phrases in this turn: Tool use 嘅 testing strategy。 · Unit test 每個 tool 嘅 happy path 同 error path。 · t 嘅 contract, 包括 schema validation 同 return format。

Tool use 嘅 testing strategy。Unit test 每個 tool 嘅 happy path 同 error path。

First clause (verbatim): Tool use 嘅 testing strategy。

Last clause (verbatim): 適合 production agent 嘅 regression suite。

Tool use 嘅 testing strategy。

Unit test 每個 tool 嘅 happy path 同 error path。

Integration test tool 同 agent 嘅 contract,

包括 schema validation 同 return format。

End-to-end test 模擬 user query 同 agent 嘅 full reasoning loop。

Regression test 記錄每次 agent run 嘅 tool call sequence,

防止 breaking change。

AgentBench 同 SWE-bench 喺 academic 提供 tool-use benchmark,

適合 production agent 嘅 regression suite。

[24 | 11:30] 嘉賓 F (expert 曉晴):

Turn 24 of 24 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 11:30 · section 5 (Wrap-up & Per-Pattern Implementation Preview)

speaker=F · chars=241 · ts=11:30 · terms=Supervisor-Worker, Plan-and-Execute, Implementation, Per-Pattern, Walkthrough · sentences=2 · clauses=9

Verbatim phrases in this turn: tion Walkthrough, 用 Python code 示範 ReAct、 · Plan-and-Execute、 · Reflexion、

ion, 包括 LangGraph 同 LangChain 嘅 API 用法, 同埋 production deployment 嘅 best practice。

First clause (verbatim): 下堂我哋會深入探討 Per-Pattern Implementation Walkthrough,

Last clause (verbatim): 我哋下期再見。

下堂我哋會深入探討 Per-Pattern Implementation Walkthrough,

用 Python code 示範 ReAct、

Plan-and-Execute、

Reflexion、

Supervisor-Worker 四個 pattern 嘅具體 implementation,

包括 LangGraph 同 LangChain 嘅 API 用法,

同埋 production deployment 嘅 best practice。

多謝收聽第四課,

我哋下期再見。

End-of-section recap (last spoken sentence of Wrap-up & Per-Pattern Implementation Preview): 下堂我哋會深入探討 Per-Pattern Implementation Walkthrough, 用 Python code 示範 ReAct、Plan-and-Execute、Reflexion、Supervisor-Worker 四個 pattern 嘅具體 implementation, 包括 LangGraph 同 LangChain 嘅 API 用法, 同埋 production deployment 嘅 best practice。


End-of-lesson summary

This lesson covered 5 sections across 24 spoken turns (~12 min audio). Below is the final sentence of each section, preserved verbatim from the source podcast script.

  • Opening & Tool Use Basics (turn 04): Tool schema 嘅設計原則。
  • MCP Design Philosophy (turn 10): 好, 講 Model Context Protocol, 即 MCP。
  • MCP Server Lifecycle & Registry (turn 16): MCP 同傳統 function calling 嘅分別。
  • Tool Use Best Practice (turn 21): Tool use 嘅 advanced pattern。
  • Wrap-up & Per-Pattern Implementation Preview (turn 24): 下堂我哋會深入探討 Per-Pattern Implementation Walkthrough, 用 Python code 示範 ReAct、Plan-and-Execute、Reflexion、Supervisor-Worker 四個 pattern 嘅具體 implementation, 包括 LangGraph 同 LangChain 嘅 API 用法, 同埋 production deployment 嘅 best practice。


End of transcript

Total turns in this lesson: 24 spoken segments · ~12 min audio · preserved verbatim from the source podcast script (/opt/data/workspace/projects/ai-agent-course-04/script_raw.json).

Use the audio player above to listen along. The Quiz section below tests comprehension of this lesson.

Source & integrity

  • Source file: script_raw.json (the line-by-line Cantonese dialogue that was TTS-synthesised into the lesson MP3)
  • Fidelity: all 廣東話 text is byte-identical to the source — no translation, no summarisation, no paraphrasing
  • Markdown structure added: speaker labels, section headings, timestamp markers, per-turn metadata callouts (speaker id, char count, timestamp, verbatim terms), per-section overview blocks, sentence-level line breaks (for readability only)
  • Rendering: react-markdown + remark-gfm in TranscriptPanel.tsx; dark theme & mobile-responsive via Tailwind prose

Integrity checksum

  • Total spoken characters (across all turns): 7,595
  • Total spoken sentences (across all turns): 97
  • Total spoken clauses (across all turns): 281
  • Speaker turn distribution: M=12 · F=12

Lesson quiz · 33 questions

Answered 0 / 33
  1. Question 1

    Decomposition buys:

  2. Question 2

    A critical step failure should trigger:

  3. Question 3

    A non-critical step failure should trigger:

  4. Question 4

    Plans as DAGs allow:

  5. Question 5

    Plans as state machines allow:

  6. Question 6

    A replan should be triggered on:

  7. Question 7

    A replan should NOT be triggered on:

  8. Question 8

    The simplest plan representation is:

  9. Question 9

    Decomposition is most valuable when:

  10. Question 10

    Plan repair differs from replanning in that:

  11. Question 11

    A "stale plan" failure occurs when:

  12. Question 12

    The cleanest way to express "if X then Y else Z" in a plan is:

  13. Question 13

    Why decompose "send email to CFO about Q3" into more steps?

  14. Question 14

    A plan that never replans is:

  15. Question 15

    For a DAG plan, execution order is determined by:

  16. Question 16

    Plan-and-Execute vs ReAct trade-off:

  17. Question 17

    A "step result" in a plan typically includes:

  18. Question 18

    For a 50-step migration, the right plan representation is:

  19. Question 19

    The "observe and replan" pattern is triggered when:

  20. Question 20

    Decomposition reduces:

  21. Question 21

    A "sub-task" in agent planning is:

  22. Question 22

    The biggest risk of an over-decomposed plan:

  23. Question 23

    Plans can be encoded as:

  24. Question 24

    A planner that uses an LLM to decompose should:

  25. Question 25

    Hierarchical planning decomposes:

  26. Question 26

    For "summarize the last 10 customer interviews", a good plan:

  27. Question 27

    A replan should preserve:

  28. Question 28

    A common failure of plan-and-execute is:

  29. Question 29

    Plan verification before execution catches:

  30. Question 30

    The right granularity for a plan step:

  31. Question 31

    A "plan repair" differs from a "replan" by:

  32. Question 32

    State machines for plans shine when:

  33. Question 33

    For new user input mid-plan, the right move is:

33 unanswered