AgentGuard: Governance for Autonomous Agents

Inspiration

I am an AI enthusiast and writing and building tools and solution which can help solidify the foundation for AI enablement and governance. When I think about future of AI agents, I can see that very soon AI agents will handle more complex transactions end to ends and the stakes would shifted from "simple mistake of counting r in strawberry" to "genuine business risks creating brand reputation impact"

That’s why we need a serious safety net. I’ve been developing the concept of "Human-as-a-Service" (HaaS) the principle that for high-stakes decisions we need to analyse the tools / transaction validation and involve human for high risk.

AgentGuard designed to be a guardrail that catches rogue or hallucinatory actions before they cause damage, without stripping away the autonomy that makes AI agents useful for everyday tasks in the first place.

What it does

AgentGuard is a zero-trust governance layer for AI agents. It acts as an intelligent MCP Tool Validator that sits between an autonomous agent and its tools. When an agent attempts to execute a tool, it validate the tool call with Agentguard to make sure it fits in all the required risk parameter for Agent to perform and involve right team to approve it.

  • Low Risk (Tier 1): Actions (like reading a file or searching the web) are passed through instantly.
  • High Risk (Tier 2-4): Actions (like mutating a production database or initiating a wire transfer) are paused. AgentGuard issues a state machine pause to the agent and broadcasts the approval request across a secure Peer-to-Peer (P2P) network.

The request is routed to a specialized pool of human experts (e.g., "Finance" or "Security"). The required number of human signatures (multi-sig consensus) is collected via a React dashboard before the cryptographically signed approval is sent back to the agent to resume execution.

The Risk engine self learn and reduce or increase the risk classification for future based on the approvals / rejection.

You can manage risks using a simple JSON configuration, making it easy to define exactly where the guardrails need to be. To keep things seamless, approval authentication integrates directly with your Enterprise SSO. This ensures the right people are automatically mapped to the right skills, providing precise oversight for every high-stakes request.

How I built it

AgentGuard is built using a modern, distributed architecture:

  • Core Governance Engine: Written in TypeScript/Node.js, this layer implements the MCP server protocol and handles risk classification.
  • Consensus & State: I have utilized Upstash Redis for distributed state management and LibP2P to build a resilient, decentralized network for broadcasting governance tasks routing to Human-as-a-Service nodes.
  • Dashboard & Verification: The human reviewer interface is built with React, Vite, and Tailwind CSS, featuring Vercel Speed Insights and Analytics for performance tracking. It integrates OAuth/SSO (LinkedIn, GitHub) to cryptographically verify that the approver possesses the necessary skills for the specific risk pool.
  • Agent Integration: I have built a lightweight Python SDK (haas-python-sdk) with an @haas_governed decorator that allows developers to easily wrap their critical functions, seamlessly integrating any Python-based agent (like AutoGPT or custom LangChain setups) into the AgentGuard network.

Challenges I ran into

Building a distributed system that pauses and resumes asynchronous AI agents presented significant hurdles:

  1. State Preservation: When an agent hits a high-risk tool call, it must wait for human approval (which could take minutes or hours). I had to engineer a reliable way to preserve the agent's context and execution stack without timing out API connections.
  2. Polling Latency: In a distributed serverless environment like Vercel, aggressive polling from the dashboard and agent clients quickly hit rate limits (e.g., 60 requests/min), causing silent 429 Too Many Requests errors. I had to carefully tune the HTTP API rate limits and implement debouncing logic to create a snappy, real-time user experience without overwhelming the backend.
  3. Conceptual Clarity: Initially, I framed the system as an "interceptor," which confused developers who thought we were magically altering their code. I had to refine language and documentation to clarify that AgentGuard acts as an "MCP Tool Validator," governed by explicit multi-sig rules.

Accomplishments that I am proud of

  • True Human-in-the-Loop: I have successfully decoupled the agent's execution from the human approval timeline, allowing agents to confidently queue up high-risk tasks while continuing parallel work.
  • Skill-Based Routing: I have proud of the credential verification system. A "CRITICAL" risk finance request cannot be approved by a junior developer; it strictly requires verified credentials from the "Finance" pool, adding a robust layer of organizational security.
  • Zero-Code Instrumentation: Through the Model Context Protocol, developers can drop AgentGuard in front of their existing tool servers with virtually zero code changes to the underlying tools themselves.

What I learned

  • Latency is the enemy of UX: I have learned firsthand the complexities of managing state across serverless functions, P2P networks, and frontend polling. Optimizing the polling intervals and handling temporary empty states gracefully (debouncing) was critical for a polished UI.
  • Standardization is powerful: Building on top of the Model Context Protocol (MCP) proved that standardizing interfaces accelerates development. By adhering to MCP, AgentGuard instantly became compatible with any agent framework that supports the protocol.
  • Safety Enables Scale: Counterintuitively, adding friction (governance) actually increases the velocity of AI adoption in enterprises. When engineering teams know there is a hard, mathematical guarantee that an agent cannot drop a database without human consensus, they are much more willing to deploy agents into production.
  • AI Code assistant: Writing code with AI Assistant is easy, but providing the right context and asking the right question for large and complex project is hard. Sometime your AI assistant can do very complex things with ease, but sometime even a single fix not possible and it take more time to debug and easier for you to jump in and fix the issue directly.

What's next for Agentguard - Action, Accountability and Responsibility

Looking ahead, My focus is entirely on scaling Action, Accountability, and Responsibility:

  • Action: Expanding integrations beyond Python. I am planning to build native SDKs for Go and Rust, and deeply integrate AgentGuard into major orchestration frameworks like LangChain, AutoGen, and CrewAI as a first-class citizen.
  • Accountability: Implementing mathematically verifiable audit logs using zero-knowledge proofs (ZKPs) or a lightweight ledger. I want to guarantee that every approved action has an immutable, cryptographically verifiable trail linking the agent's request to the specific human identities that signed off on it.
  • Responsibility: Enhancing the Risk Classifier with its own localized open-source LLM that can proactively identify anomalous agent behavior (e.g., detecting if an agent is stuck in a loop generating excessive API costs) and automatically escalating those events to human overseers, moving from reactive validation to proactive safety monitoring.
  • Open Source: Keeping the project open source to allow more people to engage and enhance the project.

Built With

Share this project:

Updates

Submission history