cd /news/ai-safety/built-a-zero-latency-ast-bouncer-for… · home topics ai-safety article
[ARTICLE · art-118704] src=dev.to ↗ pub= topic=ai-safety verified=true sentiment=↑ positive

Built a zero-latency AST bouncer for local agent tool-calling

A developer has released btp-guard, an open-source Python package that performs in-memory AST-based safety checks on code blocks generated by local LLM agents before execution. The tool parses Python, SQL, and Bash code to block dangerous operations like file deletion, database drops, and privilege escalation in under 40 microseconds, eliminating the need for remote moderation endpoints.

read1 min views1 publishedSep 2, 2026

Hey everyone,

Like many of you, we got frustrated with the current state of safety guardrails for autonomous agents.

When you're running local LLMs (via Ollama, vLLM, or LM Studio) to execute bash scripts or database queries, calling a remote cloud moderation endpoint (Bedrock, OpenAI Moderation) defeats the entire purpose of running locally:

Instead of asking another model if a proposed command is safe, we built an in-process Abstract Syntax Tree (AST) evaluator that parses Python, SQL, and Bash code blocks directly in caller memory before execution.

If an agent attempts:

rm -rf

, mkfs

, raw device writes)DROP TABLE

, TRUNCATE

)().__class__.__base__.__subclasses__()

)/etc/shadow

, .env

, id_rsa

)The tool execution is aborted in under 40 microseconds (<0.00004s) directly inside Python memory, with zero OS syscalls spawned.

It's published on PyPI as btp-guard

:

bash
pip install btp-guard
── more in #ai-safety 4 stories · sorted by recency
── more on @btp-guard 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/built-a-zero-latency…] indexed:0 read:1min 2026-09-02 ·