Repository navigation
Architecture Decision Records
This document aggregates all formal Architecture Decision Records (ADRs) governing AgentGate's runtime design, security boundaries, and infrastructure choices.
- Date: 2026-10-08
- Status: Accepted
We need to judge if an agent's tool call is safe. The industry standard is an LLM-as-judge (prompting GPT-4 or Claude with instructions to inspect the call), but that approach suffers from:
- Excessive latency (500–2000ms per tool invocation).
- Unparseable outputs (JSON failures, formatting deviations).
- Lack of calibrated confidence (no true probability vector).
- Vulnerability to recursive prompt injection (attack payload jailbreaks the judge).
We use a specialized, fine-tuned classification decision model instead of a generative token-generating LLM. The model outputs closed-set probability distributions across 4 calibrated heads (untrusted_influence, goal_alignment, reversibility, external_send) via a single forward pass.
- Sub-40ms execution latency (p95 < 38ms).
- Zero KV-cache overhead or generative hallucinations.
- Deterministic mathematical probabilities feeding downstream policy rules.
- Date: 2026-10-08
- Status: Accepted
The decision model produces probability vectors over risk classes. We need a way to map these probabilities to an operational verdict (allow, ask, or deny).
The verdict is computed by an explicit, deterministic policy layer (policy.yaml) outside of the model weights, rather than having the neural network directly output a compliance verdict.
- Security teams can adjust thresholds per tool without retraining model weights.
- Complete explainability and auditability for every decision.
- Decouples mathematical risk estimation from organizational business rules.
- Date: 2026-10-08
- Status: Accepted
The policy layer needs rules. Allowing arbitrary script expressions (such as JavaScript eval() or CEL expressions) introduces a secondary code injection attack surface.
We use structured YAML condition trees (all, any, gt, lt) instead of dynamic expression evaluation.
- Zero code injection attack surface.
- Deterministic, schema-validated rules (enforced with Zod).
- Enables offline policy replay against historic traffic without runtime side effects.
- Date: 2026-10-08
- Status: Accepted
The gateway needs to understand the user's intended objective to evaluate goal_alignment. MCP and standard tool calls do not natively carry the user's session goal. Inferring the goal from dynamic traffic is non-deterministic and error-prone.
The user goal must be supplied explicitly upon session initialization (POST /v1/sessions).
- Eliminates goal inference false positives.
- Provides a cryptographic and traceable anchor for what the agent was authorized to do.
- Date: 2026-10-08
- Status: Accepted
We need to select a base model for fine-tuning. Larger models (7B, 14B+) provide capacity but require massive GPU clusters and introduce latency overheads exceeding 100ms.
We start with a compact base architecture (fine-tuned Qwen 0.8B via 4-bit LoRA with Unsloth) and scale upward only if empirical classification boundaries demand additional parameter capacity.
- Fits easily within consumer and edge GPUs (< 2 GB VRAM).
- Extremely low inference latency (28ms p50).
- Highly cost-effective deployment across commodity cloud instances (T4, A10G, L4).
- Date: 2026-10-08
- Status: Accepted
When the decision server, database, or upstream network is unavailable or times out, the proxy must determine how to handle agent tool invocations.
The gateway defaults to fail-closed behavior (deny or route to operator review ask) whenever health checks or neural deadline timeouts are violated.
- Guarantees safety during infrastructure failures or denial-of-service attempts.
- Read-only actions (such as
read_file) can be explicitly whitelisted inpolicy.yamlif higher availability is required.
- Date: 2026-10-08
- Status: Accepted
The neural model must differentiate between trusted developer instructions and untrusted content (such as email bodies, web scrapes, or user comments).
The proxy parses conversation histories and marks untrusted inputs using structured XML-style tags (<untrusted>...</untrusted>) while strictly escaping delimiter strings within untrusted text.
- Prevents delimiter spoofing by adversarial prompt injection payloads.
- Provides clear positional cues for the classification model.
- Date: 2026-10-08
- Status: Accepted
AgentGate requires persistence for sessions, decisions, audit logs, policy versions, and human approvals. Introducing Kafka, Redis, and Mongo increases operational complexity.
We use PostgreSQL 16 as the single unified persistence engine. Real-time event propagation is handled via Postgres Pub/Sub (LISTEN / pg_notify).
- Simple operational footprint (only one stateful container or managed DB).
- ACID transactions guarantee atomic policy activation and approval resolution.
- Keyset cursor pagination provides constant-time audit log queries over millions of 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