檢索提取演練:執行狀態與執行限制詞彙
Agent 輔助工程檢查
前置要求
第 76 天的狀態與重試機制;第 73-75 天的工具協定。
學習目標
閉卷回憶本週控制詞彙的定義——步數預算、重試預算、軌跡、終止原因、檢查點、冪等副作用、拋棄式工作區——然後對照程式碼而非憑感覺驗證。
操作指引
1. 閉卷:為以下各項寫一行定義:max_steps、max_retries、trace、termination、checkpoint、idempotent effect、disposable workspace。
2. 對照權威定義自行批改:project.json 的 controls(max_steps=6、max_retries=2、tool_payload_bytes=4096)、agent.py 的 RunResult 欄位、cli.py 的 TemporaryDirectory 工作區。
3. 記錄模糊的詞彙,列入明天的提取計畫(間隔提取勝過重讀)。
4. 區分近似概念:重試預算(容忍的失敗觀測數)與步數預算(允許的總迭代數);檢查點(使復原成為可能的持久狀態)與軌跡(紀錄本身);逾時(單次阻塞等待)與截止期限(端到端上限)。
自主實作與記錄
在查看參考答案之前,先為你的手寫定義按 7 分制評分;把每個錯誤記入提取佇列。
軌跡既是執行狀態,也是稽核紀錄;檢查點是把軌跡加計數器持久化後的產物。
max_steps:迴圈迭代上限(6)。max_retries:觸發 tool_failure 前容忍的失敗觀測數(2)。trace:{action, observation} 對的僅附加串列。termination:執行結束的原因(goal_reached|tool_failure|step_budget)。checkpoint:使復原成為可能的 trace+計數器持久序列化。idempotent effect:重複套用不改變狀態的副作用。disposable workspace:執行後銷毀的 TemporaryDirectory 夾具。
無輔助寫出全部七條定義並在查程式碼前誠實自評;最低 6/7。
權威來源資源與權利證明
Site Reliability Engineering, Chapter 22: Addressing Cascading Failures
對應章節 / 時間戳: Preventing Server Overload: Retries; Latency and Deadlines
驗證版本與日期: O'Reilly 2016 free online edition (Verified: 2026-10-30)
Primary analysis of how unbounded retries amplify partial outages into cascading failures, motivating hard retry budgets and deadlines in agent runtimes.
Retries, queueing, and load-shedding basics.
The retry-amplification scenario and budget arithmetic are fully reproduced in the lesson's worked example.
對比候選資源與選型分析 (2)
Broader stability-pattern catalog (circuit breakers, bulkheads); the SRE chapter is free and directly quantifies retry amplification.
Strong companion article; the SRE chapter frames the failure mode (cascading overload) that the retry budget defends against.
Exponential Backoff And Jitter
對應章節 / 時間戳: Adding Backoff; Adding Jitter (Full Jitter, Equal Jitter, Decorrelated Jitter)
驗證版本與日期: AWS Architecture Blog 2015 (Verified: 2026-10-30)
Detailed practitioner reference proving that full jitter (sleep = random_between(0, min(cap, base*2**attempt))) prevents synchronized retry storms and reduces total work during contention.
Retries, timeouts, and basic probability of correlated load.
The backoff exercise is implemented in pure Python with a local flaky stub; the derivation of jitter benefits is fully reproduced in lesson instructions.
對比候選資源與選型分析 (2)
Product-scoped truncated exponential backoff recipe; Brooker's analysis explains why jitter matters, not just what to configure.
Library implementation reference; the AWS article supplies the comparative evidence (with/without jitter) that anchors the lesson.