# HodgeGuard: MCP Circuit-Breaker for Agent Loops

> Zero-knowledge MCP firewall that stops autonomous coding agents from burning tokens in infinite edit-test-fail loops. Saves your API quota.

HodgeGuard: MCP Circuit-Breaker for Agent Loops is a free AI agent skill on Agensi by Rajeev Nath, in LLM Ops. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Rajeev Nath](https://www.agensi.io/creators/zshor-astal)
- Category: [LLM Ops](https://www.agensi.io/skills/llm-ops)
- Version: 1.0
- Last updated: 2026-11-27
- Security: scan passed (2026-11-18); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/hodgeguard-mcp-circuit-breaker-for-agent-loops
- Tags: llm-ops, mcp, security, automation, cost-control

## About this skill

Autonomous coding agents regularly trap themselves in non-convergent edit–verify–fail livelocks—burning 50k–200k+ tokens while mutating syntax (`echo` -> `printf` -> `cat`) or polling broken states with exit code 0.

**HodgeGuard** is a zero-knowledge MCP (`stdio`) firewall that halts multi-step agent livelocks in real-time. It intercepts runaway loops that bypass naive `max_retries=3` limits.

**What's Included:**
1. The strict LLM routing instructions (`SKILL.md`) to enforce `hg_bash` execution.
2. Local Invariant Normalization (extracts canonical targets without sending your code to the cloud).
3. Topological Cycle Detection (Self-loops, 2-cycles, 3-cycles).
4. Transparent token-saving telemetry.

**Setup Instructions (Run locally):**
1. `pipx install hodgeguard-mcp`
2. Add to your MCP config:
```json
{
  "mcpServers": {
    "hodgeguard": {
      "command": "hodgeguard-mcp",
      "env": {
        "HODGEGUARD_API_KEY": ""
      }
    }
  }
}

## Requires

- Python 3.9+ and pipx
- An MCP-compatible agent (Claude Code, Cursor, OpenCode)

Runs completely locally on your machine via stdio.

## Known limitations

Requires hodgeguard-mcp server installation. Only works with agents that support Model Context Protocol (MCP).

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the HodgeGuard: MCP Circuit-Breaker for Agent Loops skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Does this send my source code to the cloud?

No. HodgeGuard normalizes targets locally and only sends truncated 16-character SHA-256 hashes (vertex_hash, state_hash) to the cloud manifold to detect topological loops. Your raw commands, file paths, and code never leave your machine.

### How is this different from setting max_retries=3?

Agents easily bypass naive retry counters by subtly mutating their commands (e.g., swapping echo for printf) or by running commands that return an exit code 0 even when failing to achieve the goal. HodgeGuard tracks topological cycles regardless of syntax evasion.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
