agentshield
Runtime security middleware for LLM agents. Drop it into your existing agent framework — no refactor required.
Defends against:
- Prompt injection (user input hijacking system instructions)
- Tool misuse & privilege escalation (agents calling tools outside intended scope)
- Memory poisoning (persistent agent memory corrupted across sessions)
- RAG context injection (poisoned document chunks injecting instructions)
Install
pip install apexguard
# or
npm install @apexguard/sdk
Python — 30-second quickstart
from apexguard import Shield, Policy
shield = Shield(
policy=Policy(
tool_allowlist=["calculator", "web_search"],
memory_ttl=3600,
injection_sensitivity="medium",
on_violation="block",
)
)
# Wrap your existing LangChain agent
secured_agent = shield.wrap(your_langchain_agent)
result = secured_agent.invoke({"input": user_query})
LangChain tool integration
from apexguard.adapters.langchain import shield_tools
secured_tools = shield_tools(your_tools, shield)
agent = create_react_agent(llm, secured_tools, prompt)
Custom violation handler
shield.on_violation(lambda e: send_to_slack(e))
TypeScript — 30-second quickstart
import { Shield } from '@apexguard/sdk';
const s = new Shield({
policy: {
toolAllowlist: ['calculator', 'webSearch'],
memoryTTL: 3600,
injectionSensitivity: 'medium',
onViolation: 'block',
},
});
const securedAgent = s.wrap(yourAgent);
Vercel AI SDK tools
import { shieldTools } from '@apexguard/sdk/adapters/vercel-ai';
const result = await generateText({
model: openai('gpt-4o'),
tools: shieldTools({ calculator, webSearch }, s),
prompt: userInput,
});
Modules
| Module | What it does |
|---|---|
PromptFirewall |
Pattern-matching injection detector — 0 external calls, <1ms |
ToolSentinel |
Allowlist/denylist + per-turn rate limiting for tool calls |
MemoryGuard |
TTL enforcement + untrusted-write quarantine for agent memory |
Policy options
| Option | Default | Description |
|---|---|---|
tool_allowlist |
None |
Whitelist of permitted tool names. None = all allowed |
tool_denylist |
[] |
Hard-blocked tool names |
memory_ttl |
3600 |
Memory entry lifetime in seconds. 0 = no expiry |
injection_sensitivity |
"medium" |
Pattern set: low / medium / high |
on_violation |
"warn" |
"warn" (log only), "block" (raise), "quarantine" (suppress) |
max_tool_calls_per_turn |
20 |
Rate limit per agent turn |
max_memory_entries |
1000 |
Cap on memory store size |
License
Apache 2.0
Metadata
Release files for apexguard 0.1.7
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 | |
|---|---|---|---|---|
| apexguard-0.1.7.tar.gz | 11.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apexguard-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / apexguard-0.1.7.tar.gz
| Download URL | apexguard-0.1.7.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddddb3915f346bf2bba14a21e6e36962ce913b0d2b7525f481947d5ac330c4ad
|
|
BLAKE2b-256 checksum How to use checksums |
3667c0eb9423b3ba0aadfff2d59ac4f768bfa8b4f692857c6701bb4657e52b68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.
Transparency logRelease files / apexguard-0.1.7-py3-none-any.whl
| Download URL | apexguard-0.1.7-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abf10f0544ea5b62edb55aa21a5281b513e22b02cf918fbad34aa6a909bcdac4
|
|
BLAKE2b-256 checksum How to use checksums |
d4ac781a77099e07dee84f0a46f031ac4634eb2039b39ff9cf326a8325f1d1a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.
Transparency logSecurity for apexguard 0.1.7
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for apexguard-0.1.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.
Transparency logA 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.