The self-healing exception handler for autonomous AI agents.
Project description
๐ก๏ธ AgentX: The Semantic Firewall for AI Agents
LLM Agents are brilliant, but they are incredibly brittle. They will drop your production database, leak AWS keys, and fall victim to prompt injections. Traditional firewalls just crash the agent by returning a 403 Forbidden.
AgentX is different. It is a neuro-symbolic edge gateway that intercepts dangerous tool calls, blocks them, and returns a Socratic Challenge back to the agent's context windowโforcing the agent to rethink its strategy and self-correct without crashing.
๐ง Don't just block agents. Coach them.
The 5 Pillars of Agentic Security
AgentX is built on a "Reasoning Engine" architecture that treats AI agents as autonomous employees rather than static scripts. We secure them through five core pillars:
- Cognitive Interception: We intercept tool calls to compare the agent's stated intent (Chain of Thought) against its actual deterministic action.
- Socratic Nudging: Instead of crashing the agent with a
403 Forbidden, we issue a Socratic Challenge to guide them to a safe, desired end-goal. - Human-in-the-Loop (HITL): If the gateway cannot judge intent safely, the agent is paused (
202 Accepted) and sent to a SOC Sandbox for human evaluation. - Dynamic Policy Refresh: We collect novel intents at the edge, allowing DevSecOps to draft new policies that sync globally to all containers in 3 seconds.
- Immutable Audit Trails: We maintain a chronological ledger of agent thoughts, actions, and corrections for future learning and compliance.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก๏ธ AgentX Session Summary (Trace: 7012938b-4cde-4bea-aac8)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฑ๏ธ Uptime: 15.49 seconds
๐ ๏ธ Tools Monitored: 2
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Intercepts: 1 | Cumulative: 34
๐ฅ Critical Blocks: 1 | Cumulative: 18
๐ Self-Corrections: 1 | Recovery Rate: 100.0%
๐ฐ Tokens Saved: ~1500 | Cumulative: ~51000
โณ Time Saved: ~5s | Cumulative: ~170s
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฉบ AGENT HEALTH INSIGHT
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ Top Offender: 'Database Isolation'
๐ก Tip: Consider refining your agent's system prompt to avoid this.
๐ The 4 Shields (Defense-in-Depth)
The Inbound Shield (Prompt Injection): Sanitizes inbound user text to prevent cognitive hijacking ("Ignore previous instructions") before the agent reads it.
The Logic Shield (Database Guard): Uses AST parsing and Gemini to catch destructive queries (DROP, DELETE) and nudges the agent to write safer SQL.
The Network Shield (SSRF Guard): Prevents agents from acting as confused deputies to hit cloud metadata IPs (e.g., 169.254.169.254).
The Egress Shield (DLP/PII Scrubber): Dynamically masks PII and API keys on the wire, maintaining clean audit logs without triggering SOC alert fatigue.
โก Quickstart (Time-to-Value < 3 Minutes)
1. Install the SDK
Zero-config integration for your Python agents.
```bash
pip install agentx-security-sdk
- Wrap your Tools Add the @agentx_protect decorator to any function your LangChain, AutoGen, or custom ReAct agent uses. AgentX operates out-of-band, adding zero latency to safe calls.
from agentx_sdk.decorators import agentx_protect
@agentx_protect(agent_id="customer_support_agent")
def execute_database_query(query: str):
# Your local logic here
return db.execute(query)
- Spin up the Edge Gateway AgentX requires an Edge node to process heuristics and embeddings at sub-millisecond speeds.
Clone this repository.
Copy .env.example to .env and add your API keys (SUPABASE_URL, SUPABASE_KEY, GEMINI_API_KEY).
Boot the gateway:
docker-compose up -d
The gateway is now listening on http://localhost:8000 and mirroring policies from your Control Plane.
- Run the Simulation Watch the AgentX Gateway coach a rogue agent in real-time.
python examples/simulate_agent_sdk.py
๐ Local Telemetry & Agent Health
AgentX ships with a built-in, privacy-first SQLite time-series event log (.agentx.db). It tracks every interception locally. When your agent script finishes or crashes, AgentX automatically prints a comprehensive Session Summary and Lifetime ROI dashboard:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก๏ธ AgentX Session Summary
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฑ๏ธ Uptime: 9.17 seconds
๐ ๏ธ Tools Monitored: 2
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Intercepts: 1 | Cumulative: 5
๐ฅ Critical Blocks: 1 | Cumulative: 5
๐ฐ Tokens Saved: ~1500 | Cumulative: ~7500
โณ Time Saved: ~5m | Cumulative: ~25m
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฉบ AGENT HEALTH INSIGHT
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ Top Offender: 'Database Isolation'
๐ ๏ธ Tip: Consider refining your agent's system prompt to avoid this.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฆ Try the Developer Demos Inside the examples/ folder, you will find three standalone scripts proving the AgentX Reasoning Layer:
- 01_self_healing_agent.py: Watch AgentX catch a hallucination and coach the agent to self-correct (Saving tokens and uptime).
- 02_cognitive_intent_block.py: Watch the Semantic Firewall catch malicious intent even when the raw syntax is perfectly safe.
- 03_human_escalation.py: See how an agent safely pauses execution and pings a SOC analyst for approval using a 202 Accepted queue.
๐น๏ธ Human-in-the-Loop (HITL) & Control Plane
Sometimes, an agent needs to drop a table for a valid business reason.
AgentX features a Next.js Control Plane Dashboard. If an agent requests an escalation, the SDK securely pauses local execution and polls the Edge Gateway. A human SOC analyst can click "Approve" or "Deny" in the UI, and the Python execution loop will automatically resume.
cd ui
npm install
npm run dev
## ๐ค Contributing
We are actively looking for design partners. If you are building autonomous agents in production and are terrified of what they might do, open an issue or reach out!
## ๐๏ธ The Architecture (Split-Plane)
AgentX relies on a decoupled, hybrid-cloud architecture to ensure maximum performance and security for AI-driven enterprise systems.
* **The Edge SDK (AgentX):** The lightweight Python package that instruments agent tools and triggers local Socratic self-healing.
* **The Data Plane (Semantic Firewall):** A Python FastAPI middleware (the "Wedge") that intercepts raw HTTP/SQL payloads *before* they hit the database.
* **The Control Plane (Dashboard):** A Next.js application (deployed via Vercel) that allows human reviewers to monitor intercepted agent traffic, review chains of thought, and approve or deny parked requests.
* **The Shared Brain:** Supabase acts as the central state manager. Both the Control Plane and Data Plane synchronize via Supabase, decoupling the network architecture and allowing asynchronous state polling.
* **The Evaluator:** Google's Gemini 2.5 Flash is used to translate an agent's Chain of Thought (CoT) into a zero-knowledge taxonomy to evaluate intent against YAML-defined enterprise policies.
## โจ Key Features & Built-in Policies
* **Automated Socratic Self-Healing**: Intercepts dangerous tool calls and challenges the agent to revise its strategy.
* **Fast Pass Heuristic Traps**: Instantly intercepts structurally dangerous queries (e.g., `DROP TABLE`, `DELETE`) with minimal latency.
* **Zero-Knowledge Intent Extraction**: Prevents malicious prompt injection by translating raw agent logic into a strict schema before policy evaluation.
* **Dynamic Cloud Policies**: Enforces isolation rules instantly via a Supabase-backed Control Plane that syncs to edge caches in 3 seconds.
## ๐ Security Posture
* **Secret Management:** API keys are never checked into version control. Production variables are managed securely via the Vercel Dashboard.
* **History Scrubbing:** This repository has been scrubbed of legacy keys using git-filter-repo.
* **Private IP:** Repository is private to protect proprietary evaluation prompts and architecture.
## ๐ Roadmap
* **โ
Trust Boundary Shift:** Moved neuro-symbolic evaluation entirely into the Data Plane container to eliminate agent runtime bypasses. (Completed)
* **โ
Zero-Knowledge Hard Split-Plane:** Mathematically enforced VPC telemetry isolation via localized metric stripping. (Completed)
* **โฌ Local LRU Neural Cache:** Deduplicate vector embeddings to minimize edge latency down to sub-1ms. (Next up)
* **โฌ Core DevX Inspection Engine:** Expose a unified CLI interface for localized policy and metric auditing. (Active)
* **Dynamic Policy Engine:** Shift YAML configurations directly into Supabase for instant Control Plane sync.
* **Dockerization:** Containerize the Data Plane for deployment to AWS ECS / Render for persistent, low-latency edge interception.
* **Multi-Tenancy:** Implement Supabase Row Level Security (RLS) for multi-org deployments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentx_security_sdk-0.2.6.tar.gz.
File metadata
- Download URL: agentx_security_sdk-0.2.6.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c5a9d1d0c95b1027fa716a3d66460e4e69744e40cea18d26737f69a2a0708fc
|
|
| MD5 |
bb49411fca538fa9f4e964d6403235c0
|
|
| BLAKE2b-256 |
d9c7ec045812d9dd9230ff76a7f40409aa652b7c93cef80234d4fd6ab03e4d1f
|
File details
Details for the file agentx_security_sdk-0.2.6-py3-none-any.whl.
File metadata
- Download URL: agentx_security_sdk-0.2.6-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ecab3ddb36d1d83521ce3422f60be9f22bf859f6bb4747152e4d74859ba1599
|
|
| MD5 |
87533f9bb1444b405d630ac642f13f42
|
|
| BLAKE2b-256 |
d7f7001f90c17443f4373b94ee536753fd8c0008ae9100d856d0db072ddd5f9d
|