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 分

    请在仓库或注册中心条目中声明许可证。