How to safely run llama.cpp native tools (exec_shell_command) with multi-sandboxing on Linux

✍️ OpenClawRadar📅 Published: June 7, 2026🔗 Source
How to safely run llama.cpp native tools (exec_shell_command) with multi-sandboxing on Linux
Ad

The llama.cpp project recently added native tool support to its llama-server, enabling the model to call functions like get_datetime and — the powerful but dangerous — exec_shell_command. A Reddit user shared a detailed multi-sandboxing workflow to safely use exec_shell_command for tasks like web RAG (fetching live URLs) without risking the host system.

Key details from the source

  • Model used: Qwen3.6-35B-A3B_MTP-UD-Q8_K_XL.gguf with MTP speculative decoding
  • Server flags: --jinja --tools get_datetime,exec_shell_command --temp 0.6 --top-p 0.95 --top-k 20 --presence-penalty 1.5 --min-p 0.00 --chat-template-kwargs '{"preserve_thinking":true}' --spec-type draft-mtp --spec-draft-n-max 1
  • Multi-sandboxing stack: Firejail + smolvm (Alpine Linux VM) + dedicated Linux user for tool execution
Ad

Step-by-step setup

  1. Enable tools in llama-server: start with --tools get_datetime,exec_shell_command (test with get_datetime first)
  2. Install Firejail (e.g., sudo pacman -S firejail on Arch)
  3. Create isolated user: sudo useradd -m vmagents; sudo passwd vmagents
  4. Switch to vmagents and install smolvm: curl -sSL https://smolmachines.com/install.sh | bash
  5. Create a minimal Alpine VM:
    smolvm machine create minivm --image alpine --net
    smolvm machine start --name minivm
  6. Create minivm-exec in ~vmagents/.local/bin/:
    #!/bin/sh
    smolvm machine start --name minivm >/dev/null
    firejail smolvm machine exec --name minivm -- $* 2>/dev/null
    smolvm machine stop --name minivm >/dev/null
    Make executable: chmod +x minivm-exec
  7. Create vm-exec in your own user's ~/.local/bin/:
    #!/bin/sh
    sudo su - vmagents -c "minivm-exec $*"
    Make executable.
  8. In llama-server web UI, prompt the model to use vm-exec as a wrapper, e.g.:
    Prepend any command to be executed with the sandboxing wrapper vm-exec. Use wget to fetch web content adding the option "-U Mozilla" as browser user agent string.
    Then ask it to retrieve a live URL and analyze the content.

How the sandboxing works

Commands are run inside a temporary Alpine Linux VM (minivm) created by smolvm, which itself is wrapped in a Firejail sandbox. This isolates network access, filesystem, and process space. The vm-exec script on the host invokes the whole chain as the vmagents user, preventing any escalation to the host user's home directory or critical system files. The VM is stopped after each command, ensuring no persistent state from malicious actions.

Who this is for

Developers running local LLM servers and wanting to safely allow code execution or web fetching via agentic tools without exposing the host OS.

📖 Read the full source: r/LocalLLaMA

Ad

👀 See Also

Three-layer memory architecture for persistent OpenClaw agent context
Guides

Three-layer memory architecture for persistent OpenClaw agent context

A developer built a 3-layer memory system on top of OpenClaw's infrastructure to prevent agents from starting each session without context. The architecture includes L1 workspace files injected every turn, L2 semantic memory search, and L3 reference documents opened on demand.

OpenClawRadar
Reddit Post: Developers Need Better AI Coding Practices, Not Just Better Tools
Guides

Reddit Post: Developers Need Better AI Coding Practices, Not Just Better Tools

A Reddit post argues that developers' dissatisfaction with AI coding tools stems from poor prompting practices, specifically 'raw prompting' without context or structure. The author recommends using scaffolding like CLAUDE.md and structured workflows to get production-ready code from Claude.

OpenClawRadar
Multi-Agent Architecture: Avoiding the Single-Agent Pitfall in AI Systems
Guides

Multi-Agent Architecture: Avoiding the Single-Agent Pitfall in AI Systems

A Reddit post identifies the common architectural mistake of using a single agent for multiple tasks, which leads to fragile systems requiring constant babysitting. The solution proposed is an orchestrator-specialist model where each agent has a narrow, specific role.

OpenClawRadar
Interactive Explainer Maps Claude Code Agent Loop Designs, from Single Calls to Self-Mutating Prompts
Guides

Interactive Explainer Maps Claude Code Agent Loop Designs, from Single Calls to Self-Mutating Prompts

An interactive site built with Opus 4.7 visualizes 11 real agent loop designs for Claude Code, from basic calls to agents that rewrite their own prompts, with SVG animations showing memory and loop mechanics.

OpenClawRadar