AI Agent Virtual Computer: Architecture and Integration Practices

    This article explains why AI agents need a controlled virtual computer, how a four-layer architecture separates the model, protocol, execution, and observation layers, and how to integrate an execution environment through a client plugin or MCP. It also covers validation steps, least-privilege security controls, and a phased rollout approach.

    1. Why an Agent Needs a Dedicated Computer

    When a large model only outputs text, humans must relay its actions. The model provides a command, the user copies it into a terminal, and then pastes any error back into the chat window. This is acceptable when a task has only two or three steps. Once the chain grows longer, such as pulling code, installing dependencies, running tests, fixing errors, and submitting results, the number of manual relays increases quickly, and so does the probability of mistakes.

    The solution is to assign the Agent a controlled execution environment. It can be a full virtual desktop or a container sandbox. Three criteria determine whether an environment is suitable for an Agent:

    1. Operable: it can execute commands, read and write files, and start programs.
    2. Observable: the input and output of every step can be returned to the model.
    3. Isolated: all operations are confined to the sandbox and do not affect the host machine or real business data.

    The industry often uses terms such as “Computer Use” or “virtual execution environment” for this type of solution. Whether a graphical interface is needed depends on the task. For command-line-only scenarios, a terminal and file system are sufficient. Screenshots and coordinate-based clicking are needed only when the Agent must click through web pages or operate desktop software.

    2. Four-Layer Architecture: Brain, Protocol, Hands, and Eyes

    A typical execution environment consists of four layers.

    Model layer (brain): understands the task, breaks it into steps, and decides the next action. The model does not access the operating system directly; it only outputs structured action instructions.

    Protocol layer (nerves): the communication standard between the model and the execution environment. Many clients and frameworks now support Model Context Protocol (MCP), which wraps system capabilities as a set of tools. The following is an illustrative tool call; the tool name and parameters depend on the tool list exposed by the server in use:

    1. {
    2. "tool": "execute_command",
    3. "params": {
    4. "command": "ls -la /workspace",
    5. "timeout": 30
    6. }
    7. }

    The value of the protocol layer is decoupling. The same model logic can connect to a local container, a remote virtual machine, or a cloud sandbox by changing only the execution backend.

    Execution layer (hands): the virtual computer that actually runs commands, usually based on a lightweight virtual machine or container with a preinstalled development toolchain and browser. The Agent can execute shell commands, manage processes, read and write files, run builds, and operate a graphical interface through screenshots and coordinate-based clicks. Network access is constrained by firewall policies.

    Observation layer (eyes): returns command output, file contents, screen captures, and other results to the model. The model uses these observations in an “act, observe, act again” loop until the task is complete. This is how ReAct-style Agents operate.

    Understanding these four layers helps with troubleshooting. For example, if an Agent repeatedly executes the same command, the observation layer may not be returning the error message, so the model cannot see the cause of failure.

    3. Two Integration Paths and Validation Steps

    The integration path depends on your use case. A plugin is quick to install, while a general protocol configuration is more flexible.

    Path 1: Install a Client Plugin

    If you use a coding tool that supports plugins, you can search the plugin marketplace for the corresponding execution environment plugin. The specific plugin name and installation entry point depend on the client’s official documentation. This article does not give a name, so readers do not find unrelated plugins with the same name. For tools that support the plugin, this approach requires fewer configuration steps and is suitable for quick trials.

    After installation, use the following three checks. Do not hand the Agent a task just because the installation success message appeared:

    1. Open the client’s tool list and confirm that tools provided by the execution environment are present.
    2. Ask the Agent to run a read-only command, such as pwd or ls, and confirm that the returned path and contents are correct.
    3. Check the plugin logs or settings page to confirm that sandbox mode is enabled.

    Path 2: Integrate via MCP

    Custom Agents, command-line Agents, and teams that need to manage multiple Agents centrally usually choose this path. The following is an illustrative configuration. The package name is a placeholder; replace it with the server package you actually use and pin it to a specific version:

    1. {
    2. "mcpServers": {
    3. "virtual-desktop": {
    4. "command": "npx",
    5. "args": ["-y", "<your-server-package>@<pinned-version>", "--mode=sandbox"],
    6. "env": {
    7. "TIMEOUT": "120",
    8. "ALLOW_NETWORK": "false"
    9. }
    10. }
    11. }
    12. }

    The configuration file location varies by client. See the MCP documentation for the client you use. Before use, prepare the following:

    • Node.js and npm are installed. The version requirements are specified in the server documentation.
    • The runtime can access the package registry, or the package is already cached in an internal mirror.
    • Confirm the parameters supported by the server. --mode=sandbox and ALLOW_NETWORK are illustrative only; check the server documentation for whether they exist.

    After configuration, validate with the same three steps: check the tool list, run a read-only command, and inspect the logs. Teams can put the configuration file under version control, but must avoid committing real secrets. Secrets should be injected through environment variables or a secret management service.

    4. Security Configuration: Least Privilege by Default

    Giving an Agent a real computer also means it may cause real damage. Set up defenses in four areas.

    Sandbox isolation: run the Agent in a container or virtual machine, and do not let it operate the host directly. Directories outside the workspace should be mounted read-only.

    Least privilege: by default, disable high-risk commands such as deleting system directories or changing network configuration. Open only necessary capabilities through an allowlist. List allowlist entries task by task rather than enabling everything at once for convenience.

    Network control: disable outbound network access by default. When access to dependency sources or APIs is required, open only explicit domains. For example, allow only pypi.org and registry.npmjs.org and deny all other addresses. Sensitive internal resources should not be exposed to the sandbox.

    Full audit: record every command, every file change, and every screenshot request in a traceable log. Logs should include the time, task ID, and execution result for later investigation.

    Example network configuration:

    1. network:
    2. default: deny
    3. allow_outbound:
    4. - host: pypi.org
    5. ports: [443]
    6. - host: registry.npmjs.org
    7. ports: [443]

    The fields in the example must be adjusted to the syntax of your firewall or sandbox platform.

    5. Phased Rollout: Permission Matrix and Acceptance Criteria

    Do not give an Agent full permissions from the start. A three-stage plan is recommended, with each stage required to pass acceptance before escalating.

    The plan is organized as a permission matrix covering file permissions, network access, allowed commands, and the criteria for entering the next stage. Do not proceed to a broader stage until the current stage passes acceptance.