86 / 90

第 86 天:綜合專案整合 —— 執行殼、基準與受控交付

將有界 Agent 執行殼接入所選模型適配器,重建確定性基準台帳,並在一次性夾具上演練 CI 交付與故障復原。

AI Agent 與工程實踐 480 分鐘有效學習時間(8 小時)
01 120 分鐘

整合架構:適配器邊界

Agent 輔助工程檢查

前置要求

第 85 天已凍結的章程與驗收契約;projects/agent_learning 原始碼結構。

學習目標

設計整合接縫,把已驗證的執行殼(工具、預算、評分器)與所選模型適配器組合起來——恰好新增一個有界工具——且不削弱任何既有限制。

操作指引

1. 梳理 projects/agent_learning 的元件:cli.py 入口;agent.py 中帶步數/重試預算與路徑檢查的迴圈;fixtures.py 一次性工作區;deterministic-v1 適配器;獨立評分器。
2. 畫出適配器邊界:適配器只提出動作;執行殼負責驗證、執行有界工具並回傳結構化觀測。模型絕不繞過驗證。
3. 規格化新增的有界工具(例如 count_words(note_name) -> int):註冊名、型別化參數、限制在 fixture 內的路徑處理、自身的失敗契約。
4. 規格化真機適配器插槽:與 deterministic-v1 相同的動作模式,由工單 23 授權契約門控;執行殼無法分辨動作來自哪個適配器——這種不透明正是接縫。
5. 撰寫 integration_design.md:文字元件圖、工具契約、以及「限制保持」清單(步數預算、重試預算、酬載上限、路徑檢查、終止條件)。

自主實作與記錄

寫出 count_words 工具契約(名稱、參數、回傳型別、錯誤模式),以及證明更換適配器無法抬高預算的「限制保持」清單。

獨立掌握標準

產出的設計中全部控制都在執行殼側,且無需觸碰預算、路徑或終止即可更換適配器。

權威來源資源與權利證明

linking arXiv.org perpetual non-exclusive license / Open Access

Toolformer: Language Models Can Teach Themselves to Use Tools

作者 / 機構: Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, Thomas Scialom | 原始出處連結 ↗

對應章節 / 時間戳: Sections 2-3: API-call annotation, sampling, filtering, tool integration

驗證版本與日期: NeurIPS 2023 / arXiv:2302.04761v4 (Verified: 2026-10-30)

入選理由:

Primary reference for model-tool integration with explicit API contracts; informs the capstone's adapter boundary where the harness owns tool validation and the model only proposes calls.

來源前置條件:

Language-model finetuning, API calls, and tool schemas.

安全回退方案(離線彈性):

The capstone's tool contract template (name, typed arguments, error modes) is fully specified in the lesson instructions.

對比候選資源與選型分析 (2)
Yao et al.: ReAct ↗ compared_alternative [Open Access / CC BY 4.0]

Prompt-time interleaving rather than finetuned tool calls; both define the model-side of the same adapter boundary.

Large API-corpus retrieval; Toolformer's minimal single-tool mechanics match the capstone's bounded tool set.

linking All Rights Reserved (personal research blog) Prose is linked, not copied; the curriculum uses its own bounded-agent implementation

LLM Powered Autonomous Agents

作者 / 機構: Lilian Weng | 原始出處連結 ↗

對應章節 / 時間戳: Sections: planning, memory, tool use, challenges

驗證版本與日期: Blog post June 23, 2023 (Verified: 2026-10-30)

入選理由:

Widely used survey mapping agent architecture components (planning, memory, tools) and their failure modes; supports the capstone integration architecture review.

來源前置條件:

Agent loops, tool use, and planning vocabulary.

安全回退方案(離線彈性):

The capstone architecture lesson specifies the adapter boundary, budgets, and tool contracts directly; no blog content is required offline.

對比候選資源與選型分析 (2)
Significant Gravitas: AutoGPT repository ↗ compared_alternative [MIT License (outside autogpt_platform/); Polyform Shield License (autogpt_platform/)]

Open-ended autonomous loop; deliberately excluded as the capstone must remain a bounded, evaluable system.

Yohei Nakajima: BabyAGI repository ↗ compared_alternative [MIT License]

Task-list autonomy demo; the survey article gives vocabulary while the capstone keeps fixed tasks and budgets.

02 120 分鐘

基準重跑與證據台帳

獨立掌握檢查(無 AI 輔助)

前置要求

第 86 天活動 1;工單 19、21、22、23 已發布的指令。

學習目標

原樣重跑先前已驗證的公開指令,記錄任何評審者都能重現的基準台帳——綜合專案對照的是這份台帳而非記憶。

操作指引

1. 執行確定性基準:python -m projects.agent_learning.cli evaluate --fixture summarize-notes --output /tmp/capstone-baseline.json;確認結束碼 0,且產物中 expected_report_sha256 = 9e8315034af750009a4b2cfb261a077428afe441bc45c602cb7ead32ac0fd787。
2. 執行評分器測試:python -m unittest discover -s tests/projects -p 'test_agent_learning.py' -v;記錄通過數。
3. 驗證兩份契約:python3 projects/lora/evidence/validate_contract.py 與 python3 projects/agent_learning/evidence/validate_contract.py;記錄 blocked 狀態保持 blocked。
4. 在 baseline_ledger.md 中逐列記錄:指令、結束碼、產物路徑、SHA-256、環境(python3 --version)、一列觀察。
5. 驗證預訓練證據包仍可解析:python3 -c "import json; json.load(open('curriculum/projects/docs/pretrain-cloud-evidence/evidence-package.json'))",並記錄 run_status=blocked。
6. 對照:今後任何綜合專案執行都必須報告相對本台帳的一致或有依據的差量。

自主實作與記錄

產出 baseline_ledger.md,每條指令一列(至少五列),含指令、結束碼、產物 sha256 與觀察;任何未能重現的列如實標記,不得改成綠色。

獨立掌握標準

交付一份重現全部五條指令、附產物級證據(雜湊或計數)的台帳,包含誠實的失敗列。

權威來源資源與權利證明

linking MIT

OpenAI Evals: Framework for Evaluating LLMs and Contamination Checks

作者 / 機構: OpenAI Research | 原始出處連結 ↗

對應章節 / 時間戳: README sections 'Running evals' and 'Writing evals'

驗證版本與日期: OpenAI Evals Repository (Verified: 2026-10-30)

入選理由:

Standardized evaluation repository specifying rigorous separation of eval prompts, canary GUID strings, and contamination test protocols.

來源前置條件:

Python, evaluation harnesses (MMLU, GSM8K), JSONL datasets.

安全回退方案(離線彈性):

Canary GUID matching, token set intersection, and leak detection scripts are implemented in the curriculum.

對比候選資源與選型分析 (2)
EleutherAI LM Evaluation Harness ↗ compared_alternative [MIT]

Widely adopted evaluation harness; OpenAI Evals provides explicit canary guidance and contamination check specifications.

Hugging Face Lighteval ↗ compared_alternative [MIT]

Modern lightweight eval framework; OpenAI Evals illustrates standard test-set integrity guarantees.

linking Open Access / CC BY 4.0

Reflexion: Language Agents with Verbal Reinforcement Learning

作者 / 機構: Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, Shunyu Yao | 原始出處連結 ↗

對應章節 / 時間戳: Sections 3-4: self-reflection loop, episodic memory, retry budgets

驗證版本與日期: NeurIPS 2023 / arXiv:2303.11366v4 (Verified: 2026-10-30)

入選理由:

Defines failure-feedback-driven retry with bounded attempts; justifies the capstone's retry budget and its distinction between corrected-in-budget and safe termination.

來源前置條件:

Agent loops, tool feedback, and retry semantics.

安全回退方案(離線彈性):

The fault-injection drill specifies verdict classes and budgets locally without needing the paper.

對比候選資源與選型分析 (2)
Yao et al.: ReAct ↗ compared_alternative [Open Access / CC BY 4.0]

Single-episode action/observation protocol; Reflexion adds the cross-attempt self-correction used in the recovery drill.

External-tool critiquing loop; Reflexion's verbal-feedback retry is simpler to bind to the capstone's retry budget.

03 120 分鐘

受控交付:CI 檢查與回滾演練

Agent 輔助工程檢查

前置要求

第 86 天活動 2 的基準台帳;curriculum/engineering/ci_delivery_rollback 中的工單 24 練習包。

學習目標

在完全一次性的 fixture 內,對綜合專案變更集演練工單 24 的交付紀律——分支、diff 評審、自動檢查、分階段部署、健康門禁與回滾。

操作指引

1. 執行 CI 練習流水線:python3 scripts/ci_practice_runner.py,辨認其五個階段(clean_install、regression_exercise、conflict_resolution、controlled_deployment、health_failure_and_rollback)。
2. 為綜合專案重現各階段語意:「變更」即新增的有界工具與任務;乾淨安裝後評分器仍須通過;故意寫錯的工具參數必須被檢查攔下。
3. 對工具 diff 做評審練習:逐行閱讀,確認預算常數未變、無新增網路呼叫。
4. 演練回滾:在一次性 fixture 中部署變更,使健康檢查失敗(例如評分器因 missing_note 失敗),恢復已知良好的 fixture 狀態,並記錄恢復證據。
5. 撰寫 delivery_log.md:階段、指令、可觀測結果、通過/失敗、回滾證明——只用可觀測結果,不用指令截圖。

自主實作與記錄

產出涵蓋全部五個階段的 delivery_log.md,並附注入回歸的診斷與回滾證據(例如恢復後檔案雜湊等於變更前雜湊)。

獨立掌握標準

在一次性 fixture 上演示「部署→健康失敗→已驗證恢復」,每個階段都有產物級證據。

權威來源資源與權利證明

linking All Rights Reserved (martinfowler.com) Article is linked, not copied; pipeline practice uses the repository's own runner

Continuous Integration

作者 / 機構: Martin Fowler | 原始出處連結 ↗

對應章節 / 時間戳: Practices of Continuous Integration: Make the Build Self-Testing; Fix Broken Builds Immediately

驗證版本與日期: Second edition, May 2006 (Verified: 2026-10-30)

入選理由:

Standard essay defining CI as verified mainline integration; grounds the capstone delivery rehearsal's check-before-merge and broken-build-response rules.

來源前置條件:

Version control, automated tests, and build scripts.

安全回退方案(離線彈性):

scripts/ci_practice_runner.py demonstrates each stage locally; the article is a reference, not a dependency.

對比候選資源與選型分析 (2)
Humble & Farley: Continuous Delivery (Addison-Wesley) ↗ compared_alternative [All Rights Reserved (book)]

Full deployment-pipeline book; the Fowler essay suffices for the rehearsal vocabulary while the repo runner supplies practice.

Forsgren, Humble, Kim: Accelerate / DORA State of DevOps ↗ compared_alternative [CC BY-NC-ND (reports)]

Industry metrics research; cited as background while the article supplies the operative CI definition.

linking CC BY-NC-ND 4.0 noncommercial no-derivatives

Site Reliability Engineering, Chapter 8: Release Engineering

作者 / 機構: Dinah McNutt (ed. Betsy Beyer, Tim Harvey), in Site Reliability Engineering (eds. Betsy Beyer, Chris Jones, Jennifer Petoff, Niall Richard Murphy; Google) | 原始出處連結 ↗

對應章節 / 時間戳: Chapter 8: release pipeline, canarying, rollback criteria

驗證版本與日期: O'Reilly 2016 / sre.google online edition (Verified: 2026-10-30)

入選理由:

Defines staged rollout, health-gated release, and rollback criteria; supplies the controlled-deployment and health-failure stages rehearsed by the capstone.

來源前置條件:

Version control, CI basics, and deployment vocabulary.

安全回退方案(離線彈性):

The CI practice runner encodes the same stages in disposable fixtures, so the exercise is self-contained.

對比候選資源與選型分析 (2)
Humble & Farley: Continuous Delivery ↗ compared_alternative [All Rights Reserved (book)]

General delivery pipeline text; the SRE chapter adds explicit rollback/health-gate criteria used by the drill.

Martin Fowler: Continuous Integration ↗ compared_alternative [All Rights Reserved]

Integration-side discipline; the SRE chapter covers the release and rollback side of the same rehearsal.

04 120 分鐘

考核:故障注入與有界恢復演練

獨立掌握檢查(無 AI 輔助)

前置要求

第 86 天活動 1-3。

學習目標

逐一注入確定性故障(畸形參數、輸入缺失、迴圈),驗證結構化觀測以預算內糾正或安全終止收場,從而證明整合系統會安全地失敗。

操作指引

1. 對 {invalid_arguments, missing_note, loop} 中每個故障,啟用該故障執行 fixture 適配器,記錄動作/觀測軌跡。
2. invalid_arguments:確認執行殼回傳結構化錯誤,Agent 在 max_retries=2 內糾正或終止。
3. missing_note:確認出現結構化的 missing-note 觀測,而非逃逸的例外。
4. loop:確認步數預算(max_steps=6)強制終止而非無限迴圈。
5. 把每個結果分類為 corrected-in-budget、terminated-safe 或 UNBOUNDED(自動判負)。在 fault_drill.json 中記錄逐故障判定。
6. 最後完成一次完整恢復:從失敗執行中還原乾淨 fixture 並重跑到綠——這是綜合專案的受控恢復證明。

自主實作與記錄

產出 fault_drill.json:對三個故障各記錄軌跡指標、觀測到的終止、重試次數與判定,並附以雜湊驗證的恢復重跑結果。

獨立掌握標準

每個故障都產生結構化、有預算約束的結果,零無界逃逸,且恢復重跑經產物雜湊驗證。

權威來源資源與權利證明

linking Open Access / CC BY 4.0

Reflexion: Language Agents with Verbal Reinforcement Learning

作者 / 機構: Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, Shunyu Yao | 原始出處連結 ↗

對應章節 / 時間戳: Sections 3-4: self-reflection loop, episodic memory, retry budgets

驗證版本與日期: NeurIPS 2023 / arXiv:2303.11366v4 (Verified: 2026-10-30)

入選理由:

Defines failure-feedback-driven retry with bounded attempts; justifies the capstone's retry budget and its distinction between corrected-in-budget and safe termination.

來源前置條件:

Agent loops, tool feedback, and retry semantics.

安全回退方案(離線彈性):

The fault-injection drill specifies verdict classes and budgets locally without needing the paper.

對比候選資源與選型分析 (2)
Yao et al.: ReAct ↗ compared_alternative [Open Access / CC BY 4.0]

Single-episode action/observation protocol; Reflexion adds the cross-attempt self-correction used in the recovery drill.

External-tool critiquing loop; Reflexion's verbal-feedback retry is simpler to bind to the capstone's retry budget.

linking arXiv.org perpetual non-exclusive license / Open Access

Toolformer: Language Models Can Teach Themselves to Use Tools

作者 / 機構: Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, Thomas Scialom | 原始出處連結 ↗

對應章節 / 時間戳: Sections 2-3: API-call annotation, sampling, filtering, tool integration

驗證版本與日期: NeurIPS 2023 / arXiv:2302.04761v4 (Verified: 2026-10-30)

入選理由:

Primary reference for model-tool integration with explicit API contracts; informs the capstone's adapter boundary where the harness owns tool validation and the model only proposes calls.

來源前置條件:

Language-model finetuning, API calls, and tool schemas.

安全回退方案(離線彈性):

The capstone's tool contract template (name, typed arguments, error modes) is fully specified in the lesson instructions.

對比候選資源與選型分析 (2)
Yao et al.: ReAct ↗ compared_alternative [Open Access / CC BY 4.0]

Prompt-time interleaving rather than finetuned tool calls; both define the model-side of the same adapter boundary.

Large API-corpus retrieval; Toolformer's minimal single-tool mechanics match the capstone's bounded tool set.