AgentShield Python SDK
Lightweight security guardrails for AI agents. All security logic runs server-side.
Quick Start
from agentshield import Shield
shield = Shield() # reads AGENTSHIELD_API_KEY from env
@shield.guard
async def send_email(to: str, body: str) -> str:
... # your tool implementation
# The server decides: ALLOW, BLOCK, or REQUIRE_CONFIRMATION
await send_email(to="user@company.com", body="Hello")
Session Mode
async with shield.session("Summarize my emails") as s:
result = await s.guarded_executor.execute(
"read_inbox", {"limit": 10}, read_inbox_fn
)
Error Handling
from agentshield import Shield, ToolCallBlocked, ConfirmationRejected, ServerError
shield = Shield()
@shield.guard
async def send_email(to: str, body: str) -> str:
...
try:
await send_email(to="user@test.com", body="hi")
except ToolCallBlocked as e:
print(f"Blocked: {e.reason} (trace: {e.trace_id})")
except ConfirmationRejected:
print("User declined confirmation")
except ServerError as e:
print(f"Server error: {e}")
Configuration
# Explicit configuration
shield = Shield(
api_key="your-key",
base_url="https://shield.yourcompany.com",
timeout=10.0,
max_retries=3,
agent_id="my-agent",
)
Or via environment variables:
AGENTSHIELD_API_KEY(required)AGENTSHIELD_BASE_URL(default: http://localhost:8000)AGENTSHIELD_TIMEOUT(default: 10.0)AGENTSHIELD_AGENT_ID
Or via agentshield.yaml in the working directory.
Data Sanitization
# Sanitize external data before processing
result = await shield.sanitize(
data=email_body,
source="email/external",
)
# result.content has hidden injections removed
# result.trust_level shows the computed trust level
Framework Integrations
from agentshield.integrations import LangChainShield, CrewAIShield
# LangChain
guarded = LangChainShield(shield).wrap(agent_executor)
# CrewAI
guarded = CrewAIShield(shield).wrap(crew)
# AutoGen
from agentshield.integrations import AutoGenShield
AutoGenShield(shield).wrap(assistant)
# Claude Agent SDK
from agentshield.integrations import ClaudeAgentShield
guarded_handler = ClaudeAgentShield(shield).wrap(my_tool_handler)
Metadata
Release files for agentshield-runtime 0.1.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 |
|---|---|---|---|---|
| agentshield_runtime-0.1.0.tar.gz | 19.4 kB | Without provenance | Details for agentshield_runtime-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentshield_runtime-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agentshield_runtime-0.1.0-py3-none-any.whl |
Total release size: 40.7 kB
Release files / agentshield_runtime-0.1.0.tar.gz
| Download URL | agentshield_runtime-0.1.0.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f7f4cf275859995d95b47d7cef2f6c76aaad20d229b8db6c7b09ed4dd797d24
|
|
BLAKE2b-256 checksum How to use checksums |
134e40d84ef21d3f41cea239c92f2443762230b0a2b6ec4977b33906cc08313c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / agentshield_runtime-0.1.0-py3-none-any.whl
| Download URL | agentshield_runtime-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0dd0a0efa7b16f2d3e629905070095461d23bd5ade67bb3f2402cc7fd03e8f5
|
|
BLAKE2b-256 checksum How to use checksums |
3ddae884fd30b7130ab44f94e40556a900a68d323782fa503815da184df697a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for agentshield-runtime 0.1.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.