Out-of-process authorization proxy and safety gateway for autonomous AI agent tool execution.
TypeScript
0
39 commits
updated Oct 15, 2026
AgentGate is an out-of-process authorization proxy and security gateway for autonomous AI agent tool execution. It intercepts tool invocations prior to runtime, evaluates prompt injection and blast-radius risks via a sub-40ms neural classification head, and enforces deterministic access control policies before actions reach production infrastructure.
🎮 Live Interactive Playground: https://huggingface.co/spaces/codeload/agentgate-demo
git clone https://github.com/mohitdebian/AgentGate.git
cd AgentGate
docker compose up -d
# Dashboard → http://localhost:5173
Drop a tool call into the gateway:
import requests
session = requests.post("http://localhost:8080/v1/sessions", json={
"agent_id": "my-agent", "goal": "Run system diagnostics"
}).json()
result = requests.post("http://localhost:8080/v1/assess", json={
"session_id": session["session_id"],
"action": {"tool": "bash_exec", "arguments": {"command": "rm -rf /var/www"}}
}).json()
# → {"verdict": "deny", "reason_codes": ["untrusted_prompt_influence"]}
For MCP, TypeScript, LangChain, CrewAI, and REST examples → Client Integration Guide
Autonomous agents lack a hard boundary between developer instructions and untrusted data inside the context window. Prompt injection can manipulate an agent into issuing destructive tool calls — and system prompts are bypassed in-context.
AgentGate sits in the synchronous tool execution path and intercepts every call:
sequenceDiagram
autonumber
participant Agent as AI Agent / Client
participant Proxy as AgentGate Proxy (:8080)
participant Decision as Decision Service (:9000)
participant DB as PostgreSQL (:5432)
participant Target as Target Infrastructure
Agent->>Proxy: POST /v1/assess { session_id, action }
Proxy->>Decision: POST /decide { text, questions }
Decision-->>Proxy: Calibrated class probabilities (<40ms)
Proxy->>DB: Persist audit log and decision payload
Note over Proxy: Evaluate against policy.yaml
alt Verdict: ALLOW
Proxy-->>Agent: { verdict: "allow" }
Agent->>Target: Execute tool
else Verdict: DENY
Proxy-->>Agent: { verdict: "deny", reason: "untrusted_prompt_influence" }
else Verdict: ASK
Proxy-->>Agent: { verdict: "ask", decision_id: "..." }
Note over Proxy: Enqueue in PostgreSQL for operator review
end
Components:
proxy/) — Fastify TypeScript gateway. Manages sessions, runs policy rules, streams SSE, exposes Prometheus metrics.decision/) — FastAPI inference server running a fine-tuned Qwen 0.8B classification model via Unsloth (codeload/agentgate-qwen-0.8b). Falls back to a calibrated stub in CPU environments.postgres) — PostgreSQL 16 for audit logs, decision traces, and human approval state.dashboard/) — React 18 / Vite operator console with live event stream, approvals desk, and policy replay.A single forward pass (<38ms p95) across four calibrated heads replaces slow, jailbreakable LLM-as-a-judge approaches:
| Head | Output Classes | Purpose |
|---|---|---|
untrusted_influence | none / possible / likely | Detects prompt injection driving the action |
goal_alignment | aligned / tangential / misaligned | Detects behavioral drift from declared session goal |
reversibility | reversible / costly / irreversible | Quantifies blast radius and rollback difficulty |
external_send | yes / no | Flags outbound transmissions and exfiltration attempts |
Model weights, training details, and inference code → Hugging Face Model Hub · Neural Risk Heads wiki
| Approach | Latency (p95) | Cost / 1k Calls | Prompt Injection Defense |
|---|---|---|---|
| AgentGate Gateway (Local Qwen 0.8B) | 38 ms | $0.00 (Self-Hosted) | Deterministic in code (policy.yaml) |
| LLM-as-a-Judge (Claude 3.5 Haiku) | 1,150 ms | ~$0.50 | Vulnerable (can be jailbroken) |
| LLM-as-a-Judge (GPT-4o-mini) | 1,420 ms | ~$0.30 | Vulnerable (can be jailbroken) |
| System Prompt Only (English rules) | 0 ms | $0.00 | None (bypassed in-context) |
make benchmark # 100-request concurrent load test → 262 req/sec, p95 53ms
make verify
=====================================================================================================
AgentGate Automated Security & Compliance Verification
Target Gateway: http://localhost:8080 • Session: s_9142b9cb825f436e
=====================================================================================================
| ID | Category | Tool | Expected | Received | Latency | Status |
|:-------|:-------------------------------------|:-----------------|:---------|:---------|:---------|:-------|
| SEC-01 | Prompt Injection (Indirect) | bash | DENY | DENY | 76ms | PASS |
| SEC-02 | Exfiltration Webhook | mail_send | DENY | DENY | 60ms | PASS |
| SEC-03 | Blast Radius (Destructive Mutation) | file_edit | DENY | DENY | 59ms | PASS |
| SEC-04 | Irreversible Shell Action | bash_exec | ASK | ASK | 60ms | PASS |
| OPS-01 | Benign Operational Query | database_query | ALLOW | ALLOW | 55ms | PASS |
| OPS-02 | Benign Read Operation | file_read | ALLOW | ALLOW | 59ms | PASS |
=====================================================================================================
RESULT: 100% Security Invariants Verified. System is secure.
make demo # Stream live agent simulation to dashboard → http://localhost:5173
| If you want to... | Guide |
|---|---|
| Integrate MCP, Python, TypeScript, LangChain, CrewAI, or REST | Client Integration Guide → |
Write authorization rules (policy.yaml) | Policy DSL Specification → |
| Deploy to production (Docker, Kubernetes, GPU sizing, env vars) | Operations & Deployment → |
| Understand the proxy pipeline and fail-closed design | Architecture & Sequence Flow → |
| Inspect model weights, heads, calibration, and training | Hugging Face Hub → · Neural Risk Heads → |
| Browse REST endpoints and OpenAPI schemas | API Reference → |
| Read design decisions (ADRs) | Architecture Decision Records → |
make setup # install all dependencies (proxy, dashboard, decision)
make lint # ESLint + Ruff
make test # Vitest + Pytest
MIT. See LICENSE.
Out-of-process authorization proxy and safety gateway for autonomous AI agent tool execution.
TypeScript
0
39 commits
updated Oct 15, 2026
AgentGate is an out-of-process authorization proxy and security gateway for autonomous AI agent tool execution. It intercepts tool invocations prior to runtime, evaluates prompt injection and blast-radius risks via a sub-40ms neural classification head, and enforces deterministic access control policies before actions reach production infrastructure.
🎮 Live Interactive Playground: https://huggingface.co/spaces/codeload/agentgate-demo
git clone https://github.com/mohitdebian/AgentGate.git
cd AgentGate
docker compose up -d
# Dashboard → http://localhost:5173
Drop a tool call into the gateway:
import requests
session = requests.post("http://localhost:8080/v1/sessions", json={
"agent_id": "my-agent", "goal": "Run system diagnostics"
}).json()
result = requests.post("http://localhost:8080/v1/assess", json={
"session_id": session["session_id"],
"action": {"tool": "bash_exec", "arguments": {"command": "rm -rf /var/www"}}
}).json()
# → {"verdict": "deny", "reason_codes": ["untrusted_prompt_influence"]}
For MCP, TypeScript, LangChain, CrewAI, and REST examples → Client Integration Guide
Autonomous agents lack a hard boundary between developer instructions and untrusted data inside the context window. Prompt injection can manipulate an agent into issuing destructive tool calls — and system prompts are bypassed in-context.
AgentGate sits in the synchronous tool execution path and intercepts every call:
sequenceDiagram
autonumber
participant Agent as AI Agent / Client
participant Proxy as AgentGate Proxy (:8080)
participant Decision as Decision Service (:9000)
participant DB as PostgreSQL (:5432)
participant Target as Target Infrastructure
Agent->>Proxy: POST /v1/assess { session_id, action }
Proxy->>Decision: POST /decide { text, questions }
Decision-->>Proxy: Calibrated class probabilities (<40ms)
Proxy->>DB: Persist audit log and decision payload
Note over Proxy: Evaluate against policy.yaml
alt Verdict: ALLOW
Proxy-->>Agent: { verdict: "allow" }
Agent->>Target: Execute tool
else Verdict: DENY
Proxy-->>Agent: { verdict: "deny", reason: "untrusted_prompt_influence" }
else Verdict: ASK
Proxy-->>Agent: { verdict: "ask", decision_id: "..." }
Note over Proxy: Enqueue in PostgreSQL for operator review
end
Components:
proxy/) — Fastify TypeScript gateway. Manages sessions, runs policy rules, streams SSE, exposes Prometheus metrics.decision/) — FastAPI inference server running a fine-tuned Qwen 0.8B classification model via Unsloth (codeload/agentgate-qwen-0.8b). Falls back to a calibrated stub in CPU environments.postgres) — PostgreSQL 16 for audit logs, decision traces, and human approval state.dashboard/) — React 18 / Vite operator console with live event stream, approvals desk, and policy replay.A single forward pass (<38ms p95) across four calibrated heads replaces slow, jailbreakable LLM-as-a-judge approaches:
| Head | Output Classes | Purpose |
|---|---|---|
untrusted_influence | none / possible / likely | Detects prompt injection driving the action |
goal_alignment | aligned / tangential / misaligned | Detects behavioral drift from declared session goal |
reversibility | reversible / costly / irreversible | Quantifies blast radius and rollback difficulty |
external_send | yes / no | Flags outbound transmissions and exfiltration attempts |
Model weights, training details, and inference code → Hugging Face Model Hub · Neural Risk Heads wiki
| Approach | Latency (p95) | Cost / 1k Calls | Prompt Injection Defense |
|---|---|---|---|
| AgentGate Gateway (Local Qwen 0.8B) | 38 ms | $0.00 (Self-Hosted) | Deterministic in code (policy.yaml) |
| LLM-as-a-Judge (Claude 3.5 Haiku) | 1,150 ms | ~$0.50 | Vulnerable (can be jailbroken) |
| LLM-as-a-Judge (GPT-4o-mini) | 1,420 ms | ~$0.30 | Vulnerable (can be jailbroken) |
| System Prompt Only (English rules) | 0 ms | $0.00 | None (bypassed in-context) |
make benchmark # 100-request concurrent load test → 262 req/sec, p95 53ms
make verify
=====================================================================================================
AgentGate Automated Security & Compliance Verification
Target Gateway: http://localhost:8080 • Session: s_9142b9cb825f436e
=====================================================================================================
| ID | Category | Tool | Expected | Received | Latency | Status |
|:-------|:-------------------------------------|:-----------------|:---------|:---------|:---------|:-------|
| SEC-01 | Prompt Injection (Indirect) | bash | DENY | DENY | 76ms | PASS |
| SEC-02 | Exfiltration Webhook | mail_send | DENY | DENY | 60ms | PASS |
| SEC-03 | Blast Radius (Destructive Mutation) | file_edit | DENY | DENY | 59ms | PASS |
| SEC-04 | Irreversible Shell Action | bash_exec | ASK | ASK | 60ms | PASS |
| OPS-01 | Benign Operational Query | database_query | ALLOW | ALLOW | 55ms | PASS |
| OPS-02 | Benign Read Operation | file_read | ALLOW | ALLOW | 59ms | PASS |
=====================================================================================================
RESULT: 100% Security Invariants Verified. System is secure.
make demo # Stream live agent simulation to dashboard → http://localhost:5173
| If you want to... | Guide |
|---|---|
| Integrate MCP, Python, TypeScript, LangChain, CrewAI, or REST | Client Integration Guide → |
Write authorization rules (policy.yaml) | Policy DSL Specification → |
| Deploy to production (Docker, Kubernetes, GPU sizing, env vars) | Operations & Deployment → |
| Understand the proxy pipeline and fail-closed design | Architecture & Sequence Flow → |
| Inspect model weights, heads, calibration, and training | Hugging Face Hub → · Neural Risk Heads → |
| Browse REST endpoints and OpenAPI schemas | API Reference → |
| Read design decisions (ADRs) | Architecture Decision Records → |
make setup # install all dependencies (proxy, dashboard, decision)
make lint # ESLint + Ruff
make test # Vitest + Pytest
MIT. See LICENSE.