r/PiCodingAgent • u/drtikov • 6h ago
Resource Free open-source local safety gate for Prime Agent: 2-line setup, <0.31 ms overhead, saves error-recovery tokens and blocks risky tool calls
Hey everyone,
I just added native Prime Agent support to Aetheris Microbrains, an open-source, 100% local CPU pre-flight safety gate (Apache 2.0, zero GPU, no cloud calls, pure Python stdlib core).
You do not need to modify Prime Agent's core runtime. It wraps Prime's REPL callables (rlm.bash, edit.run, and mcp.call_tool — both sync and async) in two lines:
from aetheris_microbrains.prime_gate import install_prime_gate install_prime_gate(profile="dev")
And you can verify it anytime with: aetheris install prime --self-test
Why it is useful for Prime Agent users:
- Blocks critical hazards before they run: catches destructive shell commands (rm -rf, curl | bash), broken syntax and dangerous code edits (os.system, subprocess), large risky diffs, and unpinned MCP tools before execution.
- Protects your secrets and Prime config: locks down .prime/ and .prime/agent/settings.json so an agent cannot disable its own guardrails, and scrubs leaked credentials from bash, edit, and MCP tool outputs before they reach the REPL (failing closed if redaction cannot be applied).
- Saves tokens on wasted retries: catching syntax errors and bad tool calls locally prevents expensive multi-turn error-recovery loops (modeled at up to ~97% fewer error-recovery tokens per session in our Prime benchmarks).
- Negligible overhead: runs in-process at under 0.31 ms p99 latency across bash, edit.run, and mcp.call_tool, using about 0.5 MB of memory.
- Safe rollout and tamper-evident logs: supports shadow_mode=True (log without blocking) and writes a SHA-256 hash-chained audit journal you can verify with aetheris-audit --verify-chain.
Repo (Apache 2.0): https://github.com/drtikov/microbrainsforagents
Happy to answer questions or hear feedback if you try it with Prime Agent.