Dev.to AI 🤖 Ai 👁 0 📖 3 min read

Running several AI coding agents on one machine without them stepping on each other

If you use more than one AI coding tool, you have probably hit this: you open a second agent session, and something from the first one leaks into it. A different config, the wrong proxy, a stale login, a time zone that d

If you use more than one AI coding tool, you have probably hit this: you open a second agent session, and something from the first one leaks into it. A different config, the wrong proxy, a stale login, a time zone that doesn't match anything.

None of these are exotic bugs. They happen because most tools quietly share global state with every other process on your machine. Here is what I learned while building a desktop workbench for this problem.

Where the shared state hides

When two agent sessions run side by side, they usually share more than you expect:

  • Config and credentials directory. Both read and write the same ~/.config/... or ~/.tool/ folder.
  • Environment variables. HTTPS_PROXY, TZ, locale settings, and API base URLs are inherited from whatever shell launched the tool.
  • System proxy settings. One tool's proxy change affects every app on the machine.
  • Working directory and caches. Session A's cached context shows up in session B.

The symptom is always "it worked yesterday". The cause is always "another session changed something".

Principle 1: give each session its own environment

The simplest fix is to stop inheriting. Start each session as a child process with an explicit, minimal environment instead of passing along your whole shell:

import { spawn } from "node:child_process";

// Illustrative sketch only: a per-session environment, built from scratch.
function startSession(id: string, cmd: string, args: string[]) {
  const home = `/var/sessions/${id}`; // private config and cache root
  return spawn(cmd, args, {
    cwd: home,
    env: {
      PATH: process.env.PATH,
      HOME: home,
      XDG_CONFIG_HOME: `${home}/config`,
      XDG_CACHE_HOME: `${home}/cache`,
      TZ: "UTC", // set deliberately, don't inherit
    },
  });
}

Two sessions can now never overwrite each other's config, because they never see the same directory.

Principle 2: scope the network setting to the process, not the machine

Changing the system proxy is the blunt option. It affects your browser, your package manager, your video call, everything. A cleaner approach is to route only the traffic your tool generates, and leave everything else alone:

  • Don't touch system proxy settings.
  • Don't install a virtual network adapter.
  • Send only the AI requests through the chosen route, and let local or domestic traffic connect directly.

The side effect is that nothing else on the machine behaves differently after you install or uninstall the tool.

Principle 3: make the environment self-consistent

A surprising number of problems come from small inconsistencies: the machine says one time zone, the network exit says another, and the locale says a third. Services that look at these signals can behave in confusing ways, and so can your own debugging.

We settled on one rule: the session's time zone follows the network exit region, and the exit stays fixed for the lifetime of the session. That way the exit address and region don't drift between requests, and when something does go wrong, you have far fewer variables to rule out.

Principle 4: keep credentials where they belong

Signing in with your own official accounts is fine, but the login should stay on your own computer. The workbench shouldn't need to hold your session tokens on its servers to function.

What this looks like in practice

  • Several agent sessions open at once, each with its own config, cache, and environment
  • One consistent exit per session, with the time zone following it
  • No system-wide changes to undo later

Takeaways

  1. Treat each agent session like a small container. Don't inherit what you don't need.
  2. Prefer per-process network settings over system-wide ones.
  3. Make time zone, locale, and network exit agree with each other.
  4. If something "worked yesterday", diff the environment first.

Disclosure: I work on AnBoWork, a desktop AI workbench built around these ideas (independent sessions, a consistent network exit, and signing in with your own accounts). The snippet above is a simplified illustration, not our production code. Happy to answer questions in the comments.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.