回到頂部
Mason AI Lab tech article hero for Deep Agents Interpreter 是什麼?為什麼 Agent 需要介於 tool call 和 sandbox 之間的 runtime

Deep Agents Interpreter 是什麼?為什麼 Agent 需要介於 tool call 和 sandbox 之間的 runtime

LangChain 在 2026-05-20 介紹 Deep Agents interpreters。整理 QuickJS、programmatic tool calling、狀態、限制與適用場景。

LangChain 在 2026 年 5 月 20 日介紹 Deep Agents interpreters。這個概念可以理解成:給 agent 一個受限的小型 runtime,讓它在 agent loop 裡寫程式、保存臨時狀態、組合工具結果,但又不直接給它完整 sandbox 或主機環境。

這對 agent engineering 很重要。因為很多任務不是單純呼叫一次工具,也不一定需要整台 sandbox。它們需要的是一個可控的中間層。

Interpreter 解決什麼問題?

傳統 agent 常見兩種方式:

  • Serial tool calls:模型一次呼叫一個工具,拿到結果,再決定下一步。
  • Full sandbox:agent 可以在環境裡跑 shell、寫檔、安裝套件、執行程式。

兩者都有問題。

Serial tool calls 很容易產生太多模型 round trip,中間結果一直塞回 context。Full sandbox 很強,但 action surface 大,佈署、隔離、成本和安全控制都更重。

Interpreter 介於兩者之間。它讓 agent 可以用程式表達多步驟邏輯,但預設沒有 filesystem、network、shell、package installation 等能力。需要碰外部世界時,必須透過 host runtime 明確 expose 的 bridge。

Interpreter state 是第三個 context surface

Agent 常見 context surface 有兩個:

  • Message history:模型當下要看的內容。
  • Filesystem:保存 artifacts、筆記、中間檔案和長期工作記憶。

Interpreter 加入第三個 surface:live working values。

例如 arrays、objects、maps、counters、queues、helper functions 都可以留在 runtime 裡,不需要每一步都轉成文字、塞回 prompt 或寫成檔案。

這對長任務很有用,因為模型不必背著所有中間資料前進。

Programmatic tool calling 是什麼?

Programmatic tool calling 讓 allowlisted tools 出現在 interpreter 的 tools namespace 裡。Agent 可以寫 code 直接呼叫這些工具,再把結果整理成更小的輸出回到模型 context。

這樣做的好處是:

  • 減少中間結果塞進 prompt。
  • 減少模型 round trip。
  • 讓工具組合更像程式流程。
  • 讓失敗模式更容易測試。
  • 可以把大量資料先 filter、score、slice,再交給模型判斷。

LangChain 提到早期測試中,這種方式在部分任務上使用更少 token。實際節省幅度會依任務而不同,但方向很合理:不要讓模型看每個中間步驟,只讓它看需要推理的部分。

和 sandbox 差在哪裡?

類型能力風險
Serial tool calls最簡單、好追蹤步驟多時昂貴、慢、context 膨脹
Interpreter可寫程式、保存狀態、組合工具需要設計 allowlist、timeout、result size
Sandbox能跑完整環境、操作檔案和 shell隔離、供應、成本和安全負擔更大

Interpreter 不取代 sandbox。當 agent 要操作 repo、跑測試、處理檔案或安裝 dependency,sandbox 仍然必要。

但如果任務主要是資料轉換、工具結果組合、subagent dispatch、批次篩選,interpreter 會更輕。

適合哪些 agent 任務?

比較適合:

  • 對 1000 筆資料先篩選再總結。
  • 同時呼叫多個 subagents 後合併結果。
  • 對工具結果做排序、分群、去重。
  • 將多個 API 回傳轉成統一 schema。
  • 將候選文件先打分,再挑少量進模型 context。
  • 在同一個 run 中保留 queue、counter 或 intermediate map。

不適合:

  • 需要真實 filesystem 操作。
  • 需要安裝套件。
  • 需要跑外部 command。
  • 需要高度隔離的 untrusted code execution。

導入時要設計的安全邊界

Interpreter 雖然受限,但仍然需要治理。

建議設計:

  • 哪些 tools 可以 expose。
  • 每次 eval 的 timeout。
  • 最大 programmatic tool calls。
  • 最大 result size。
  • memory limit。
  • console output 是否保留。
  • 是否允許 snapshot between turns。
  • trace 裡是否記錄 interpreter code 和 tool args。

這些設定會決定 interpreter 是可控 runtime,還是另一個看不清楚的執行層。

官方來源

結論

Deep Agents interpreter 的重點,是把 agent 的工作空間切得更細:模型負責判斷,interpreter 負責受限的程式組合,sandbox 負責完整環境操作。

這代表 agent 架構正在變成熟。未來可靠的 agent 不會只有「模型加工具」,而會有多層 runtime:message context、interpreter state、filesystem、sandbox、trace 和 eval 各自負責不同工作。

№ · further reading

延伸閱讀