Repository navigation
Architecture
Mohit Singh edited this page Oct 12, 2026
·
1 revision
AgentGate operates as an out-of-process security checkpoint positioned between autonomous AI agents and downstream execution tools.
+-----------------------------------------------------------------------------+
| Agent Client |
| (Claude Desktop, Cursor, LangChain, CrewAI) |
+-----------------------------------------------------------------------------+
|
POST /v1/assess { action }
v
+-----------------------------------------------------------------------------+
| AgentGate Proxy (:8080) |
| [Fastify / Node.js] |
| |
| * Context Window Assembly (BPE Token Budgeting) |
| * Deterministic Policy Evaluation (deny > ask > allow) |
| * Event Streaming (SSE) & Prometheus Metrics (/metrics) |
+-----------------------------------------------------------------------------+
| |
POST /decide (<40ms) Audit Log / Approval State
v v
+------------------------------+ +--------------------------------+
| Decision Engine (:9000) | | PostgreSQL 16 (:5432) |
| [FastAPI / Python] | | |
| | | * decisions & session traces |
| * Unsloth Qwen-0.8B Head | | * approval queue & audit logs |
| * Single Forward Pass | | * pg_notify event bus |
+------------------------------+ +--------------------------------+
^
| SSE Live Stream
+--------------------------------+
| Operator Console (:5173) |
| [React 18 / Tailwind] |
+--------------------------------+
When an agent requests permission to execute a tool:
-
Ingress & Authentication: The proxy validates the incoming request payload (
session_id,action.tool,action.arguments). - Context Window Token Budgeting: The proxy aggregates prior agent actions and environment outputs for the current session, trimming history to fit the model's token budget using BPE encoding.
-
Inference Dispatch: The compiled context and proposed action are forwarded to the decision service via
POST /decide. -
Deadline Enforcement: The proxy enforces a hard deadline (
AG_DECISION_DEADLINE_MS, default 5000ms). If the decision engine fails or exceeds this deadline, the configureddefaults.on_model_errorpolicy (default:ask) is triggered. -
Deterministic Policy Matching: The probability vector returned by the decision service is evaluated against
policy.yaml. - Persistence & Audit Log: The decision record, input hashes, and model probability distribution are written to PostgreSQL.
-
Verdict Return:
-
allow: Agent proceeds to execute the tool directly. -
deny: Execution is blocked immediately, returning specific error codes. -
ask: The action is suspended in PostgreSQL, waiting for an operator decision via the dashboard or approval API.
-
- Runtime: Node.js 22, Fastify, TypeScript.
-
Responsibilities:
- Exposes client REST API (
/v1/sessions,/v1/assess). - Enforces deterministic YAML policy rules.
- Streams real-time audit flight-recorder events via Server-Sent Events (SSE).
- Serves Prometheus metrics on
/metrics.
- Exposes client REST API (
- Runtime: Python 3.11, FastAPI, Uvicorn.
-
Responsibilities:
- Hosts the fine-tuned Qwen 0.8B classification model loaded via Unsloth.
- In CPU or non-GPU development environments, gracefully falls back to an integrated stub evaluator.
- Exposes health probe on
/healthand model metadata on/model.
- Runtime: PostgreSQL 16 Alpine.
-
Responsibilities:
- Persists session state, decisions, audit logs, and approval queues.
- Delivers low-latency real-time updates to connected dashboards using
LISTEN/NOTIFY.
- Runtime: React 18, Vite, Tailwind CSS.
-
Responsibilities:
- Live flight-recorder monitoring over SSE.
- Human-in-the-loop approvals desk (
Approve/Denyactions held withask). - Dry-run policy replay engine testing rule modifications against historic production events.
AgentGate — An open-source, fail-closed authorization proxy for autonomous AI agent tool execution. Licensed under the MIT License.
-
Overview
-
Architecture
-
Access Control
-
Integration & APIs
-
Operations