How to Run a Coding Assistant On Premises Without Code Leaving
Build an on-prem coding assistant in five layers: host the model, agent and gateway inside your network, block egress, and prove with packet capture.
For Engineering, Security and IT

How do I run a coding assistant on premises so source code never leaves the network?
Host every component that touches your code inside your network: the model, the agent that plans each step, the gateway that controls access, and the code and documentation the agent reads. Then block outbound traffic from those machines and prove it with a packet capture. Installing a local model is only the first step. The network boundary is what makes the "never leaves" claim true, and a capture of your own traffic is what lets you show it to a security team.
TL;DR
- A self-hosted coding assistant has five layers (agent, model, gateway, code context, documentation context), and each can sit in a different place.
- Running the model locally is not enough. If the agent loop runs in a vendor's cloud, your code reaches that cloud anyway.
- Put the model and agent on a dedicated internal subnet with a default-deny outbound rule, then allow only what you name.
- Use one internal gateway so developers hit a single endpoint you can authenticate, log and limit.
- Documentation lookups, license checks, update checks and telemetry are quiet sources of egress. Hunt for them on purpose.
- Finish with a packet capture during real work. Zero packets to non-internal addresses is your proof.
What does "on-premises" actually mean for a coding assistant?
Vendors use "private", "secure" and "on-prem" loosely. Some tools run the model in your network but still check a license online. Others run tools on your machine while the agent itself lives in the vendor's cloud. Ask which of four levels each component is at:
| Level | Where it runs | Who can reach it |
|---|---|---|
| SaaS | The vendor's cloud | The vendor runs and updates it |
| VPC | Your cloud account (AWS, GCP, Azure) | Only your team |
| On-prem | Your own servers, inside your network | Only your team |
| Air-gapped | A network with no internet connection | Only your team, with files moved across by hand |
Tabnine's documentation, for example, lists SaaS, VPC, on-prem on Kubernetes and fully air-gapped options. That is a useful model for what to ask any vendor. Your security rule ("no source code or prompts leave the network") only holds if every layer meets it.
What are the five layers you need to host?
- The assistant and agent loop. The editor or terminal tool, plus the loop that takes a task, plans, and decides which tool to call.
- The model. The system that actually writes code.
- The gateway. The control point deciding which models and tools each person can use.
- Git and code context. The repositories the agent can read.
- Documentation context. The library and internal docs the agent can look up.
Most "run it locally" guides stop at layer 2. A leak at any layer defeats the whole setup.
How do I host the model inside the network?
Pick an inference server and run it on a machine inside your network. For a single developer, Ollama or LM Studio is the usual route. Popular coding models in current guides include Qwen 2.5 Coder and Qwen3 Coder. For a team, run a shared inference server (vLLM and llama.cpp's server are common choices) on a GPU host rather than on every laptop.
A few rules make this hold up:
- Download weights once, then freeze. Pull the model on a staging machine, check it, and move it to the production host. In an air-gapped setup, you carry the files across by hand.
- Bind to an internal address only. Do not listen on all interfaces. Ollama's default port is 11434. Make sure only your internal subnet can reach it.
- Check hardware against the model you pick. I won't quote memory figures here, because they vary with model size and quantization. Read the model card for the exact build you choose.
Where should the agent loop run?
This is the question that catches teams out. The agent loop is the part that decides what to do next. If it runs in the vendor's cloud, each step needs context sent there.
Cursor's self-hosted agents show the pattern. The agent loop and the planning run in Cursor's cloud. A worker on your machine performs file edits and commands and hosts local MCP servers. The worker sends what each step needs back to Cursor: file contents, terminal output, diffs. Your full checkout stays on your machine, but pieces of it travel. That may be fine for some teams, but it is not "never leaves the network".
For a strict boundary, choose an agent whose loop runs on your side:
- Claude Code or Codex pointed at a local endpoint. Popular guides do this with Ollama or LM Studio, replacing the vendor's servers with your own address.
- OpenCode, an open-source coding agent described as running locally with zero telemetry and supporting many model providers through Ollama. Treat "zero telemetry" as a claim to test, not a fact (more on that below).
- Vendor products with a true on-prem or air-gapped tier. Ask for the architecture document and read what each component calls.
Why do I need a gateway?
Without a gateway, every developer configures their own endpoint, and you cannot see or control anything. A gateway is one internal service that sits between the agent and the models. Open-source options such as LiteLLM exist for this, or you can use the one your vendor ships.
Give it these jobs:
- Authenticate each user or service.
- Allowlist models. Only the models you host can be called. A misconfigured client cannot quietly route to a public API.
- Log requests inside your network, so you have an audit trail.
- Be the only route. Developers' machines should reach the model host only through the gateway.
The gateway also gives you a single place to enforce "no external provider URLs", which makes the egress rules later much simpler.
How do I keep code and documentation context inside too?
Code context is usually easy: your Git server already lives inside the network. Point the agent at it and confirm the agent never clones from or pushes to a public host.
Documentation is the layer people forget. Many assistants fetch library docs from the internet when they need an answer. That is a request leaving your network, and the query itself can reveal what you are building. Options:
- Mirror the docs you need on an internal server and point the agent at it.
- Use an internal documentation index for your own wikis and API specs.
- Turn off web lookup in the agent's configuration, then confirm in the capture that it stays off.
How do I block outbound traffic?
Put the model host, gateway and developer agents on a segment with default-deny outbound. Then add allow rules only for named internal destinations.
- Block at the network firewall, not just on the host. A host setting can be changed. A firewall rule on the segment is harder to bypass.
- Handle DNS deliberately. Point machines at an internal resolver that answers only internal names. Public name lookups can themselves leak information.
- Contain the runtime. For the strictest case, run the agent in a container with networking disabled at the operating system level. SITU Agent, for example, is described as running in an isolated container with network access off.
- Don't forget the editor. Extensions check for updates, sync settings and report usage. Disable or mirror those.
Run this once the rules are in place. Anything that breaks tells you about a dependency you did not know you had.
How do I prove no code leaves the network?
Do not rely on a vendor's privacy page. Capture the traffic yourself.
Step 1. Plant a canary. Add a unique string, such as CANARY-7f3a91, in a comment in a test repository.
Step 2. Start a capture on the developer machine or the segment's gateway, recording anything not headed to private address ranges:
sudo tcpdump -i any -nn -w agent-session.pcap \
'not (dst net 10.0.0.0/8 or dst net 172.16.0.0/12 or dst net 192.168.0.0/16)'
Step 3. Work normally for a realistic session. Open the repo, ask for a refactor, run tests, request a doc lookup, restart the editor.
Step 4. Read the result:
tcpdump -nn -r agent-session.pcap | head
If your egress block works, the file should be empty or contain only blocked attempts. Any destination that appears is a finding. Look up what it is, and fix it.
Step 5. Check live connections too:
ss -tnp state established
Note that traffic to an outside host will be encrypted, so searching the capture for your canary string proves little. The stronger proof is that no packets reached a non-internal address at all. Keep the capture and the firewall config as evidence. Repeat after every agent or extension update, because updates change behavior.
What this means for you
- If you are a developer who wants an AI assistant at work: bring the layer table to your security team. It turns "can we use AI?" into specific questions they can answer.
- If you are a security or IT lead: make the packet capture part of your approval process. It takes an afternoon and gives you evidence instead of a vendor's promise.
- If you are a manager: expect a trade-off. Hosting your own model costs hardware and upkeep, and local models may be less capable than the biggest cloud models. Pilot with one team first.
- If you work in a regulated field: write down which of the four levels each layer sits at. Auditors tend to ask exactly that.
Is there a simple way to track this review?
Whatever you pick, the checklist needs a home: which layer each tool covers, who approved it, when the last capture ran, and what the firewall allowed. That is a small internal tool, and it is the kind of thing Remy can build from a plain-English description, for example an approval tracker with a form, a status per layer and a reminder to re-run the capture after updates. Remy apps run on its hosting, so keep source code out of it and record only the checklist and results.
Frequently Asked Questions
Is running Ollama on my laptop enough to keep code private?
Not by itself. Ollama handles the model, but the agent, the editor extension, documentation lookups and update checks can all still make outside connections. Block outbound traffic and capture packets to confirm.
Can I use Claude Code with a local model?
Popular guides describe pointing Claude Code at a local endpoint served by Ollama or LM Studio instead of Anthropic's servers. Check the tool's own documentation for the exact settings, and verify with a capture that nothing else is called.
What is the difference between on-prem and air-gapped?
On-prem means your own servers inside your network, which may still have some internet access. Air-gapped means the network has no internet connection, and files move across by hand. Air-gapped is stricter and harder to maintain.
Do open-source agents guarantee no telemetry?
No. Some, such as OpenCode, are described as having zero telemetry, but a description is not proof. Treat it as a claim, block outbound traffic, and check the capture.
How we source, write, and correct our articles. Editorial standards
Related articles

Should Companies Run Open-Weight Models to Protect Their Data?

What Is Microsoft Aion 1.0 Instruct and How Do You Run It?

Is OpenBot Safe? What Full Access Means and How to Limit It
