Workspaces
Several coding agents can share one APXY proxy, each in its own git worktree. Each worktree is a workspace. All workspaces share one proxy, one web UI, and one traffic database. APXY keeps their evidence and their rules apart, so an agent never passes a check on another agent’s request or gets an answer from another agent’s mock. The agents configure nothing.
How APXY finds the workspace
A command runs in the first workspace that applies:
- The value of
APXY_WORKSPACE, when it is set. - The git worktree of the current directory, from
git rev-parse --show-toplevel. WhenCONDUCTOR_WORKSPACE_NAMEis also set, it names the workspace. - The value of
CONDUCTOR_WORKSPACE_NAME, outside a git worktree.
The workspace ID is ws- and the first 12 hex characters of the SHA-256 of the worktree path. The workspace name is the directory name and 4 hex characters of the ID, such as checkout-a1b2. Commands that take a workspace accept the ID or the name.
apxy status prints the workspace that a command runs in. Every agent JSON envelope (--output agent) has a workspace field.
A command outside any workspace runs as APXY did before workspaces. It reads the traffic of every workspace and uses the global rules.
What each workspace keeps apart
| Item | Location | Scope |
|---|---|---|
| Proxy and web UI | One per machine | Shared by every workspace |
| Traffic | ~/.apxy/data/apxy.db | One database. Each record carries the workspace of the client that sent it, or no workspace. |
| Marks | ~/.apxy/data/apxy.db | One set per workspace. apxy mark in one worktree never moves the default mark of another. |
| Workspace rules | <worktree>/.apxy/rules.json | Requests tagged with this workspace |
| Global rules | ~/.apxy/rules.json | Untagged requests, and every workspace after its own rules |
Rules are mocks, rewrites, filters, scripts, breakpoints, SSL domains, DNS overrides, network conditions, and caching overrides.
How a request gets its workspace
apxy run sets HTTP_PROXY and HTTPS_PROXY to http://<workspace-id>:x@127.0.0.1:<port> and sets APXY_WORKSPACE to the workspace ID. Most HTTP clients send that username to the proxy. The proxy reads it once per connection and tags every request on the connection with it. That includes CONNECT tunnels, decrypted HTTPS, and plain HTTP inside a CONNECT tunnel, such as Node fetch to port 80.
The username is a tag, not a login. The proxy never answers 407, and it removes the Proxy-Authorization header before it forwards the request.
These requests carry no workspace:
- Java clients that get the proxy through
JAVA_TOOL_OPTIONS. Java ignores the username. - Safari and Firefox, which use the system proxy.
- iOS simulators, which use the macOS system proxy.
- Android emulators that
apxy device setuppoints at the plain proxy port, because it ran outside any workspace or before a proxy ran. - Webhooks and any other client that connects to the proxy without the username.
Prove a change from a worktree
Run the loop from inside the worktree:
cd ~/src/my-app-checkout
apxy mark
apxy run -- npm test -- checkout.spec.ts
apxy wait --match "POST /api/checkout" --expect "status == 200"apxy wait, apxy logs list, apxy logs search, and apxy logs egress see the requests of this workspace and untagged requests. The same request from another worktree never matches. An untagged request can match. When it matches while other workspaces are active, apxy wait adds a warning, because the request can come from another agent.
To read the traffic of another workspace, pass --from-workspace with its ID or name. You see its requests and untagged requests. For example, check the requests that another agent’s web app sent to your backend:
apxy wait --from-workspace web-7c2e --match "GET /api/profile" --expect "status == 200"To read every workspace, pass --all-workspaces.
Rules for one workspace
A rule command run in a worktree, from the CLI or from MCP, writes <worktree>/.apxy/rules.json. A tagged request gets its workspace rules first, then the global rules. An untagged request gets the global rules only.
apxy mock add --name checkout-down --url "https://api.myapp.com/api/checkout" --method POST --status 503
apxy rules listapxy rules list shows every rule that applies to this workspace, the file that holds it, and whether the running proxy applies that file now. apxy rules clear deletes the rules of this workspace. No command clears the rules of other workspaces.
apxy run and apxy mcp push the workspace rules file and the global rules file to the proxy. They push again within a second after a file changes, by hand or by git checkout, and after the proxy restarts. After you edit the file by hand with neither running, run apxy rules apply to push it now. APXY never pushes an invalid file. The proxy keeps the last valid rules, and the error names the file and the line and column or the rule, such as mock_rules[2].
apxy init adds .apxy/rules.json to .apxy/.gitignore, because mock bodies can hold tokens. To share the rules of a worktree through git, run apxy init --commit-rules.
A workspace that APXY_WORKSPACE or CONDUCTOR_WORKSPACE_NAME names outside a git worktree keeps its rules in ~/.apxy/workspaces/<workspace-id>/rules.json. Outside any workspace, rules are global.
Global rules
Add --global to write ~/.apxy/rules.json instead. Global rules answer untagged traffic, and every workspace after its own rules. Use them for traffic that carries no workspace: browsers on the system proxy, iOS simulators, Android emulators set up outside a workspace or with no proxy running, webhooks, and Java clients.
apxy mock add --global --name sim-config --url "https://api.myapp.com/config" --status 200 --body '{"flag":true}'
apxy rules list
apxy rules clear --globalThe web UI creates and edits global rules only.
A check that passed on a mock
When a mock answered the request that apxy wait matched, the result has mocked_by with the id, name, and source of the mock rule. It also has a warning that starts with passed on a mocked response. The pass proves that your code handled the mock. It does not prove that the real API works. If the check must reach the real API, remove the mock with apxy mock remove --id <id>, adding --global for a global rule, and run the loop again.
Who stops the shared proxy
apxy stop and the stop_proxy MCP tool stop a proxy only when both of these are true:
- This workspace started it, with
apxy run,apxy browser,start_proxy, orapxy startfrom a script. - No
apxy run,apxy browser, or MCP session in another workspace still uses it.
Otherwise the command fails with the error code stop_refused, and the message says who started the proxy. A proxy that a person started with apxy start at a terminal is never stopped this way. That person stops it with Ctrl+C in its terminal.
apxy status shows who started the running proxy in owner:
owner | Started by |
|---|---|
user | A person, with apxy start at a terminal |
start:<workspace-id> | apxy start from a script or an agent’s shell |
run:<workspace-id> | apxy run |
browser:<workspace-id> | apxy browser |
mcp:<workspace-id> | The start_proxy MCP tool |
apxy stop --force stops the proxy whoever started it. It is for people. An agent never passes it, because it cuts off the other agents.
The temporary proxy of apxy run stops a few seconds after the last apxy run that uses it exits. Captured traffic outlives the proxy. See Logs.
The Free plan limit of 10 minutes applies to each proxy session, as before.
Web apps in a browser
apxy browser http://localhost:3000For Chrome, Edge, Brave, and Arc, apxy browser starts a temporary proxy when none runs. It holds a lease on the proxy while the browser runs, so the proxy stays up after other agents finish. In a workspace, the browser gets its own profile, ~/.apxy/<browser>-profile-<workspace-id>, and a proxy port of its own that tags every request with the workspace. Chromium refuses a username in a proxy URL, so the tag cannot ride in the URL as it does for apxy run. The mocks of the workspace answer the browser. The port is the same for a workspace every time: the proxy picks it from the workspace ID within apxy start --workspace-ports (default 20000-29999), and takes a random one only when another program holds it. A proxy that restarts reopens the port while the browser runs, so an open browser keeps working.
Safari and Firefox use the system proxy. Their requests are untagged, so only global rules apply to them. See Browser Integration.
Simulators and emulators
apxy device list
apxy device setup --ios-simulator booted
apxy device setup --android-emulator booted
apxy device teardown --android-emulator booted- For an iOS simulator,
apxy device setupinstalls the APXY CA withxcrun simctl. The simulator sends its traffic through the macOS system proxy, which a person turns on withapxy start. - For an Android emulator,
apxy device setupcopies the CA to the emulator and points its HTTP proxy at the host,10.0.2.2. In a workspace with a proxy running, that is the workspace’s own port, which tags the traffic, so the mocks of the workspace answer it. Setup holds the port for 8 hours, and running it again holds it longer.apxy device teardownclears the proxy and releases the port. - Outside any workspace, or with no proxy running, the emulator gets the plain proxy port and its traffic is untagged. The output’s
untagged_becausesays why. Run setup again once a proxy runs to tag it. - iOS simulator traffic is untagged, so mocks for it need
--global.
See Mobile Setup.
Watch every agent in the web UI
apxy run starts its temporary proxy without a web UI. To watch the agents, run apxy ui:
apxy uiapxy ui serves the web UI at http://127.0.0.1:8082 with no proxy running. It reads the shared database and every rules file. Once a workspace exists, the top bar has a workspace picker with All workspaces, each workspace, and Untagged. A workspace shows its own requests and untagged requests, as its agent sees them. See Web UI.
Name your workspace
The web UI shows each workspace by its label, else its git branch, else its name. The branch shows on its own. To say what an agent is doing, label its workspace from the worktree:
apxy workspace label "Fix checkout retries"
apxy workspace showA label is one line of at most 80 characters. apxy workspace label --clear removes it. APXY_WORKSPACE_LABEL sets it too, and the MCP tool is set_workspace_label. See apxy workspace.
Subagents and MCP
The MCP server runs in the workspace of the directory it started in, usually the main checkout. A subagent in another worktree uses one of these:
- The CLI, run from inside its own worktree.
- The
workspaceargument of the MCP tools, with the absolute path of its worktree, its workspace ID, or its name.
{"match": "POST /api/checkout", "expect": ["status == 200"], "workspace": "/Users/me/src/my-app-checkout"}set_mark, wait_for_request, list_traffic_logs, search_traffic_logs, and every rule tool take workspace. The rule tools also take global: true. See MCP Tools.
Limits
- Java clients send untagged requests, because Java ignores the username in the proxy URL.
- Browsers on the system proxy, iOS simulators, and Android emulators set up outside a workspace or with no proxy running send untagged requests. Mocks for them need
--global, and those mocks also answer the other workspaces. - An untagged request can match
apxy waitin any workspace. Check the warning before you trust the match.