Lesson 5: Per-Pattern Implementation Walkthrough — Full Spoken Transcript (Cantonese)
Original podcast: Cantonese dialogue between two speakers (M = 主持 host 子謙, F = 嘉賓 expert 曉晴). Total spoken duration: ~14 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 5 of 8 · learnagent.lmmlab.com Topic (EN): Python code for ReAct, Plan-and-Execute, Reflexion, Supervisor-Worker, Workflow Graph. Topic (粵): 五大 pattern 嘅 Python 實作。 Speakers: 主持 M (host 子謙) and 嘉賓 F (expert 曉晴) · 25 spoken turns · ~14 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 & ReAct Implementation (粵: 開場同 ReAct 實作) — turn 01 onwards
- 2. Plan-and-Execute & Reflexion Implementation (粵: Plan-and-Execute 同 Reflexion 實作) — turn 05 onwards
- 3. Supervisor-Worker & Workflow Graph Implementation (粵: Supervisor-Worker 同 Workflow Graph 實作) — turn 11 onwards
- 4. Production Considerations (粵: Production 考量) — turn 17 onwards
- 5. Wrap-up & Evaluation Preview (粵: 總結同 Evaluation 預覽) — turn 23 onwards
Section 1/5 — Opening & ReAct Implementation
開場同 ReAct 實作
Section overview: covers turns 01–04 (4 spoken segments).
Topic terms (extracted from spoken text): create_react_agent, langgraph.prebuilt, Supervisor-Worker, Plan-and-Execute, init_chat_model, Implementation, max_iterations, token-by-token, SystemMessage, HumanMessage
Latin/English code-terms in this section (verbatim from speech): create_react_agent, langgraph.prebuilt, Supervisor-Worker
Section character total: 994 characters across 4 spoken turns.
Section duration estimate: ~2:14 of 14: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): ~248 chars.
Cumulative characters through this section: 994 of 8,216 total.
[01 | 00:00] 主持 M (host 子謙):
Turn 1 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 00:00 · section 1 (Opening & ReAct Implementation)
speaker=M · chars=199 · ts=00:00 · terms=Supervisor-Worker, Plan-and-Execute, Implementation, Per-Pattern, Walkthrough · sentences=3 · clauses=9
Verbatim phrases in this turn: tion Walkthrough, 用 Python code 示範 ReAct、 · Plan-and-Execute、 · Reflexion、
各位同學早晨, 我係子謙。歡迎收聽第五課。
First clause (verbatim): 各位同學早晨,
Last clause (verbatim): 主要用 LangGraph 同 LangChain 嘅 API。
各位同學早晨,
我係子謙。
歡迎收聽第五課。
今日嘅主題係 Per-Pattern Implementation Walkthrough,
用 Python code 示範 ReAct、
Plan-and-Execute、
Reflexion、
Supervisor-Worker 四個 pattern 嘅具體 implementation,
主要用 LangGraph 同 LangChain 嘅 API。
[02 | 00:33] 嘉賓 F (expert 曉晴):
Turn 2 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 00:33 · section 1 (Opening & ReAct Implementation)
speaker=F · chars=109 · ts=00:33 · terms=contract, pattern, combine, project, tool · sentences=3 · clauses=6
Verbatim phrases in this turn: 第一堂講咗 pattern 嘅抽象理論, 第四課講咗 tool use 嘅 contract。 · 日就將兩個 combine 落具體 code, 令你可以直接 copy 落自己嘅 project 用。
大家好, 我係曉晴。第一堂講咗 pattern 嘅抽象理論, 第四課講咗 tool use 嘅 contract。
First clause (verbatim): 大家好,
Last clause (verbatim): 令你可以直接 copy 落自己嘅 project 用。
大家好,
我係曉晴。
第一堂講咗 pattern 嘅抽象理論,
第四課講咗 tool use 嘅 contract。
今日就將兩個 combine 落具體 code,
令你可以直接 copy 落自己嘅 project 用。
[03 | 01:07] 主持 M (host 子謙):
Turn 3 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 01:07 · section 1 (Opening & ReAct Implementation)
speaker=M · chars=325 · ts=01:07 · terms=create_react_agent, langgraph.prebuilt, init_chat_model, implementation, identifier · sentences=4 · clauses=11
Verbatim phrases in this turn: prebuilt 引入 create_react_agent, 然後 model、 · 首先講 ReAct 嘅 LangGraph implementation。 · react_agent 嘅 prebuilt function, 係最簡單嘅 entry point。
首先講 ReAct 嘅 LangGraph implementation。
First clause (verbatim): 首先講 ReAct 嘅 LangGraph implementation。
Last clause (verbatim): tools 等於 list of tool function。
首先講 ReAct 嘅 LangGraph implementation。
LangGraph 提供 create_react_agent 嘅 prebuilt function,
係最簡單嘅 entry point。
基本 skeleton 係,
由 langgraph.prebuilt 引入 create_react_agent,
然後 model、
tools、
prompt 傳入去。
即係 from langgraph.prebuilt import create_react_agent,
model 等於 init_chat_model 或者 string identifier,
tools 等於 list of tool function。
[04 | 01:40] 嘉賓 F (expert 曉晴):
Turn 4 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 01:40 · section 1 (Opening & ReAct Implementation)
speaker=F · chars=361 · ts=01:40 · terms=max_iterations, token-by-token, SystemMessage, HumanMessage, agent.stream · sentences=4 · clauses=16
Verbatim phrases in this turn: 係 list of message dicts, 例如 HumanMessage、 · SystemMessage、 · AIMessage、
ReAct agent 嘅 invoke 嘅 usage。
First clause (verbatim): ReAct agent 嘅 invoke 嘅 usage。
Last clause (verbatim): 包括 tool call start 同 finish。
ReAct agent 嘅 invoke 嘅 usage。
Agent 接受 messages,
係 list of message dicts,
例如 HumanMessage、
SystemMessage、
AIMessage、
ToolMessage。
當 invoke 嘅時候,
agent 會 iterate thought、
action、
observation loop,
直至 task done 或者 hit max_iterations。
如果要 stream token-by-token,
可以用 agent.stream 嘅 mode values,
mode values 嘅 stream mode 會 yield 每個 state change,
包括 tool call start 同 finish。
End-of-section recap (last spoken sentence of Opening & ReAct Implementation): ReAct agent 嘅 invoke 嘅 usage。
Section 2/5 — Plan-and-Execute & Reflexion Implementation
Plan-and-Execute 同 Reflexion 實作
Section overview: covers turns 05–10 (6 spoken segments).
Topic terms (extracted from spoken text): PostgresSaver.from_conn_string, langgraph.checkpoint.postgres, multi-conversation, Human-in-the-loop, interrupt_before, Plan-and-Execute, straightforward, implementation, customization, PostgresSaver
Latin/English code-terms in this section (verbatim from speech): PostgresSaver.from_conn_string, langgraph.checkpoint.postgres, multi-conversation
Section character total: 2,037 characters across 6 spoken turns.
Section duration estimate: ~3:21 of 14:00 total.
Turns in this section: 05, 06, 07, 08, 09, 10.
First spoken sentence of this section (turn 05, verbatim): ReAct agent 嘅 customization。
Average characters per turn (this section): ~339 chars.
Cumulative characters through this section: 3,031 of 8,216 total.
[05 | 02:14] 主持 M (host 子謙):
Turn 5 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 02:14 · section 2 (Plan-and-Execute & Reflexion Implementation)
speaker=M · chars=390 · ts=02:14 · terms=Human-in-the-loop, interrupt_before, customization, checkpointer, conversation · sentences=5 · clauses=14
Verbatim phrases in this turn: ReAct agent 嘅 customization。 · er 做 conversation memory, 跨 invoke 嘅 state persist。 · es, 例如 trim conversation history 或者 inject context。
ReAct agent 嘅 customization。
First clause (verbatim): ReAct agent 嘅 customization。
Last clause (verbatim): 等 human approve。
ReAct agent 嘅 customization。
Memory,
可以加 checkpointer 例如 MemorySaver 做 conversation memory,
跨 invoke 嘅 state persist。
Pre-model hook,
可以加一個 node 喺 model call 之前 modify messages,
例如 trim conversation history 或者 inject context。
Post-model hook,
加一個 node 喺 model call 之後,
例如 log 或者 trigger validation。
Human-in-the-loop,
加 interrupt_before 喺 sensitive tool,
即係 tool call 之前 pause,
等 human approve。
[06 | 02:48] 嘉賓 F (expert 曉晴):
Turn 6 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 02:48 · section 2 (Plan-and-Execute & Reflexion Implementation)
speaker=F · chars=363 · ts=02:48 · terms=PostgresSaver.from_conn_string, langgraph.checkpoint.postgres, multi-conversation, PostgresSaver, checkpoint_ns · sentences=3 · clauses=7
Verbatim phrases in this turn: 因為 MemorySaver 係 in-memory, restart 之後會 loss state。 · gresSaver.from_conn_string 用 connection string 初始化。 · ns, 支援 multi-tenant 同 multi-conversation isolation。
checkpointer 做 durable state, 因為 MemorySaver 係 in-memory, restart 之後會 loss state。
First clause (verbatim): ReAct 嘅 production deployment 通常配 PostgreSQL checkpointer 做 durable state,
Last clause (verbatim): 支援 multi-tenant 同 multi-conversation isolation。
ReAct 嘅 production deployment 通常配 PostgreSQL checkpointer 做 durable state,
因為 MemorySaver 係 in-memory,
restart 之後會 loss state。
PostgreSQL checkpoint 嘅 setup 係 from langgraph.checkpoint.postgres import PostgresSaver,
然後 PostgresSaver.from_conn_string 用 connection string 初始化。
Checkpointer 接受 thread_id 同 checkpoint_ns,
支援 multi-tenant 同 multi-conversation isolation。
[07 | 03:21] 主持 M (host 子謙):
Turn 7 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 03:21 · section 2 (Plan-and-Execute & Reflexion Implementation)
speaker=M · chars=359 · ts=03:21 · terms=Plan-and-Execute, implementation, observation, LangGraph, replanner · sentences=6 · clauses=14
Verbatim phrases in this turn: Plan-and-Execute 通常有 planner、 · executor、 · 好, 第二個 pattern, Plan-and-Execute 嘅 implementation。
好, 第二個 pattern, Plan-and-Execute 嘅 implementation。
First clause (verbatim): 好,
Last clause (verbatim): 決定繼續執行或者重新 plan。
好,
第二個 pattern,
Plan-and-Execute 嘅 implementation。
LangGraph 唔似 ReAct 有 prebuilt function,
所以需要 explicit 寫 graph。
Plan-and-Execute 通常有 planner、
executor、
replanner 三個 nodes。
Planner 接受 messages 同 plan state,
output 一個 ordered list of steps。
Executor 接受 current step 同 tools,
執行 step 同 return observation。
Replanner 接受 completed steps 同 failed steps,
決定繼續執行或者重新 plan。
[08 | 03:55] 嘉賓 F (expert 曉晴):
Turn 8 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 03:55 · section 2 (Plan-and-Execute & Reflexion Implementation)
speaker=F · chars=279 · ts=03:55 · terms=Plan-and-Execute, conditional, past_steps, TypedDict, replanner · sentences=6 · clauses=10
Verbatim phrases in this turn: State 入面有 messages、 · past_steps、 · Plan-and-Execute 嘅 state 通常用 TypedDict 定義。
Plan-and-Execute 嘅 state 通常用 TypedDict 定義。
First clause (verbatim): Plan-and-Execute 嘅 state 通常用 TypedDict 定義。
Last clause (verbatim): Graph 嘅 conditional edge 由 replanner decide 去 end node 還是 back to executor。
Plan-and-Execute 嘅 state 通常用 TypedDict 定義。
State 入面有 messages、
plan、
past_steps、
response。
Plan 係 list of strings 或者 list of dicts。
Past steps 係 list of tuples,
每個 tuple 係 step 同 result。
Response 係 final answer。
Graph 嘅 conditional edge 由 replanner decide 去 end node 還是 back to executor。
[09 | 04:28] 主持 M (host 子謙):
Turn 9 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 04:28 · section 2 (Plan-and-Execute & Reflexion Implementation)
speaker=M · chars=294 · ts=04:28 · terms=implementation, past_steps, Replanner, messages, response · sentences=4 · clauses=14
Verbatim phrases in this turn: mplementation 通常係一個 LLM call 接受 messages、 · sages、plan、past_steps, output 一個 response 或者新 plan。 · 如果 plan 已經 complete, output response 同 end node。
entation 通常係一個 LLM call 接受 messages、plan、past_steps, output 一個 response 或者新 plan。
First clause (verbatim): Replanner 嘅 implementation 通常係一個 LLM call 接受 messages、
Last clause (verbatim): 或者 finish。
Replanner 嘅 implementation 通常係一個 LLM call 接受 messages、
plan、
past_steps,
output 一個 response 或者新 plan。
如果 plan 已經 complete,
output response 同 end node。
如果 step 失敗,
output revised plan 取代原來 plan。
Replanner prompt 要 explicit,
例如你係一個 replanner,
given 過去嘅 steps 同 results,
decide 要繼續,
重新 plan,
或者 finish。
[10 | 05:02] 嘉賓 F (expert 曉晴):
Turn 10 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 05:02 · section 2 (Plan-and-Execute & Reflexion Implementation)
speaker=F · chars=352 · ts=05:02 · terms=Plan-and-Execute, straightforward, optimization, granularity, competitor · sentences=3 · clauses=7
Verbatim phrases in this turn: Plan-and-Execute 嘅 cost optimization。 · depth, 但 execution 通常係 straightforward 嘅 tool call。 · y name 更加 robust 但需要 executor 自己 figure out detail。
Plan-and-Execute 嘅 cost optimization。
First clause (verbatim): Plan-and-Execute 嘅 cost optimization。
Last clause (verbatim): 高 level plan 例如 research competitor 比起低 level plan 例如 search company name 更加 robust 但需要 executor 自己 figure out detail。
Plan-and-Execute 嘅 cost optimization。
Planner 可以用 capable model 例如 Opus 5 或者 Sonnet 5,
Executor 可以用 cheap model 例如 Luna 或者 Mini,
因為 planning 需要 reasoning depth,
但 execution 通常係 straightforward 嘅 tool call。
Plan 嘅 granularity 要 control,
高 level plan 例如 research competitor 比起低 level plan 例如 search company name 更加 robust 但需要 executor 自己 figure out detail。
End-of-section recap (last spoken sentence of Plan-and-Execute & Reflexion Implementation): Plan-and-Execute 嘅 cost optimization。
Section 3/5 — Supervisor-Worker & Workflow Graph Implementation
Supervisor-Worker 同 Workflow Graph 實作
Section overview: covers turns 11–16 (6 spoken segments).
Topic terms (extracted from spoken text): Supervisor-Worker, Plan-and-Execute, Critic-augmented, implementation, research_agent, reviewer_agent, self-critique, sanitization, writer_agent, improvement
Latin/English code-terms in this section (verbatim from speech): Supervisor-Worker, Plan-and-Execute, Critic-augmented
Section character total: 2,005 characters across 6 spoken turns.
Section duration estimate: ~3:21 of 14:00 total.
Turns in this section: 11, 12, 13, 14, 15, 16.
First spoken sentence of this section (turn 11, verbatim): 好, 第三個 pattern, Reflexion 嘅 implementation。
Average characters per turn (this section): ~334 chars.
Cumulative characters through this section: 5,036 of 8,216 total.
[11 | 05:36] 主持 M (host 子謙):
Turn 11 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 05:36 · section 3 (Supervisor-Worker & Workflow Graph Implementation)
speaker=M · chars=243 · ts=05:36 · terms=Plan-and-Execute, implementation, reflection, Reflexion, pattern · sentences=3 · clauses=10
Verbatim phrases in this turn: 好, 第三個 pattern, Reflexion 嘅 implementation。 · eAct 或者 Plan-and-Execute 做底, 外面再加 reflection layer。 · ct reflection, 再 retry with reflection 喺 prompt 入面。
好, 第三個 pattern, Reflexion 嘅 implementation。
First clause (verbatim): 好,
Last clause (verbatim): 再 retry with reflection 喺 prompt 入面。
好,
第三個 pattern,
Reflexion 嘅 implementation。
Reflexion 通常 wrap 其他 pattern,
即係 ReAct 或者 Plan-and-Execute 做底,
外面再加 reflection layer。
最簡單嘅 implementation 係做 retry loop,
agent 第一次 attempt,
失敗嘅話 collect reflection,
再 retry with reflection 喺 prompt 入面。
[12 | 06:09] 嘉賓 F (expert 曉晴):
Turn 12 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 06:09 · section 3 (Supervisor-Worker & Workflow Graph Implementation)
speaker=F · chars=326 · ts=06:09 · terms=self-critique, improvement, reflection, suggestion, Reflexion · sentences=3 · clauses=9
Verbatim phrases in this turn: 己嘅 previous attempt, output improvement suggestion。 · eas for improvement, write 2-3 sentence reflection。 · ory buffer, 下次 attempt 嘅 prompt prepend reflection。
可以係 self-critique, 即係 LLM 評估自己嘅 previous attempt, output improvement suggestion。
First clause (verbatim): Reflexion 嘅 reflection generator 可以係 self-critique,
Last clause (verbatim): 下次 attempt 嘅 prompt prepend reflection。
Reflexion 嘅 reflection generator 可以係 self-critique,
即係 LLM 評估自己嘅 previous attempt,
output improvement suggestion。
Reflection prompt 要 explicit,
例如 review 你剛才嘅 response,
identify mistakes 同 areas for improvement,
write 2-3 sentence reflection。
Reflection 可以 store 喺 episodic memory buffer,
下次 attempt 嘅 prompt prepend reflection。
[13 | 06:43] 主持 M (host 子謙):
Turn 13 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 06:43 · section 3 (Supervisor-Worker & Workflow Graph Implementation)
speaker=M · chars=372 · ts=06:43 · terms=Critic-augmented, Multi-trial, reflection, Reflexion, objective · sentences=5 · clauses=11
Verbatim phrases in this turn: Reflexion 嘅 advanced pattern。 · ect 多次, 例如每次 reflection 都 build 喺上一次 reflection 上面。 · primary agent 嘅 output, 提供 more objective critique。
Reflexion 嘅 advanced pattern。
First clause (verbatim): Reflexion 嘅 advanced pattern。
Last clause (verbatim): 適合有 label 嘅 task。
Reflexion 嘅 advanced pattern。
Multi-trial reflection,
即係 reflect 多次,
例如每次 reflection 都 build 喺上一次 reflection 上面。
Critic-augmented reflection,
即係另一個 agent 或者 tool 評估 primary agent 嘅 output,
提供 more objective critique。
例如 unit test failure message 可以自動做 reflection source。
External evaluator reflection,
即係用 ground truth 或者 expert feedback 做 reflection source,
適合有 label 嘅 task。
[14 | 07:16] 嘉賓 F (expert 曉晴):
Turn 14 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 07:16 · section 3 (Supervisor-Worker & Workflow Graph Implementation)
speaker=F · chars=362 · ts=07:16 · terms=sanitization, aggregation, reflections, concatenate, escalation · sentences=5 · clauses=12
Verbatim phrases in this turn: Reflexion 嘅 best practice。 · etry cap, 例如最多 retry 三次, 否則 fallback to escalation。 · e add 去 memory, 因為 malformed reflection 會污染 memory。
Reflexion 嘅 best practice。Retry cap, 例如最多 retry 三次, 否則 fallback to escalation。
First clause (verbatim): Reflexion 嘅 best practice。
Last clause (verbatim): 否則 prompt 會 redundant 同 contradict。
Reflexion 嘅 best practice。
Retry cap,
例如最多 retry 三次,
否則 fallback to escalation。
Reflection sanitization,
即係 reflection entry 要 verified before add 去 memory,
因為 malformed reflection 會污染 memory。
Reflection expiry,
即係 old reflection 要 evict 因為 context 可能 stale。
Reflection aggregation,
即係多個 reflections 要 synthesize 唔係簡單 concatenate,
否則 prompt 會 redundant 同 contradict。
[15 | 07:50] 主持 M (host 子謙):
Turn 15 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 07:50 · section 3 (Supervisor-Worker & Workflow Graph Implementation)
speaker=M · chars=373 · ts=07:50 · terms=Supervisor-Worker, implementation, research_agent, Supervisor, competitor · sentences=5 · clauses=12
Verbatim phrases in this turn: 好, 第四個 pattern, Supervisor-Worker 嘅 implementation。 · 通常係主 graph, 每個 Worker 係 subgraph 或者 function node。 · r is research_agent, task is research competitor X。
好, 第四個 pattern, Supervisor-Worker 嘅 implementation。
First clause (verbatim): 好,
Last clause (verbatim): Supervisor 收到 worker result 之後決定 next worker 或者 synthesize final answer。
好,
第四個 pattern,
Supervisor-Worker 嘅 implementation。
LangGraph 入面 Supervisor 通常係主 graph,
每個 Worker 係 subgraph 或者 function node。
Supervisor node 嘅 output 係 worker selection 同 task payload,
例如 next worker is research_agent,
task is research competitor X。
Worker node 接受 task payload,
執行 task,
return result。
Supervisor 收到 worker result 之後決定 next worker 或者 synthesize final answer。
[16 | 08:24] 嘉賓 F (expert 曉晴):
Turn 16 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 08:24 · section 3 (Supervisor-Worker & Workflow Graph Implementation)
speaker=F · chars=329 · ts=08:24 · terms=Supervisor-Worker, research_agent, reviewer_agent, writer_agent, conditional · sentences=4 · clauses=8
Verbatim phrases in this turn: rker 嘅 conditional edge 通常由 Supervisor 嘅 output 控制。 · h, writer_agent 做 writing, reviewer_agent 做 review。 · decide which worker to call next 或者 return FINISH。
Supervisor-Worker 嘅 conditional edge 通常由 Supervisor 嘅 output 控制。
First clause (verbatim): Supervisor-Worker 嘅 conditional edge 通常由 Supervisor 嘅 output 控制。
Last clause (verbatim): Supervisor 通常用 capable model 因為 routing decision critical。
Supervisor-Worker 嘅 conditional edge 通常由 Supervisor 嘅 output 控制。
Supervisor 嘅 prompt 要 define workers 同佢哋嘅 capability,
例如你有一個 research_agent 做 research,
writer_agent 做 writing,
reviewer_agent 做 review。
Given current state,
decide which worker to call next 或者 return FINISH。
Supervisor 通常用 capable model 因為 routing decision critical。
End-of-section recap (last spoken sentence of Supervisor-Worker & Workflow Graph Implementation): Supervisor-Worker 嘅 conditional edge 通常由 Supervisor 嘅 output 控制。
Section 4/5 — Production Considerations
Production 考量
Section overview: covers turns 17–22 (6 spoken segments).
Topic terms (extracted from spoken text): create_react_agent, Supervisor-Worker, research_agent, writer_agent, out-of-scope, restriction, independent, conditional, exponential, multi-agent
Latin/English code-terms in this section (verbatim from speech): create_react_agent, Supervisor-Worker, research_agent
Section character total: 2,096 characters across 6 spoken turns.
Section duration estimate: ~3:21 of 14:00 total.
Turns in this section: 17, 18, 19, 20, 21, 22.
First spoken sentence of this section (turn 17, verbatim): Worker 嘅 design。
Average characters per turn (this section): ~349 chars.
Cumulative characters through this section: 7,132 of 8,216 total.
[17 | 08:57] 主持 M (host 子謙):
Turn 17 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 08:57 · section 4 (Production Considerations)
speaker=M · chars=291 · ts=08:57 · terms=Supervisor, reasoning, subgraph, sub-task, contract · sentences=5 · clauses=10
Verbatim phrases in this turn: Worker 嘅 design。 · r 可以係獨立 agent 例如 ReAct agent, 適合需要 tool use 嘅 task。 · r 可以係 simple LLM call, 適合 pure reasoning 例如 review。
Worker 嘅 design。Worker 可以係獨立 agent 例如 ReAct agent, 適合需要 tool use 嘅 task。
First clause (verbatim): Worker 嘅 design。
Last clause (verbatim): Supervisor 要知道點樣 format input 同 parse output。
Worker 嘅 design。
Worker 可以係獨立 agent 例如 ReAct agent,
適合需要 tool use 嘅 task。
Worker 可以係 simple LLM call,
適合 pure reasoning 例如 review。
Worker 可以係 subgraph,
即係 Worker 本身有自己嘅 control flow,
適合 complex sub-task。
每個 Worker 嘅 input 同 output 要有 clear contract,
Supervisor 要知道點樣 format input 同 parse output。
[18 | 09:31] 嘉賓 F (expert 曉晴):
Turn 18 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 09:31 · section 4 (Production Considerations)
speaker=F · chars=432 · ts=09:31 · terms=create_react_agent, Supervisor-Worker, research_agent, writer_agent, out-of-scope · sentences=4 · clauses=8
Verbatim phrases in this turn: Worker 嘅 tool restriction。 · h, writer_agent 嘅 tool set 係 file write 同 template。 · h prebuilt 嘅 create_react_agent 入面 tools parameter。
Worker 嘅 tool restriction。
First clause (verbatim): Worker 嘅 tool restriction。
Last clause (verbatim): 即使 Supervisor 嘅 prompt 被 injection 嘗試 route worker 去 call out-of-scope tools。
Worker 嘅 tool restriction。
Supervisor-Worker 嘅 security advantage 係 role-based tool restriction,
即係 research_agent 嘅 tool set 係 search 同 fetch,
writer_agent 嘅 tool set 係 file write 同 template。
Tool restriction 通常係 worker 嘅 definition 入面 explicit list tools,
例如 langgraph prebuilt 嘅 create_react_agent 入面 tools parameter。
Worker 唔可以 access 其他 worker 嘅 tools,
即使 Supervisor 嘅 prompt 被 injection 嘗試 route worker 去 call out-of-scope tools。
[19 | 10:04] 主持 M (host 子謙):
Turn 19 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 10:04 · section 4 (Production Considerations)
speaker=M · chars=352 · ts=10:04 · terms=independent, conditional, Supervisor, competitor, wall-clock · sentences=4 · clauses=9
Verbatim phrases in this turn: Worker 嘅 parallel execution。 · ompetitor, 可以 parallel execution 減 wall-clock time。 · parallel run, 全部完成之後 join node 收 result 再 continue。
Worker 嘅 parallel execution。
First clause (verbatim): Worker 嘅 parallel execution。
Last clause (verbatim): synthesize 全部 worker result。
Worker 嘅 parallel execution。
如果 Supervisor 派多個 worker 去做 independent task,
例如 research 三個 competitor,
可以 parallel execution 減 wall-clock time。
LangGraph 用 Send 嘅 conditional edge 實現 fan-out,
即係 Supervisor node 之後 multiple worker nodes parallel run,
全部完成之後 join node 收 result 再 continue。
Join node 通常係 Supervisor 嘅 second pass,
synthesize 全部 worker result。
[20 | 10:38] 嘉賓 F (expert 曉晴):
Turn 20 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 10:38 · section 4 (Production Considerations)
speaker=F · chars=306 · ts=10:38 · terms=Supervisor-Worker, independent, transcript, supervisor, debugging · sentences=4 · clauses=11
Verbatim phrases in this turn: Trace 入面有每個 node 嘅 input、 · Supervisor-Worker 嘅 debugging tip。 · endent execution, failure 可以 spread 去多個 transcript。
Supervisor-Worker 嘅 debugging tip。
First clause (verbatim): Supervisor-Worker 嘅 debugging tip。
Last clause (verbatim): debug 經常係 review supervisor 嘅 routing decision 同 worker 嘅 tool call sequence。
Supervisor-Worker 嘅 debugging tip。
因為每個 Worker 係 independent execution,
failure 可以 spread 去多個 transcript。
建議開 LangGraph Studio,
視覺化個 graph 同 trace 每個 node 嘅 state,
可以快速搵到邊個 worker 失敗。
Trace 入面有每個 node 嘅 input、
output、
latency、
status,
debug 經常係 review supervisor 嘅 routing decision 同 worker 嘅 tool call sequence。
[21 | 11:12] 主持 M (host 子謙):
Turn 21 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 11:12 · section 4 (Production Considerations)
speaker=M · chars=367 · ts=11:12 · terms=exponential, Production, deployment, decorator, transient · sentences=6 · clauses=18
Verbatim phrases in this turn: ion deployment 嘅 best practice 第一, retry 同 backoff。 · y with backoff, max retry 3 次, exponential backoff。 · meout, 例如 30 秒, 否則 hang 住嘅 worker 會 block 整個 graph。
Production deployment 嘅 best practice 第一, retry 同 backoff。
First clause (verbatim): Production deployment 嘅 best practice 第一,
Last clause (verbatim): 防止 infinite loop。
Production deployment 嘅 best practice 第一,
retry 同 backoff。
每個 tool call 包一層 retry decorator,
例如 tenacity library,
transient error retry with backoff,
max retry 3 次,
exponential backoff。
第二,
timeout。
每一個 node 嘅 execution 應該有 timeout,
例如 30 秒,
否則 hang 住嘅 worker 會 block 整個 graph。
第三,
step cap。
Graph 嘅 total step 應該有 hard limit,
例如 50 steps,
超過即 terminate,
防止 infinite loop。
[22 | 11:45] 嘉賓 F (expert 曉晴):
Turn 22 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 11:45 · section 4 (Production Considerations)
speaker=F · chars=348 · ts=11:45 · terms=multi-agent, consumption, structured, production, LangSmith · sentences=5 · clauses=14
Verbatim phrases in this turn: LangSmith, log level 要 include node name、 · thread_id、 · 第四, structured logging。
第四, structured logging。
First clause (verbatim): 第四,
Last clause (verbatim): 適合 production incident response。
第四,
structured logging。
每個 node 嘅 input 同 output 要 log 去 central logging system 例如 LangSmith,
log level 要 include node name、
thread_id、
latency、
status。
Token usage 要 track,
因為 multi-agent system 嘅 token consumption 容易失控。
第五,
kill switch。
即係 manual override 可以 pause 同 inspect 一個 running graph,
LangGraph 嘅 interrupt 機制支持,
適合 production incident response。
End-of-section recap (last spoken sentence of Production Considerations): 第四, structured logging。
Section 5/5 — Wrap-up & Evaluation Preview
總結同 Evaluation 預覽
Section overview: covers turns 23–25 (3 spoken segments).
Topic terms (extracted from spoken text): create_react_agent, high-availability, Supervisor-Worker, Plan-and-Execute, quality-critical, multi-specialist, implementation, medium-horizon, Terminal-Bench, observability
Latin/English code-terms in this section (verbatim from speech): create_react_agent, high-availability, Supervisor-Worker
Section character total: 1,084 characters across 3 spoken turns.
Section duration estimate: ~1:40 of 14:00 total.
Turns in this section: 23, 24, 25.
First spoken sentence of this section (turn 23, verbatim): LangGraph Platform 嘅 deployment。
Average characters per turn (this section): ~361 chars.
Cumulative characters through this section: 8,216 of 8,216 total.
[23 | 12:19] 主持 M (host 子謙):
Turn 23 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 12:19 · section 5 (Wrap-up & Evaluation Preview)
speaker=M · chars=375 · ts=12:19 · terms=high-availability, observability, auto-scaling, integration, Self-hosted · sentences=5 · clauses=10
Verbatim phrases in this turn: Features 包括 auto-scaling、 · persistent storage、 · horizontal scaling、
LangGraph Platform 嘅 deployment。
First clause (verbatim): LangGraph Platform 嘅 deployment。
Last clause (verbatim): LangGraph Platform 適合 production agent 嘅 high-availability 同 compliance requirement。
LangGraph Platform 嘅 deployment。
LangGraph Platform 係 managed service 提供長-running stateful agent 嘅 production deployment。
Features 包括 auto-scaling、
persistent storage、
horizontal scaling、
US 同 EU data residency、
observability integration。
Self-hosted option 亦都提供,
可以 deploy 喺 Kubernetes cluster 入面。
LangGraph Platform 適合 production agent 嘅 high-availability 同 compliance requirement。
[24 | 12:52] 嘉賓 F (expert 曉晴):
Turn 24 of 25 · speaker F (expert 曉晴 — explains concepts and trade-offs) · audio timestamp 12:52 · section 5 (Wrap-up & Evaluation Preview)
speaker=F · chars=511 · ts=12:52 · terms=create_react_agent, Supervisor-Worker, Plan-and-Execute, quality-critical, multi-specialist · sentences=6 · clauses=17
Verbatim phrases in this turn: n task 需要 pre-execution audit, 寫 planner、 · executor、 · Production deployment 必備 retry、
Pattern implementation 嘅總結。
First clause (verbatim): Pattern implementation 嘅總結。
Last clause (verbatim): LangGraph Platform 提供 managed deployment。
Pattern implementation 嘅總結。
ReAct 適合 prototype 同 short task,
用 create_react_agent 幾分鐘就 work。
Plan-and-Execute 適合 medium-horizon task 需要 pre-execution audit,
寫 planner、
executor、
replanner 三個 node。
Reflexion 適合 quality-critical 有 retry budget,
wrap ReAct 或者 Plan-and-Execute 加 reflection layer。
Supervisor-Worker 適合 multi-specialist task,
用 conditional edge 同 parallel execution 嘅 LangGraph graph。
Production deployment 必備 retry、
timeout、
step cap、
structured logging、
kill switch,
LangGraph Platform 提供 managed deployment。
[25 | 13:26] 主持 M (host 子謙):
Turn 25 of 25 · speaker M (host 子謙 — opens and closes) · audio timestamp 13:26 · section 5 (Wrap-up & Evaluation Preview)
speaker=M · chars=198 · ts=13:26 · terms=Terminal-Bench, reproducible, Evaluation, Benchmarks, AgentBench · sentences=2 · clauses=7
Verbatim phrases in this turn: nt Evaluation 同 Benchmarks, 包括 SWE-bench、 · AgentBench、 · 你嘅 agent 可以 reproducible 嘅測試同 regression detection。
點樣 design custom eval suite 等到你嘅 agent 可以 reproducible 嘅測試同 regression detection。
First clause (verbatim): 下堂我哋會深入探討 Agent Evaluation 同 Benchmarks,
Last clause (verbatim): 我哋下期再見。
下堂我哋會深入探討 Agent Evaluation 同 Benchmarks,
包括 SWE-bench、
AgentBench、
Terminal-Bench 等 benchmark 嘅具體內容,
同埋點樣 design custom eval suite 等到你嘅 agent 可以 reproducible 嘅測試同 regression detection。
多謝收聽第五課,
我哋下期再見。
End-of-section recap (last spoken sentence of Wrap-up & Evaluation Preview): 下堂我哋會深入探討 Agent Evaluation 同 Benchmarks, 包括 SWE-bench、AgentBench、Terminal-Bench 等 benchmark 嘅具體內容, 同埋點樣 design custom eval suite 等到你嘅 agent 可以 reproducible 嘅測試同 regression detection。
End-of-lesson summary
This lesson covered 5 sections across 25 spoken turns (~14 min audio). Below is the final sentence of each section, preserved verbatim from the source podcast script.
- Opening & ReAct Implementation (turn 04): ReAct agent 嘅 invoke 嘅 usage。
- Plan-and-Execute & Reflexion Implementation (turn 10): Plan-and-Execute 嘅 cost optimization。
- Supervisor-Worker & Workflow Graph Implementation (turn 16): Supervisor-Worker 嘅 conditional edge 通常由 Supervisor 嘅 output 控制。
- Production Considerations (turn 22): 第四, structured logging。
- Wrap-up & Evaluation Preview (turn 25): 下堂我哋會深入探討 Agent Evaluation 同 Benchmarks, 包括 SWE-bench、AgentBench、Terminal-Bench 等 benchmark 嘅具體內容, 同埋點樣 design custom eval suite 等到你嘅 agent 可以 reproducible 嘅測試同 regression detection。
End of transcript
Total turns in this lesson: 25 spoken segments · ~14 min audio · preserved verbatim from the source podcast script (/opt/data/workspace/projects/ai-agent-course-05/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-gfminTranscriptPanel.tsx; dark theme & mobile-responsive via Tailwindprose
Integrity checksum
- Total spoken characters (across all turns): 8,216
- Total spoken sentences (across all turns): 107
- Total spoken clauses (across all turns): 274
- Speaker turn distribution: M=13 · F=12