Live Nov 18 · Cohort 3Nov 18, 19:00 MSK — free hands-on AI agents live workshop · Live Cohort 3 starts Nov 23Join Nov 18 Live →Cohort 3 (Nov 23)
InfrastructureInsight · On RadarHabr AI→ original

How to Run an AI Agent in a VM While Keeping the Model on the Host GPU: A Setup with Strata

An autonomous agent with terminal access is an intern with admin rights on your main system. The author of this setup separates the model from execution: inference runs on the host through Strata, while VS Code with the Cline plugin runs in a NAT-mode virtual machine. The model's port is forwarded with netsh, and all outbound VM traffic goes to a SOCKS proxy through Proxifier. If a stealer is hiding in someone else's code, you roll back a snapshot in five seconds. The GPU stays on the host, so you don't need to pass it through to the VM. The Proxifier rule for port 47831 goes above all the others, set to Direct. Shared folders and the shared clipboard are disabled in the VM.

AI-processed from Habr AI; edited by Hamidun News
How to Run an AI Agent in a VM While Keeping the Model on the Host GPU: A Setup with Strata
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Key metric #1The GPU stays on the host and does not need to be passed through to the VM
Key metric #2The Proxifier rule for port 47831 is placed above the others, as Direct
Key metric #3Shared folders and the shared clipboard are disabled in the VM

An agent that installs packages, runs scripts and edits files on its own saves hours. But in effect you are giving an intern admin rights on your own laptop. One hallucination in a cleanup script, or one postinstall hook in an unfamiliar repository, and you will feel the consequences on your main system.

The obvious answer is a virtual machine. The problem is that you usually can't pass a GPU through to it, and a local model without a graphics card runs painfully slowly. A Habr write-up proposes separating the "brain" from the "hands."

How the setup works

There are three components.

The host handles inference. It runs the Strata desktop app, which exposes an OpenAI-compatible API (the default port is 47831). Untrusted code never reaches or runs on this machine.

The virtual machine in NAT mode is the sandbox. It holds VS Code and the Cline plugin, and it's where archives get unpacked, dependencies get installed and questionable scripts get run. If something goes wrong, the VM rolls back from a snapshot in about five seconds.

The network gateway forces all of the hypervisor's traffic on the host into a SOCKS proxy through Proxifier. If the code under inspection contains telemetry or a reverse connection, only the proxy's IP leaves the machine, not your home network's.

A simple example: you want to quickly examine an unknown repository from GitHub. You clone it into the VM and ask the agent to build the project and run the tests. The model does its thinking on the host's GPU, while everything is executed inside the sandbox.

Where it breaks

The most interesting part here is not the idea itself but two network traps.

First: local model servers (Strata, Ollama, LM Studio) listen only on 127.0.0.1 by default. The VM can't see them, even through the 10.0.2.2 gateway. The author solves this with Windows' built-in portproxy. A single netsh interface portproxy command forwards the port, and a firewall rule opens it. The check is simple: curl.exe 10.0.2.2:47831/v1/models run from inside the VM should return JSON with a list of models. The exact id field from that response is what you will need in Cline.

The second trap is not obvious. When the VM connects to 10.0.2.2, the packet ends up handled by the system process svchost.exe. Proxifier intercepts it and tries to send it to a local address through the remote SOCKS server. The connection hangs. The fix is an exception rule: applications — Any (precisely because the traffic goes through svchost), hosts — 10.0.2.2, 127.0.0.1, localhost and local subnets, port — 47831, action — Direct. The rule must sit above the general rule for the hypervisor. Because the port is fixed, the VM's remaining internet traffic still goes only through the proxy.

In Cline, the settings are as follows: provider OpenAI Compatible, Base URL 10.0.2.2:47831/v1, key — any non-empty word, Model ID — the name from the server's response. It makes sense to disable separate models for Plan and Act modes so you don't duplicate the config.

What to consider in practice

The isolation depends on discipline. Shared folders and the two-way clipboard are disabled in the VM, otherwise the sandbox loses its point. Never log in to personal accounts or keep real keys and tokens there: Auto-approve in Cline lets the agent do everything that is available inside the machine.

There is also a weak spot that the article doesn't cover. The portproxy command uses listenaddress=0.0.0.0, which means the port listens on all of the host's interfaces, and the firewall rule in the example does not restrict the source. If you are on a shared Wi-Fi network, it makes sense to narrow the rule to the VM's subnet with the remoteip parameter, or to bind listenaddress to the virtual adapter's address. This is our conclusion, not the author's recommendation. In addition, a VM does not offer an absolute guarantee: a hypervisor escape is rare but possible, and you will have to keep refreshing the snapshot.

The takeaway for developers: you don't need a "smart" agent, you need an agent in a cage. The setup comes together in an evening on free software and suits auditing someone else's code, examining suspicious packages and experimenting with autonomous mode. Export your Proxifier profile, and take a clean snapshot right after you verify the external IP.

Story

Key Questions Answered

How the setup works?

There are three components. The host handles inference. It runs the Strata desktop app, which exposes an OpenAI-compatible API (the default port is 47831). Untrusted code never reaches or runs on this machine. The virtual machine in NAT mode is the sandbox. It holds VS Code and the Cline plugin, and it's where archives get unpacked, dependencies get installed and questionable scripts get run. If something goes wrong, the VM rolls back from a snapshot in about five seconds.

Where it breaks?

The most interesting part here is not the idea itself but two network traps. First: local model servers (Strata, Ollama, LM Studio) listen only on 127.0.0.1 by default. The VM can't see them, even through the 10.0.2.2 gateway. The author solves this with Windows' built-in portproxy. A single netsh interface portproxy command forwards the port, and a firewall rule opens it. The check is simple: curl.exe 10.0.2.2:47831/v1/models run from inside the VM should return JSON with a list of models.

What to consider in practice?

The isolation depends on discipline. Shared folders and the two-way clipboard are disabled in the VM, otherwise the sandbox loses its point. Never log in to personal accounts or keep real keys and tokens there: Auto-approve in Cline lets the agent do everything that is available inside the machine. There is also a weak spot that the article doesn't cover.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…