Skip to content

About

Official Python SDK and middleware for AgentShield: safeguard LangChain, LlamaIndex, AutoGen, and CrewAI pipelines against prompt injection and data leaks.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

0 stars

Watchers

0 watching

Forks

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



πŸ’– Sponsor & Support

If you find this project valuable, consider supporting our open-source development:

Sponsor on Dodo Payments Interactive Donation Portal GitHub Sponsors


πŸ›‘οΈ Community & Governance

About

Official Python SDK and middleware for AgentShield: safeguard LangChain, LlamaIndex, AutoGen, and CrewAI pipelines against prompt injection and data leaks.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages