Secure your agents.
Control their actions.
AgentShield is an open-source security and authorization gateway for autonomous AI agents. Enforce policies, control tool execution, manage approvals, and establish trust boundaries across your agent infrastructure.
Quickstart
Run the stack, register an agent, and send a signed tool call in minutes.
Architecture
How the gateway, control plane, policy engine, and event pipeline fit together.
Integrations
Python and TypeScript SDKs, LangGraph, LangChain, CrewAI, and MCP.
Security
Threat model, request integrity, replay protection, SSRF controls, and audit.
API Reference
Gateway and control plane endpoints rendered from the OpenAPI contracts.
Self-hosting
Docker Compose, Kubernetes, configuration, and production hardening.
Architecture
A gateway outside the agent decides what runs.
Agents never execute tools directly. Every call is signed, authenticated, checked against budgets and policy, and recorded before a registered adapter runs it. Committed events then flow asynchronously to streaming and evidence storage.
Core capabilities
Security controls that hold when the model does not.
Agent identity
Each agent holds an Ed25519 key. Every request is signed over its raw body, timestamp, and a single-use nonce. AgentShield stores only the public key.
Deterministic authorization
An in-process evaluator returns allow, deny, or require_approval. Deny beats approval beats allow, and anything unmatched is denied.
Controlled execution
Tools run only through registered gateway adapters, at most once per decision, with arguments bound to the hash that policy saw.
Human approvals
Sensitive actions wait for an owner, admin, or approver. Approvals bind to the exact request body, expire after 15 minutes, and are consumed once.
Budgets and limits
Per-agent request, tool-call, and token budgets, adapter deadlines, and circuit breakers stop runaway loops before they reach a tool.
Security intelligence
Deterministic rules flag prompt injection in tool results and secrets in tool arguments. Findings are advice and never change a decision.
Audit events
Every decision, execution, and approval is appended to a per-organization SHA-256 hash chain enforced by PostgreSQL triggers.
Operational visibility
A transactional outbox streams committed events to NATS JetStream. Prometheus metrics and a Grafana dashboard ship with the stack.
Developer experience
Route every tool call through one client.
The Python and TypeScript SDKs sign the exact bytes they send. Framework integrations for LangGraph, LangChain, CrewAI, and MCP forward through those clients and refuse local tool functions, so there is no path around the gateway.
- Errors are never an allow. A database, Redis, or policy failure denies or returns an error. No path defaults to permit.
- The agent is untrusted. Organization ids, permissions, and approval claims in a request body are claims, not authority.
- Advice is not authority. Content analysis can raise an alert. It cannot allow, deny, or hold a call.
- Side effects happen at most once. Executions are claimed before dispatch. An interrupted run is refused on retry, never repeated.
from pathlib import Path
from agentshield_sdk import ApprovalRequired, Client, Denied
client = Client(
gateway="http://127.0.0.1:8081",
agent_id=AGENT_ID,
organization_id=ORGANIZATION_ID,
seed=Path("agent.seed").read_bytes(), # 32-byte Ed25519 seed. Never sent.
)
try:
executed = client.call_tool(
tool_name="sample.echo",
operation="sample.echo",
resource="demo",
arguments={},
)
print(executed.adapter, executed.result)
except Denied as exc:
print("denied:", exc.decision.explanation["reason"])
except ApprovalRequired as exc:
print("waiting for a person:", exc.decision.approval_id)Run the full stack locally.
One Compose command starts the gateway, control plane, dashboard, intelligence engine, event relay, and their data services on loopback ports.