Skip to content

The Deska blog

Running AI Agents in WSL: The Best Setup

Learn the optimal way of running AI agents in WSL to build a high performance development environment with seamless local execution and hardware access.

12 min read

Running AI agents in WSL has become a necessity for developers who want the power of a Linux environment while staying within the Windows ecosystem. With the rise of CLI based agents like Claude Code, Codex CLI, and OpenCode, the challenge is no longer just installing them. The real hurdle is creating a cohesive workspace where these agents can interact with your file system, execute commands, and remain visible while you write code.

The Architecture of WSL for AI Workflows

Windows Subsystem for Linux (WSL2) operates as a lightweight utility VM that runs a real Linux kernel. For AI agents, this is significant because many agents rely on specific Unix based tools, compilers, and shells like Zsh or Bash to execute their tasks. When you are running AI agents in WSL, the agent expects a high degree of interoperability with the host.

Performance in WSL2 is generally excellent for CPU bound tasks. However, file system performance can degrade if the agent is trying to index files located on the Windows host /mnt/c/ rather than the native Linux file system. To achieve the best setup, always store your project files within the WSL distribution, usually under /home/username/projects. This ensures the AI agent can read and write files at native speeds without the overhead of the 9P protocol used for cross platform file access.

Essential Components for an Agent Ready Setup

A robust setup requires more than just a terminal. You need a way to manage multiple streams of information. AI agents are chatty and often perform long running tasks.

  1. Node.js and Python Environments: Most modern agents are built on these runtimes. Use nvm or pyenv inside WSL to manage versions rather than installing them globally.
  2. SSH and Git Configuration: Ensure your credentials are authenticated within the WSL environment so the agent can perform commits or fetch dependencies without prompting for UI based login.
  3. Terminal Multiplexing: Tools like Tmux allow you to keep an agent running in one pane while you monitor logs in another.
  4. Visual Context: Agents often need to "see" your code. Standard editors sometimes struggle to sync the exact state of the agent's changes in real time.

Integrating Deska into the WSL Workflow

While standard terminal emulators work, they often lack the spatial organization required for complex AI interactions. Deska provides a canvas based workspace that is particularly effective for managing the chaotic output of multiple AI agents.

By running Deska on your Windows host, you can open multiple terminals that connect directly to your WSL instance. This allows you to place a Claude Code session on one side of the screen and an OpenCode session on the other, while keeping a code editor in the center. Because Deska is local-first, your code and agent sessions remain on your machine, which is a critical security consideration for professional development.

Running Side by Side Agents

One of the strengths of this setup is the ability to use different agents for different tasks. You might use Codex CLI for quick shell commands and Claude Code for complex refactoring. In Deska, you can treat these as separate panels within the same infinite workspace. This eliminates the need to constantly switch tabs or windows.

The Ask Deska assistant can further streamline this by driving the workspace itself. You can use voice or chat to open new WSL terminals or check the status of a long running agent task. This level of orchestration is difficult to achieve with a standard terminal and IDE combination.

Hardware and Resource Management

AI agents can be resource intensive, especially if they are running local inference or indexing large repositories. WSL2 allows you to limit the amount of RAM and CPU cores assigned to the Linux kernel via a .wslconfig file in your Windows user profile.

Consider allocating at least 8GB of RAM to WSL if you plan to run multiple agents concurrently. If you are using agents that support local models, ensure you have the latest NVIDIA drivers on Windows, as WSL2 supports GPU acceleration through CUDA. This allows your coding agents to leverage your hardware for faster response times.

ComponentRecommended ConfigurationPurpose
File SystemNative Linux path (/home/...)Maximum I/O speed for agent indexing
Memory8GB to 16GB allocated in .wslconfigPrevents host slowdown during heavy tasks
ShellZsh with Oh My ZshBetter autocomplete and plugin support
WorkspaceDeska CanvasSpatial management of multiple agent panels

Managing Sessions and Remote Access

A common pain point when running AI agents in WSL is losing context when you step away from your desk. Since these agents are often in the middle of a multi step reasoning process, interrupting them can be counterproductive.

Deska offers a mobile application that connects to your desktop workspace through a secure relay. This allows you to monitor the progress of a Claude Code refactor from your phone or tablet without exposing any ports on your router. The devices pair directly, ensuring that your data and storage remain private. If the agent hits a snag and needs a simple confirmation, you can handle it remotely without returning to your PC.

Common Pitfalls and How to Avoid Them

The most frequent issue developers face is permission errors. When an agent tries to modify a file, it must have the correct Linux permissions. Avoid running agents as sudo unless absolutely necessary, as this can create files that your IDE cannot easily edit later.

Another issue is environment variable synchronization. Agents often require API keys for services like Anthropic or OpenAI. If you are a subscriber to a managed service, this is handled for you, but for a BYOK (Bring Your Own Key) setup, you must ensure these keys are exported in your .bashrc or .zshrc inside WSL.

FAQ

How to use Claude Code in WSL?

To use Claude Code, you need to install the package via npm inside your WSL distribution. Once installed, you can launch it within a terminal panel. For a better experience, use a workspace that allows you to see the terminal and your files simultaneously.

Does WSL2 support GPU for AI agents?

Yes, WSL2 supports GPU paravirtualization. You must install the appropriate drivers on the Windows host. This allows agents that run local models to access your NVIDIA GPU for faster inference without needing a native Linux installation.

How to access WSL files from Windows apps?

You can access your WSL file system through the \\wsl$ network path. However, for development, it is better to use applications that have native WSL integration to avoid performance bottlenecks and file lock issues.

Get Started with a Better WSL Setup

Building a high performance environment for AI agents requires the right mix of OS configuration and workspace management. By combining the power of WSL2 with a flexible, spatial tool like Deska, you can create a workflow that keeps up with the speed of AI development.

Download the app for free at /download and start organizing your agents today.

Running AI Agents in WSL: The Best Setup | Deska