Runtime EDR for AI agents — zero-code-change monitoring for LangChain, LangGraph, OpenAI Assistants, and the Anthropic SDK
Project description
ShieldPi — Runtime EDR for AI Agents
Zero-code-change monitoring for AI agents. Every tool call, LLM call, file read, and outbound request your agent makes streams to ShieldPi's detectors in real time — the same way EDR agents stream endpoint events to a SIEM.
The 60-second setup
pip install "shieldpi[all]"
export SHIELDPI_SDK_KEY=shpi_live_... # get one at https://shieldpi.io/dashboard
# Add one import at the top of your agent process:
import shieldpi.auto
# Use LangChain / LangGraph / OpenAI Assistants / Anthropic SDK normally.
from langchain.agents import AgentExecutor
agent = AgentExecutor(...)
agent.invoke({"input": "..."}) # every tool call + LLM call is captured
That's it. Open https://shieldpi.io/dashboard/agent-monitor to see the live event stream and any alerts the detectors fire.
What gets captured
| Agent action | What ShieldPi sees | Detector that scores it |
|---|---|---|
| User sends a message | user_message event |
pattern_match scans for jailbreak strings |
| Agent calls a tool | tool_call event with args |
analyzer categorizes (destructive / exfil / credential_access) |
| Agent reads a file | tool_call args with path |
pattern_match catches path traversal |
| Agent makes HTTP request | tool_call with URL |
trajectory catches read→exfil kill chains |
| Agent writes to memory | memory_write event |
memory_integrity detects tampering |
| Agent responds to user | final_response event |
response_leak_scanner checks for leaked secrets |
Six detectors run in parallel on every event: pattern_match, trajectory, analyzer, memory_correlation, memory_integrity, response_leak_scanner.
Supported frameworks
| Framework | Auto-patch | Manual handler | Optional dep |
|---|---|---|---|
| LangChain (AgentExecutor) | ✅ | ✅ | pip install shieldpi[langchain] |
| LangChain (LCEL tools) | ✅ (BaseTool hook) | ✅ | pip install shieldpi[langchain] |
| LangGraph | ✅ | ✅ | pip install shieldpi[langgraph] |
| OpenAI Assistants API | ✅ | — | pip install shieldpi[openai] |
| OpenAI Chat Completions w/ tools | ✅ | — | pip install shieldpi[openai] |
| Anthropic SDK (tool use) | ✅ | ✅ | pip install shieldpi[anthropic] |
| Custom agents (no framework) | — | ✅ | base install |
Explicit configuration (optional)
If you want to override env-var defaults:
import shieldpi.auto
shieldpi.auto.configure(
sdk_key="shpi_live_...", # or SHIELDPI_SDK_KEY env
agent_name="invoice-bot", # or SHIELDPI_AGENT_NAME env
stated_goal="help users file invoices",
frameworks=["langchain", "anthropic"], # or SHIELDPI_AUTO_INSTRUMENT=langchain,anthropic
)
Environment variables:
| Variable | Purpose |
|---|---|
SHIELDPI_SDK_KEY |
Your SDK key (starts with shpi_live_). Required. |
SHIELDPI_BASE_URL |
Override the API base URL (defaults to production). |
SHIELDPI_AGENT_NAME |
Logical name for this agent. Default: unnamed-agent. |
SHIELDPI_AGENT_GOAL |
Stated goal (helps detectors flag off-goal behavior). |
SHIELDPI_AUTO_INSTRUMENT |
Comma-separated framework allowlist. Default: all installed. |
Manual integration
For custom agents or full control:
from shieldpi import Monitor
monitor = Monitor(sdk_key="shpi_live_...")
with monitor.start_session(
agent_name="invoice-bot",
stated_goal="help users file invoices",
) as session:
session.log_user_message("How do I file a Q1 invoice?")
session.log_tool_call("search_docs", {"query": "Q1 invoice filing"})
session.log_tool_result("search_docs", {"results": [...]})
session.log_final_response("Here's how to file a Q1 invoice...")
LangChain (manual)
from shieldpi import Monitor
from shieldpi.hooks.langchain import ShieldPiCallbackHandler
monitor = Monitor(sdk_key="shpi_live_...")
handler = ShieldPiCallbackHandler(monitor, agent_name="my-agent")
agent.invoke({"input": "..."}, config={"callbacks": [handler]})
Anthropic SDK (manual)
from anthropic import Anthropic
from shieldpi import Monitor
from shieldpi.hooks.anthropic import monitored_tool_use
anth = Anthropic()
monitor = Monitor(sdk_key="shpi_live_...")
with monitored_tool_use(monitor, agent_name="invoice-bot") as session:
session.log_user_message("Help me file an invoice")
response = anth.messages.create(
model="claude-opus-4-20250514",
messages=[{"role": "user", "content": "Help me file an invoice"}],
tools=[...],
)
session.observe_anthropic_response(response)
Safety guarantees
The SDK is built to never crash your agent:
- Every HTTP call is fire-and-forget (background worker, bounded queue).
- Monitoring failures are logged at WARNING level; they never raise to your agent.
- If
SHIELDPI_SDK_KEYis missing,import shieldpi.autologs once and does nothing. - All patches are idempotent — double-import won't double-wrap.
- Patches gracefully no-op when the target framework isn't installed.
What's new in 0.2.0
shieldpi.auto— one-line zero-code-change monitoring for LangChain, LangGraph, OpenAI, and Anthropic.- LangGraph support — first-class patching of
Pregel.invoke/ainvoke/stream/astream. - OpenAI Assistants support — new patch for
client.beta.threads.runs.create_and_polland Chat Completions with tools. - Import hook — frameworks imported AFTER
shieldpi.autoare still patched. - Idempotent patches — safe to re-import or reconfigure at runtime.
Links
- Dashboard — https://shieldpi.io/dashboard/agent-monitor
- Docs — https://shieldpi.io/docs/live-agent-monitor
- Scanner package —
shieldpi-mcp(MCP server for Claude Desktop / Cursor / Continue)
License
Apache-2.0
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 shieldpi-0.2.0.tar.gz.
File metadata
- Download URL: shieldpi-0.2.0.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dbdf2b91a47a244944443fa4407121454bf8b76bcdfcd65901d6403a65d0392
|
|
| MD5 |
1b0888e4f938a7bebd3ef710552e3331
|
|
| BLAKE2b-256 |
4d0f3367113ba7b458e676855862dd7e04fea9c84db7464d783e3b61be3003f0
|
File details
Details for the file shieldpi-0.2.0-py3-none-any.whl.
File metadata
- Download URL: shieldpi-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6fe034a6dbf6ba6297caf411173a19a2d2299421a17039ea98cba1fde81d6b2
|
|
| MD5 |
902111cb579cda60d2b93b14e3b426f8
|
|
| BLAKE2b-256 |
c7b0f7f2880c9eb3aec15465176475c19e5bd1b8d3401b9a7720e86ab52cf00a
|