DEV Community

DC
DC

Posted on

"Add a Kill Switch to Any AI Agent in 5 Lines of Python"

AI agents are powerful, but what happens when they go rogue? Here's how to add safety controls to ANY AI agent in 5 lines of code.

The Problem

Coding assistants can delete files. Autonomous agents can spawn more agents. Trading bots can drain wallets. We need guardrails.

The Solution: Runtime Fence


python
pip install runtime-fence  5 Lines of Code
python
from runtime_fence import RuntimeFence, FenceConfig

fence = RuntimeFence(FenceConfig(
    agent_id="my-agent",
    blocked_actions=["delete", "exec", "rm"]
))

result = fence.validate("delete", "important_file.py")
if not result.allowed:
    print(f"BLOCKED: {result.reasons}")

That's it. Your agent now has a safety layer.

Works With Everything
✅ LangChain
✅ AutoGPT
✅ Copilot/Cursor/Aider
✅ Custom agents
✅ Trading bots
✅ Data analysts
Real Examples

Stop Cursor from deleting files:
python
fence = RuntimeFence(FenceConfig(
    blocked_actions=["rm", "delete"],
    blocked_targets=[".git/", ".env"]
))

Limit AutoGPT spending:
python
fence = RuntimeFence(FenceConfig(
    spending_limit=50.0,
    blocked_actions=["spawn_agent", "modify_self"]
))

Emergency stop ANY agent:
python
fence.kill("Suspicious activity detected")

Why It Matters
As AI agents get more autonomous, accidents happen:
Coding assistants accidentally delete production code
Autonomous agents modify their own config
Data bots export sensitive PII
Runtime Fence adds the missing safety layer.
Try It
GitHub: https://github.com/RunTimeAdmin/ai-agent-killswitch
PyPI: https://pypi.org/project/runtime-fence

Works 100% offline, no signup required
Open source (MIT). Built by developers who got tired of AI accidents.


Enter fullscreen mode Exit fullscreen mode

Top comments (0)