Building a Production Agent Harness with LangGraph and Jev
Google Cloud 推出了 Advent of Agents Season 3,這是一個為期 31 天的教學系列,重點在於建置可用於 production 的安全且受治理的 AI agents。在 10 月期間每天發布的教學都附帶可執行的程式碼,以解決實際的安全與客戶問題。涵蓋的關鍵維運主題包括 agent identity、sandboxing、guardrails、evaluations、MCP security 和 fleet management。Agent Engineering 課程的 Part 3 與 Part 4 展示了如何使用 LangChain Middleware、LangGraph 和 Jev 來建構 production agent harness 和 verification loop。Jev 作為一個 System One 模型運作,專門為 typed decisions 提供經過校準的機率(calibrated probabilities),而非生成自由格式的文字。這些機率在整個 agent workflow 中用於 model routing、request classification、tool-risk assessment 以及 evidence verification。該系統結合了 deterministic logic、Jev 的 bounded probabilistic judgments 以及獨立的 LLM verification,以提高控制力與效率,而無需完全依賴通用型的 LLMs。當推論請求到達 LLM serving engine 時,scheduler 會跨 iteration 管理其生命週期,而不是直接將其傳遞給 GPU。scheduler 在建立每個 execution batch 之前會評估 token 限制與剩餘的 KV-cache 空間,在接收新工作之前優先處理 decode 任務。傳入的請求首先會經歷 prefill 階段以計算 key-value tensors,隨後在 decode 階段轉換為 autoregressive token generation。透過 continuous batching,現代 serving engines 動態結合了 prefill 和 decode 工作,在每一步之後將已完成的請求替換為等待中的請求。
閱讀原文 ↗目錄
Google Advent of Agents Season 3 來了!
Google Cloud 推出了 Advent of Agents Season 3,這是一個為期 31 天的教學系列,聚焦於建置可用於 production 的安全且受治理的 AI agents。在 10 月期間每天發布的教學都附帶可執行的程式碼,以解決實際的安全與客戶問題。涵蓋的關鍵維運主題包括 agent identity、sandboxing、guardrails、evaluations、MCP security 和 fleet management。
- Advent of Agents Season 3 是由 Google Cloud 舉辦的 31 天免費系列課程。
- 在整個 10 月期間,每天都會發布包含可執行程式碼的實作教學。
- 該系列聚焦於 production 級別的 AI agent 安全性、governance 和 fleet management。
- 涵蓋的具體主題包括 agent identity、guardrails、sandboxing、observability、evaluations、MCP security 以及 cost controls。
使用 LangGraph 與 Jev 建構 production agent harness
Agent Engineering 課程的 Part 3 與 Part 4 展示了如何使用 LangChain Middleware、LangGraph 和 Jev 來建構 production agent harness 和 verification loop。Jev 作為一個 System One 模型運作,專門為 typed decisions 提供經過校準的機率,而非生成自由格式文字。這些機率在整個 agent workflow 中用於 model routing、request classification、tool-risk assessment 以及 evidence verification。該系統結合了 deterministic logic、Jev 的 bounded probabilistic judgments 以及獨立的 LLM verification,以提高控制力與效率,而無需完全依賴通用型的 LLMs。
- Jev 是一個 System One 模型,旨在為 typed decisions 回傳經過校準的機率,而非生成開放式文字。
- Part 3 聚焦於 agent harness 控制項,例如 PII redaction、retries、hard call limits、permission enforcement,以及針對寫入操作的人工審核(human approval)。
- Part 4 將 agent 置於顯式的 LangGraph loop 中,具備 structured planning、stuck detection、replanning 和 execution budgets。
- 三層驗證系統採用 deterministic checks 來處理明確的失敗情況、利用 Jev 進行高信賴度的 accept/reject 決策,並由獨立的 LLM 負責處理不確定區間。
- Jev 機率在更大的控制系統中作為附加訊號,而不是取代 deterministic checks、permissions 或 human approvals。
清楚解析 LLM scheduling loop:
當推論請求到達 LLM serving engine 時,scheduler 會跨 iteration 管理其生命週期,而不是直接將其傳遞給 GPU。scheduler 在建立每個 execution batch 之前會評估 token 限制與剩餘的 KV-cache 空間,在接收新工作之前優先處理 decode 任務。傳入的請求首先會經歷 prefill 階段以計算 key-value tensors,隨後在 decode 階段轉換為 autoregressive token generation。透過 continuous batching,現代 serving engines 動態結合了 prefill 和 decode 工作,在每一步之後將已完成的請求替換為等待中的請求。
- LLM scheduler 根據處理 token 的限制與剩餘的 KV-cache 空間,一次一個 iteration 地管理推論請求。
- Prefill 會平行處理 prompt tokens 以建構 KV tensors,並可能將長 prompt 進行 chunk 切塊處理,以避免阻塞進行中的生成任務。
- decode stage 會以 autoregressive 方式生成 token,通常在每個 model step 中為每個 active request 產出一個 token。
- Continuous batching 讓 serving engine 能夠在同一個 GPU batch 中混合 prefill 與 decode 操作,並在每個 step 後調整 batch 的組成。
- 已完成的 request 會立即釋放其 KV-cache block,讓 scheduler 能從 queue 中准入新的 request。