Skip to main content

AgentShield Python SDK 🛡️

PyPI version Python 3.10+ License: MIT Interactive Playground Trust Center

Enterprise-grade Zero-Leak Secret Defense & Sandbox for Autonomous AI Agents built with LangGraph, CrewAI, AutoGen, LlamaIndex, and Smolagents.

Documentation • Web Portal • Trust Center • Issues


⚡ Key Features

  • @shield.protect Decorator: Zero-boilerplate function and tool protection. Automatically intercepts arguments and return values.
  • Framework Integrations:
    • LangChain & LangGraph: AgentShieldCallbackHandler
    • CrewAI: AgentShieldCrewHook
    • LlamaIndex: AgentShieldLlamaHandler
    • Microsoft AutoGen: AgentShieldAutoGenGuard
  • Zero-Leak Redaction: 40+ credential types (OpenAI, Anthropic, AWS, GitHub, Stripe, Slack, private keys, /proc/self/environ).
  • Environment Sanitization: sanitize_env() replaces sensitive variables with virtual mock tokens.
  • HMAC-SHA256 Audit Ledger: Cryptographically seals every inspection with microsecond overhead.

📦 Installation

pip install agentshield-defense

Note: In code, import as standard import agentshield or from agentshield import shield.


🚀 Usage Guide

1. The @shield.protect Decorator

Decorate any agent tool, custom function, or LLM wrapper:

from agentshield import shield

@shield.protect
def deploy_infrastructure(target: str, config: str) -> str:
    # Any incoming AWS keys or OpenAI keys in config are automatically masked
    return f"Deployed {target} with token: AKIAIOSFODNN7EXAMPLE"

# When executed:
output = deploy_infrastructure("prod-cluster", "key=sk-1234567890abcdef1234567890abcdef")
print(output)
# -> "Deployed prod-cluster with token: [AGENTSHIELD_REDACTED:AWS_ACCESS_KEY:a1b2c3d4e5f6]"

For strict enforcement (raising PermissionError on leak):

from agentshield import protect

@protect(strict=True)
def sensitive_operation():
    ...

2. LangGraph & LangChain Integration

from langchain_openai import ChatOpenAI
from agentshield import AgentShieldCallbackHandler

shield_handler = AgentShieldCallbackHandler()

llm = ChatOpenAI(
    model="gpt-4o",
    callbacks=[shield_handler]
)
# Outgoing prompts and tool invocations are inspected and sanitized in real time

3. CrewAI Guardrail Hook

from crewai import Task
from agentshield import AgentShieldCrewHook

hook = AgentShieldCrewHook()

task = Task(
    description="Analyze server environment and deploy database",
    expected_output="Deployment summary"
)

hook.before_task_execution(task)

4. LlamaIndex Callback Handler

from llama_index.core import Settings
from agentshield import AgentShieldLlamaHandler

Settings.callback_manager.add_handler(AgentShieldLlamaHandler())

5. Microsoft AutoGen Message Guard

from agentshield import AgentShieldAutoGenGuard

guard = AgentShieldAutoGenGuard()
clean_message = guard.filter_message(incoming_message)

🔒 Security & Compliance

  • Zero Cloud Exfiltration: Runs 100% locally with AGENTSHIELD_AIR_GAPPED=1.
  • Pre-filled SIG Lite / CAIQ: Download the Vendor Risk Assessment Packet at ritualdev.in/trust.
  • Statutory Alignment: Designed for India DPDP Act 2023, EU GDPR, and SOC 2 Type II.

📄 License

MIT © RitualDev Studio

Metadata

Release files for agentshield-defense 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentshield-defense 0.2.2
File Size Uploaded Provenance Actions
agentshield_defense-0.2.2.tar.gz 13.4 kB Without provenance Details for agentshield_defense-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentshield-defense 0.2.2
File Interpreter ABI Platform Actions
agentshield_defense-0.2.2-py3-none-any.whl Python 3 none any Details for agentshield_defense-0.2.2-py3-none-any.whl

Total release size: 25.5 kB

Release files / agentshield_defense-0.2.2.tar.gz

Download URL agentshield_defense-0.2.2.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b8e7e8cf113ae7043f94203ea0a968ee6442efb861ff94573d4f3a99421cca82
BLAKE2b-256 checksum
How to use checksums
21deb1c7e3878cf3a9d9147150535b81213da2ac688c9364211178868a75ef40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / agentshield_defense-0.2.2-py3-none-any.whl

Download URL agentshield_defense-0.2.2-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aed5e6fd8169ec0d0b905a98d28941e15ae66174aab9f17b4b39abe28ddafbb9
BLAKE2b-256 checksum
How to use checksums
4e2d6767462f91e6a630f7c16d5ca57160609562e6477936a4c906b477e2f3e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for agentshield-defense 0.2.2

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.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page