LangChain 在 2026 年 5 月 13 日推出 LangSmith LLM Gateway private beta。它的定位,是放在 agent 和 LLM provider 之間的 runtime governance layer。
這個方向很實際。Agent 開始接觸真資料、真工具和真使用者後,治理不能只靠事後 log。成本爆量、PII 外送、policy violation,最好在 request 到達模型前就能處理。
LLM Gateway 做什麼?
LangSmith LLM Gateway 可以:
- 位於 agent 和 LLM provider 之間。
- 設定 spend limits。
- 在 request 送到模型前 redact PII。
- 把 policy violations 作為 traceable events 顯示在 LangSmith。
- 讓團隊從 blocked request 追回 triggering trace。
- 透過 base_url 切換接入,不需要另外架一套治理基礎設施。
這讓 governance 更貼近 runtime,而不是只在月報或安全審查時才發現問題。
為什麼 agent 需要 gateway?
Agent 的風險比一般 chatbot 更高,因為它可能:
- 連續呼叫多次模型。
- 自動重試。
- 使用長 context。
- 呼叫工具後再把結果送回模型。
- 處理使用者、客戶或內部資料。
- 在不同 provider 間切換。
如果沒有 gateway,成本和資料外流很容易只在事後被發現。
Spend limits 的價值
Agent 可能因為 loop、tool error、retry 或長任務導致成本暴增。
Gateway 層的 spend control 可以用來:
- 限制 workspace spend。
- 限制 agent spend。
- 限制 user spend。
- 限制特定 model usage。
- 阻擋異常高 token request。
這比只看帳單更即時。
PII redaction 的價值
如果 agent 會處理客服、HR、醫療、金融、法律或內部文件,PII redaction 會變成基本需求。
常見需要處理的資料包括:
- Email。
- Phone number。
- Address。
- 身分證或護照號。
- Customer ID。
- Bank account。
- Medical record。
- Internal secret。
Gateway 的優勢是能在資料送到模型前處理,而不是等模型回覆後才發現。
導入策略
企業可以把政策分成三層:
| 政策類型 | 處理方式 |
|---|---|
| 高風險 | 直接 block,例如 secret、credential、受管個資 |
| 中風險 | Redact 或 mask,例如 email、phone、customer ID |
| 低風險 | 只記錄 event,供後續 review |
同時要把 gateway event 接回 trace,才能知道是哪個 agent、哪個 user、哪個 tool result 觸發了政策。
官方來源
結論
LLM Gateway 代表 AI governance 從文件政策走向 runtime control。
Agent 系統越複雜,越不能只依賴工程師記得不要送出敏感資料,也不能只在月底看成本。比較成熟的做法,是把 spend、PII、policy 和 trace 綁在一起,讓治理在每次模型呼叫時就能生效。