工具註冊表
這是什麼
工具架構、處理函式、可用性檢查和工具集成員資格的中央註冊表。
白話解釋
想像醫院的值班表:每位專科醫生的名字都列在上面,寫明他們看什麼病、如何呼叫他們、以及他們目前是否在值班。工具註冊表就是 Hermes 的值班表——一個集中存放每個工具指令、執行它的程式碼以及判斷它當前是否可用的規則的地方,而不是讓這些細節散落在程式碼各處。
為什麼重要
69 個已註冊的工具宣告全部位於 tools/registry.py——架構、處理函式、可用性檢查和工具集成員資格都定義在同一個地方,而不是散落在程式碼各處。對話上下文在決定模型這一輪能看到哪些工具時會查詢這個註冊表,一個工具可能已註冊但仍不可見(如果其可用性檢查失敗的話)——這是「為什麼 agent 不能做 X」這個常見困惑的來源。工具集本質上是這個註冊表的具名視圖,而不是一個獨立的系統,這也是成員資格就寫在工具定義旁邊的原因。
How it works
Each tool file calls registry.register() at import time — once per tool it defines — handing over its name, schema, handler, toolset label, and an optional check_fn that probes whether the tool can actually run right now (tools/registry.py). Check results are cached for about 30 seconds so a repeat probe doesn’t hit Docker or the filesystem on every turn, but the real flake protection is a separate 60-second grace window: when a probe fails soon after it last succeeded — say Docker timing out once — the last known “available” verdict is served instead of the fresh failure, so one blip doesn’t strip a whole toolset from an agent mid-turn. Only a failure that persists past that window gets cached and honored. When the agent needs its tool list, get_definitions() walks the requested names, skips anything whose check currently says unavailable, and returns only the ready-to-use tools.