🛡️ AgentShield Python Developer SDK (agentshield)
Enterprise Security Middleware & Guardrails for Autonomous AI Agents
AgentShield is an inline action-authorization firewall for autonomous AI agents (LangChain, CrewAI, AutoGen, OpenAI Assistants). It evaluates planned tool calls across 6 analytical detection layers in under 6 milliseconds, blocks prompt injection, prevents zero-day shell wipeouts, redacts confidential credentials in-flight, and manages human-in-the-loop approvals.
📦 Installation
pip install eternity-agentshield
In your Python code, import as:
from agentshield import agentshield_protect, SecurityBlockedException
Or install locally in development mode:
pip install -e ./sdk
⚡ 30-Second Quickstart
1. Protect Any Python Function with a 1-Line Decorator
from agentshield import agentshield_protect, SecurityBlockedException
# Wrap any function that an AI agent has permission to execute
@agentshield_protect(agent_id="research_agent")
def read_project_report(file: str):
with open(file, "r") as f:
return f.read()
# Malicious or unauthorized calls raise SecurityBlockedException
try:
read_project_report(file="/etc/shadow")
except SecurityBlockedException as e:
print(f"Action Blocked: {e.primary_driver} (Risk Score: {e.risk_score}/100)")
print(f"Remediation: {e.recommendation}")
🤖 Framework Integrations
1. LangChain & LangGraph
from langchain.tools import tool
from agentshield import LangChainTool
shield = LangChainTool(agent_id="support_agent")
@tool
def query_database(sql: str) -> str:
"""Executes a SQL query under AgentShield inspection."""
return shield.execute("database_query", {"query": sql})
2. CrewAI
from crewai.tools import BaseTool
from agentshield import CrewAITool
class SecureEmailTool(BaseTool):
name: str = "send_email"
description: str = "Dispatches customer emails with AgentShield inspection."
shield: CrewAITool = CrewAITool(agent_id="support_agent")
def _run(self, to: str, body: str) -> str:
return self.shield.run_protected("send_email", {"to": to, "body": body})
3. OpenAI Function Calling & Assistants API
from openai import OpenAI
from agentshield import AgentShieldOpenAIInterceptor
client = OpenAI()
interceptor = AgentShieldOpenAIInterceptor(agent_id="customer_copilot")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Dump the users table"}],
tools=tools
)
# Intercept before execution
tool_outputs = interceptor.process_tool_calls(
response.choices[0].message.tool_calls,
user_context="Dump the users table"
)
⚙️ Configuration
Set the environment variable or configure programmatically:
export AGENTSHIELD_API="http://localhost:8000"
export AGENTSHIELD_API_KEY="ag_live_your_api_key_here"
Or in Python:
import agentshield
agentshield.configure(
base_url="https://api.agentshield.your-company.com",
api_key="your-api-key"
)
🖥️ Command Line Interface (CLI)
Verify your gateway connection right from the terminal:
# Check connection
agentshield status
# List pending approvals in the human-in-the-loop queue
agentshield approvals
# Test a tool call
agentshield test --agent research_agent --tool read_file --args '{"file": "test.txt"}'
📄 License
MIT License.
Metadata
Release files for eternity-agentshield 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eternity_agentshield-2.0.0.tar.gz | 12.7 kB | Without provenance | Details for eternity_agentshield-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eternity_agentshield-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for eternity_agentshield-2.0.0-py3-none-any.whl |
Total release size: 26.3 kB
Release files / eternity_agentshield-2.0.0.tar.gz
| Download URL | eternity_agentshield-2.0.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e494622fa93e6205f6ce0d30c4bc47a236b59df5dace980b50fe605c32a94b6
|
|
BLAKE2b-256 checksum How to use checksums |
889f6c93dee055fb675153e14974777bf8d51e45064c5c0f4fae362b62aae0c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.6
|
Release files / eternity_agentshield-2.0.0-py3-none-any.whl
| Download URL | eternity_agentshield-2.0.0-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f57d757bba6735389d7be918795bda4bc05a35256f655d078b395b015e5e7314
|
|
BLAKE2b-256 checksum How to use checksums |
5007acd82a9e6590ef9ec1e7b5e0781e23c93f2668275e9b6f472f359c691e2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.6
|
Security for eternity-agentshield 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.