{"slug": "built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling", "title": "Built a zero-latency AST bouncer for local agent tool-calling", "summary": "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.", "body_md": "Hey everyone,\n\nLike many of you, we got frustrated with the current state of safety guardrails for autonomous agents.\n\nWhen 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:\n\nInstead 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.\n\nIf an agent attempts:\n\n`rm -rf`\n\n, `mkfs`\n\n, raw device writes)`DROP TABLE`\n\n, `TRUNCATE`\n\n)`().__class__.__base__.__subclasses__()`\n\n)`/etc/shadow`\n\n, `.env`\n\n, `id_rsa`\n\n)The tool execution is aborted in **under 40 microseconds** (<0.00004s) directly inside Python memory, with zero OS syscalls spawned.\n\nIt's published on PyPI as `btp-guard`\n\n:\n\n```\nbash\npip install btp-guard\n```\n\n", "url": "https://wpnews.pro/news/built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling", "canonical_source": "https://dev.to/ivegotahunnitonit/built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling-3lk6", "published_at": "2026-09-02 07:27:27+00:00", "updated_at": "2026-09-02 07:53:01.127629+00:00", "lang": "en", "topics": ["ai-safety", "developer-tools", "ai-agents", "artificial-intelligence"], "entities": ["btp-guard", "Ollama", "vLLM", "LM Studio", "Bedrock", "OpenAI Moderation"], "alternates": {"html": "https://wpnews.pro/news/built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling", "markdown": "https://wpnews.pro/news/built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling.md", "text": "https://wpnews.pro/news/built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling.txt", "jsonld": "https://wpnews.pro/news/built-a-zero-latency-ast-bouncer-for-local-agent-tool-calling.jsonld"}}