Fully Local AI Agents: Building an On-Premises Agent That Keeps Data Inside
Many companies are hesitant to use cloud-based AI agents—worried about data leaks. By 2026, fully on-premises agent solutions have matured. This post covers how to set one up.
📜 Table of Contents
📖 Keep reading
Fully Local AI Agents: Building an On-Premises Agent That Keeps Data Inside
For finance, healthcare and legal teams, the first obstacle is compliance, not quality: customer records, medical notes and contracts cannot leave the intranet. Local deployment covers most office workflows in 2026; the price is a lower capability ceiling and operational overhead.
The stack
UI Open WebUI or a custom front end
Orchestration LangGraph / LangChain / CrewAI
Inference Ollama (local model, OpenAI-compatible)
Data Chroma / Qdrant + business databases
Tools MCP servers / local functions
Reading documents, retrieving, comparing, drafting reports and calling internal APIs all work. What degrades is frontier-level reasoning; either accept it or isolate that part in a hybrid design.
Step 1: Model choice
Agents need reliable structured tool calls more than prose quality.
- Main model: 14B-32B instruct-tuned, strong Chinese support if your corpus is Chinese; 24GB VRAM runs 32B at 4-bit.
- Small model: 4B-8B for intent routing and argument extraction.
- Serving: Ollama with an OpenAI-compatible endpoint, so orchestration code stays unchanged.
ollama pull qwen3:14b
ollama serve
Bind it to localhost or the internal interface. Never expose 11434 publicly.
Step 2: Orchestration
LangGraph for stateful multi-step flows, LangChain for linear pipelines, CrewAI for role-based tasks. The framework matters less than narrow tools: one job per tool, typed arguments, structured returns.
from langchain_ollama import ChatOllama
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_core.tools import tool
@tool
def search_contracts(keyword: str) -> str:
"""Search the local contract index and return matching clauses."""
return local_index.search(keyword, top_k=5)
llm = ChatOllama(model="qwen3:14b", temperature=0)
agent = create_tool_calling_agent(llm, [search_contracts], prompt)
AgentExecutor(agent=agent, tools=[search_contracts], max_iterations=6).invoke(
{"input": "Find the penalty clauses"})
Always set max_iterations, or a failing tool call loops until the GPU is saturated.
Step 3: Local knowledge base
Chunk by heading, 300-800 characters, keep file name and page as metadata for citations. Embedding must be local too — a cloud embedding call inside retrieval is the most common compliance leak. Use hybrid vector plus keyword recall with a reranker; enterprise corpora are full of part numbers and jargon that pure vectors miss.
Step 4: Tools and permissions
- Whitelist only the tools the workflow needs.
- Validate arguments: restrict paths to one directory, read-only DB accounts for SQL.
- Human confirmation for any write action (submit, send, pay).
- Audit log every tool call with arguments, results and latency.
Privacy tiers
| Tier | Data path | Security | Use |
|---|---|---|---|
| L1 | Local redaction, cloud model | Medium | Non-sensitive, cost-driven |
| L2 | Local model, cloud tools | High | Cloud capability without raw data |
| L3 | Model, data, tools all internal | Highest | Medical, contracts, customer data |
Most enterprises land between L2 and L3.
Performance
The bottleneck is the call chain: intent, tool selection, result reading, re-reasoning — five or six model passes per task, seconds each. Reduce latency with a small routing model, fewer iterations, and fixed flows for common paths.
FAQ
Q: Can local models call tools reliably? 14B and up are stable with well-described tools; small models skip arguments or invent tool names. Keep under ten tools.
Q: Offline plus web search? Not possible. Import corpora manually, or run retrieval in the cloud with redacted queries (L2).
Q: Hardware? 14B 4-bit needs 12-16GB VRAM, 32B needs 24GB. CPU works for 4B-8B but multi-turn agents crawl.
Q: Prove data stays inside. Monitor egress on the agent host, disable telemetry in every component, and run the full flow with the network physically disconnected.
Q: Model updates? Manual pulls plus regression tests. Pin version tags, avoid latest.
Q: Is local automatically private? No. Weights, embedding models, logs and backups can all leak data. The boundary is network isolation and access control.
Interfaces change; check official docs.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.