Agent Guard

io.github.mdfifty50-boop由 GitHub 帳號 mdfifty50-boop 發布v0.1.3更新於 Oct 24, 2026

Constitutional guardrails and loop detection for AI agents

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

一個本機 MCP 伺服器,用來監控 AI 代理是否陷入重複迴圈,提供斷路器、卡死分析與復原建議。

可以做什麼
註冊代理並設定迭代上限與進度門檻,記錄每次工具呼叫的參數和簡短結果預覽,用於滾動視窗的迴圈偵測。偵測代理是否卡死,回傳信心分數、模式類型、重複動作與復原建議。設定斷路器,在重複相同動作後警告、阻擋或建議替代方案,並在工具呼叫前做預檢。產生詳細的卡死報告,包含動作歷程、token 浪費估算與建議,並提供依風險排序的所有受監控代理健康儀表板。以資源形式列出受監控的代理。
適用情境
適用於建置或執行可能反覆呼叫同一工具而卡住的代理系統,希望在流程內偵測迴圈、阻擋重複動作並給出復原建議的情況。最適合能在每次工具呼叫前後接入記錄與預檢工具的代理。
執行需求
以本機 stdio 程序執行,通常用 npx agent-guard-mcp 啟動,或從原始碼以 Node.js 和 npm install 執行。未宣告帳號、API 金鑰或環境變數。僅限桌面用戶端,沒有網頁可執行版本。
安裝前請注意
伺服器在執行中的程序內保存代理狀態,監控只涵蓋該工作階段註冊的代理。阻擋模式會攔下代理原本要執行的工具呼叫,應謹慎設定門檻。記錄的參數與結果預覽會傳給伺服器,避免在其中放入機密資訊。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Agent Guard,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

agent-guard-mcp

MCP server that detects and prevents infinite agent loops — the #1 reliability problem in agentic systems.

Provides circuit breakers, pattern detection, stuck-agent analysis, and recovery recommendations via the Model Context Protocol.

Install

bash
npx agent-guard-mcp

Claude Desktop

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "agent-guard": {      "command": "npx",      "args": ["agent-guard-mcp"]    }  }}

From source

bash
git clone https://github.com/mdfifty50-boop/agent-guard-mcp.gitcd agent-guard-mcpnpm installnode src/index.js

Tools

register_agent

Register an agent for monitoring.

ParamTypeDefaultDescription
agent_idstringrequiredUnique agent identifier
max_iterationsnumber100Max iterations before forced stop
progress_thresholdnumber0.3Min unique/total action ratio to be "making progress"

log_action

Log an agent action for loop detection. Maintains a rolling window of the last 50 actions.

ParamTypeDefaultDescription
agent_idstringrequiredAgent identifier
tool_namestringrequiredTool being called
argsobjectrequiredArguments passed
result_previewstring""Brief result preview (max 200 chars)

Returns early warnings when repeated patterns are detected.

detect_loop

Check if an agent is stuck in an infinite loop.

ParamTypeDescription
agent_idstringAgent to check

Returns:

  • is_stuck — boolean
  • confidence — 0.0 to 1.0
  • pattern — healthy, exact_repeat, low_diversity, or exact_repeat_and_low_diversity
  • suggestion — human-readable recovery advice
  • repeated_actions — list of repeated signatures with counts

set_circuit_breaker

Configure automatic intervention when action patterns repeat.

ParamTypeDefaultDescription
agent_idstringrequiredAgent identifier
max_repeatsnumber3Trigger after N identical actions
actionstring"warn""warn", "block", or "suggest_alternative"

check_circuit_breaker

Pre-flight check before executing a tool. Call this BEFORE the actual tool call.

ParamTypeDescription
agent_idstringAgent identifier
proposed_toolstringTool about to be called
proposed_argsobjectArguments about to be passed

Returns proceed: false when the circuit breaker fires (block mode only).

get_stuck_report

Detailed analysis of why an agent is stuck.

ParamTypeDescription
agent_idstringAgent to analyze

Returns: action history, pattern analysis, token waste estimate, diversity ratio, top repeated patterns, and recovery recommendations.

get_health_dashboard

Overview of all monitored agents. No parameters.

Returns all agents sorted by risk score with their status (STUCK/HEALTHY), action counts, and circuit breaker config.

Resources

URIDescription
agent-guard://agentsAll monitored agents with current status

Usage Pattern

1. register_agent — at agent startup2. Before each tool call:   a. check_circuit_breaker — should this action proceed?   b. Execute the tool   c. log_action — record what happened3. Periodically:   - detect_loop — am I stuck?   - get_health_dashboard — how are all agents doing?4. On stuck detection:   - get_stuck_report — what went wrong and how to recover

Tests

bash
npm test

License

MIT

來源:README.md,提交 ebeb97e

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.3最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。