The Research Report
llama-server --tools all: Your Local Model Just Became a Code Agent
llama.cpp shipped something quietly consequential in March 2026. PR #20898, authored by contributor ngxson, added built-in execution tools directly into llama-server. One flag activates them:
llama-server -m model.gguf --tools all
That single line turns any local GGUF model into a code agent. Read files, write files, search codebases, edit source, run shell commands. No MCP server. No Python wrapper. No extra moving parts.
The feature matters. The security implications matter more.
What --tools all Actually Gives You
Seven built-in tools ship inside llama-server when you enable them:
- read_file — Read any file on the host filesystem the server process can access
- write_file — Write content to a file path
- edit_file — Make targeted edits to existing files
- apply_diff — Apply patch-style file modifications
- fileglobsearch — Find files by glob pattern (e.g.,
src/*/.py) - grep_search — Search file contents with regex support
- execshellcommand — Execute arbitrary shell commands
An eighth tool, get_datetime, provides the current timestamp.
You can enable all of them with --tools all, or cherry-pick with --tools readfile,grepsearch,fileglobsearch to skip the dangerous ones.
Before this PR, every one of these operations required a separate MCP server or a custom Python harness. You had llama-server for inference, then you wired it to a file server, then to a shell server, then you wrote the orchestration code that handled tool-call routing, error recovery, and response injection back into context. That was three moving parts minimum. Now it is one binary.
How It Works Under the Hood
The execution flow for a single agent step looks like this:
- The model generates tokens during its forward pass and produces a tool call using its native chat template (Llama 3.1/3.3 uses a special token format, Qwen 2.5 uses Hermes-style syntax)
- The server's chat handler intercepts the tool-call token sequence and pauses generation
- For built-in tools, the server executes the operation directly inside its own process. For custom tools defined in your API request, it returns the tool call and waits for your code to respond
- The tool result gets injected into context as a tool-result message
- Generation resumes. The model sees the result and decides whether to call another tool or produce a final answer
The entire loop runs inside llama.cpp for built-in tools. No external orchestration. No JSON parsing in your application layer. The model and its tools share the same process, the same API endpoint, and the same agentic loop.
Models with native chat template handlers (Llama 3.1/3.2/3.3, Qwen 2.5 via Hermes, Mistral Nemo, Firefunction v2, Command R7B) get the efficient path. Unknown models fall back to generic JSON schema wrapping, which costs more tokens and has higher hallucination rates on tool-call formatting. You can verify which path your model uses by hitting GET /props on your server and checking the chat_template field.
The Agent Stack Collapses
Here is the practical significance. Before --tools all, building a local code agent required:
- llama-server for inference
- A separate MCP file/shell server for tool execution
- A desktop client or custom harness to wire inference to tools
- Error handling, retry logic, and context management across process boundaries
That is three distinct pieces of infrastructure, each with its own failure modes. With built-in tools, the second piece is gone. The server handles inference and tool execution in the same event loop. Your harness calls the same OpenAI-compatible chat completions endpoint it always called. The tools are an implementation detail.
For anyone running Qwen 3.x Coder, Llama 3.3 70B Instruct, or DeepSeek-Coder locally, this is the moment where the local agent stack compresses from "research project" to "one command."
# Start a code agent in one line
llama-server -m qwen3-coder-32b.gguf --tools all -ngl 99 --port 8080
That is the entire infrastructure. One process. One port. No YAML config files for MCP servers. No Python virtual environments.
The Security Problem
Here is where the story gets uncomfortable.
Every tool enabled by --tools all executes as the user who started the llama-server process. No sandbox. No chroot. No container isolation. No authentication layer. If you start llama-server as root with --tools all, the model can run any command as root.
The README states this plainly: "do not enable in untrusted environments."
That warning is accurate but buried. It does not appear at startup. It does not appear in the server logs when you enable the flag. It does not gate access behind a confirmation prompt. The flag is opt-in, which is good, but the consequences of opting in are severe enough that the community raised an immediate alarm.
Issue #21126, filed on March 28, 2026 by contributor maddes8cht, proposes a --tool-executor flag that would wrap every tool execution in a user-specified sandbox command:
# Proposed syntax (not yet merged)
--tool-executor "firejail --net=none -- %COMMAND%"
--tool-executor "podman run --rm -v /tmp:/tmp tool-sandbox %COMMAND%"
--tool-executor "sandboxie-run %COMMAND%"
The idea is straightforward: instead of executing tool calls directly, llama-server would format the command, substitute it into the executor template, and launch it as a subprocess. The exit code, stdout, and stderr would be captured and returned to the tool-calling logic exactly as before.
This is not merged yet. As of June 2026, if you enable --tools all, every tool call runs with full privileges of the server process.
What This Means in Practice
Scenario 1: Home lab developer. You run llama-server on your workstation, port 8080, bound to localhost. You enable --tools all for a coding project. The model can read your SSH keys, write to your .bashrc, and run rm -rf on your home directory. You are the threat model. If you send the model a malicious prompt, or if a tool-call injection reaches it, the consequences are unlimited.
Scenario 2: Shared server. You run llama-server on a team machine, bound to 0.0.0.0:8080 for convenience. Anyone on the network can send a chat completion request that triggers execshellcommand. No API key. No rate limit. No audit log of what commands ran. This is functionally equivalent to giving every network peer a shell on your server.
Scenario 3: Containerized deployment. You run llama-server in Docker with GPU passthrough. You enable --tools all. The model can execute commands inside the container. If the container has network access or mounted volumes, the blast radius extends beyond the container boundary.
The pattern here is not new. Cloud-hosted agent platforms (Claude Code, Cursor, Codex) all give models shell access. The difference: those platforms have authentication, rate limiting, audit logging, and in some cases sandboxed execution. llama-server has none of these. It is a single-user, single-process inference server with a REST API. Adding shell execution to that API surface without guards is a design decision that demands honest assessment.
Practical Security Guidance
If you use --tools all, follow these rules:
Never bind to 0.0.0.0. Use --host 127.0.0.1 to restrict access to localhost only. If you need remote access, put an auth proxy (nginx with basic auth, Caddy with forward auth) in front. Never expose the raw server to a network.
Do not run as root. Run llama-server under a dedicated user with minimal filesystem permissions. If the model runs rm -rf /, it should hit permission errors immediately.
Use the selective flag, not --tools all. If you do not need shell execution, enable only the safe subset:
llama-server -m model.gguf --tools read_file,grep_search,file_glob_search
This gives you read-only code search without the shell execution surface. Most coding assistance tasks work fine with read-only tools.
Run in a container or VM. Until --tool-executor lands, wrap llama-server in a container with restricted capabilities. Podman or Docker with --cap-drop ALL, read-only filesystem mounts, and no network access for the container gives you most of what the proposed --tool-executor flag would provide.
Set resource limits. Container memory limits, CPU limits, and PID limits constrain what a compromised model can do. Even without full sandboxing, resource limits turn a total system compromise into a contained incident.
Which Models Work With Built-in Tools
Not every model can use these tools effectively. Tool calling requires the model to emit well-structured function calls, not just text that looks like function calls. Models with native chat template handlers in llama.cpp handle this automatically. Models without native handlers fall back to generic JSON wrapping, which produces more formatting errors and hallucinated tool calls.
Models with native handlers as of June 2026:
- Llama 3.1 / 3.2 / 3.3 (Meta's official tool-call format)
- Qwen 2.5 / 3.x (shared Hermes-style handler)
- Mistral Nemo
- Firefunction v2
- Command R7B
For agent workloads specifically, you need models above roughly 30B parameters for reliable multi-step planning. Llama 3.1 8B works for single-tool lookups. Qwen 2.5 32B (Q4KM, fits in 24GB VRAM) is the realistic entry point for agents that need to reason across multiple tool calls. Llama 3.3 70B Instruct is the production choice when accuracy is non-negotiable, but requires 48GB VRAM.
A general-chat model without tool-call training will hallucinate tool calls into prose. The agentic loop will stall. Use a model trained for function calling.
The Bigger Picture
llama.cpp is no longer just an inference engine. The MCP client support merged in March 2026 (PR #18655) gave it an agentic loop that could call external servers. The --tools family adds built-in execution that needs no external server. Together, they make llama.cpp a complete local agent runtime.
For builders comparing local versus cloud agent loops on cost, latency, and privacy, this matters. A Mac Studio or a single H100 can now host an entire agent stack. Cursor-style behavior, Claude-Code-style file editing, your own filesystem, your own GGUF weights. No API keys. No per-token billing. No data leaving your machine.
The unresolved security model is the only thing that should stop a production team from shipping it today. Once --tool-executor or an equivalent sandboxing mechanism lands, local agent deployment becomes straightforward for organizations that need data privacy and cost predictability.
Where Things Are Headed
Three developments to watch:
- Issue #21126 resolution. The
--tool-executorproposal is the most important open issue for llama-server's agent future. When it merges, you will be able to wrap tool execution in Firejail, Podman, or Sandboxie without a separate MCP server. That is the day local agents become production-viable.
- Model improvements. Tool-call reliability in small models is still uneven. Qwen 3.x Coder and Llama 3.3 70B are the current leaders. Every model generation improves tool-call formatting accuracy. The gap between "works for demos" and "works for production" is closing.
- Downstream adoption. Ollama, LM Studio, and Jan all bundle llama.cpp. Whether they expose
--toolsin their own interfaces determines whether this feature reaches mainstream users or stays a power-user option. The security implications make this a design decision, not just a UI choice.
The local agent stack was three pieces of infrastructure yesterday. It is one binary today. The security model needs to catch up to the capability. When it does, the practical difference between a local code agent and a cloud code agent will be who holds the weights and where the filesystem lives.
That is a smaller gap than most people think.
Sources:
- PR #20898: server: add built-in tools backend support
- Issue #21126: Feature Request: Optional external tool executor / sandbox wrapper for built-in tools
- Commit b0a1b31: change arg to --tools all
- llama.cpp server README (built-in tools section)
- r/LocalLLaMA discussion thread (May 23, 2026)
- PR #18655: MCP client support (March 2026)