What It Takes to Build a Production Agent Harness
Agent harness 作為 execution layer,負責管理 models、tools 與 application state 之間的互動。本系列展示如何使用 LangChain 與 LangGraph 打造這樣的 harness,從簡單的 request 轉換為具備 state 的 production 應用程式。該實作解決了關鍵的 system design 挑戰,包括 error propagation、state persistence 與 deterministic execution control。此章節描述了一個使用 Hermes 與 Opik 的 self-repairing agent harness 系統,能在不重新訓練模型權重的情況下從 production failures 中學習。它區分了 runtime learning(將成功程序儲存為 skills)以及離線最佳化(利用 GEPA 演算法進行 prompt 與 skill 的演化)。其工作流程涵蓋擷取 execution traces、利用 Ollie 工具診斷 root causes,並建立 regression tests 以防止錯誤再次發生。透過修改 instructions 與 configurations 等外部 artifacts,系統將 production incidents 轉化為結構化且可審查的輸入,以實現持續改進。
閱讀原文 ↗在 LangChain 中打造 production agent harness
Agent harness 作為 execution layer,負責管理 models、tools 與 application state 之間的互動。本系列展示如何使用 LangChain 與 LangGraph 打造這樣的 harness,從簡單的 request 轉換為具備 state 的 production 應用程式。該實作解決了關鍵的 system design 挑戰,包括 error propagation、state persistence 與 deterministic execution control。
- Agent harness 是負責管理 models、tools 與 state 之間互動的 execution layer。
- Production agent 平台需要具備 sessions、checkpoints、tracing 以及 human-in-the-loop 審核等能力。
- LangChain 提供 models、messages 與 tools 的介面,而 LangGraph 則提供明確的 state 轉移與 execution control。
- Agent 的 system design 涉及決定哪些 state 僅屬於單次 run,哪些 state 則需要在跨對話中保持 persistent。
- Harness 必須透過決定是否 retry、請求 human input 或是停止執行,來處理 tool failures。
你的 agent harness 應該具備自我修復能力
本節介紹了一個 self-repairing agent harness 系統,使用 Hermes 與 Opik 從 production failures 中學習,而無需重新訓練 model weights。它區分了 runtime learning(將成功的程序儲存為 skills)以及使用 GEPA algorithm 進行 prompt 和 skill 進化的 offline optimization。其工作流程包括擷取 execution traces、使用 Ollie 工具診斷 root causes,並建立 regression tests 以防止錯誤再次發生。透過修改 instructions 和 configurations 等 external artifacts,該系統將 production incidents 轉化為結構化且可審查的輸入,以實現持續改進。
- Agent 系統可以透過修改 instructions、skills 和 configurations 等 external artifacts 來改進,而不需要更新 model weights。
- Hermes 將成功的任務程序保存為可編輯的 SKILL.md 檔案,作為日後重複使用的 procedural memory。
- GEPA (Genetic-Pareto Prompt Evolution) 方法能對 agent artifacts 進行 offline optimization,而不需要 GPU fine-tuning。
- Opik 提供 tracing infrastructure,可擷取 model spans 與 tool spans,精準找出多步驟決策過程失敗的具體步驟。
- Ollie 扮演診斷橋樑的角色,負責檢查專案檔案,並根據 trace data 提出程式碼或 configuration diffs。
- 一個穩健的 repair loop 需要對提議的變更進行 human approval,接著透過重新執行進行驗證,並建立 regression test cases。
- Opik Test Suites 使用 natural-language assertions 和 LLM judges,根據預期結果驗證 agent 行為。