Simulated user and ACP target agent share environment variables

Open
#4,465 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
devtools, security

Research direction

Start in src/harbor/trial/trial.py, where exec_env merges the user agent, bridge and target environment variables, then read src/harbor/bridges/acp.py to see how the acpx config is written to .acpxrc.json. Done means each agent gets only its own variables and the config moves to ~/.acpx/config.json. This is blocked on openclaw/acpx#1050 being merged and released, and on bumping the pinned acpx version from 0.11.2.

Written by the indexing model from the issue text.

Description

Problem

When a trial runs a simulated user, Harbor's ACP bridge (src/harbor/bridges/acp.py) uses acpx to connect it to the target agent. Environment variables reach the two agents as follows:

  1. Harbor runs the simulated user with a set of environment variables.
  2. The simulated user runs acpx, and acpx runs the target.
  3. Each process inherits its parent's environment variables, so the target gets the simulated user's.

The acpx CLI config has no way to give the target its own environment variables, so Harbor adds the target's variables to the simulated user's in step 1 (src/harbor/trial/trial.py):

exec_env = {
    **self.user_agent.extra_env,
    **self.bridge.env(),
    **self.agent.extra_env_for_bridge(self.config.user_agent.bridge.kind),
}

This happens in shared bridge and trial code, so it affects all ACP targets. Each agent's variables can change how the other runs, in both directions:

  • Target → simulated user. The simulated user runs with the target's variables. When both agents use the same variable name, the target's value replaces the simulated user's. For example, with Claude Code as both the simulated user and the target, the simulated user authenticates with the target's credentials.
  • Simulated user → target. The target inherits the simulated user's variables, including keys, tokens and flags the target was not configured with.

Some targets work around the second direction on their own:

  • Claude Code starts its ACP server with env -u CLAUDECODE.
  • Copilot CLI starts its ACP server through a shell script that unsets every inherited COPILOT_* variable, then loads the target's variables from an env file in a private home directory.

Other targets have no such workaround.

Proposed fix

openclaw/acpx#1050 proposes three optional keys for an agent's entry in the acpx config:

  • envAllow: limit the inherited variables to the listed names.
  • envBlock: drop the listed inherited variables.
  • env: give the agent its own values.

With these keys, the target's variables no longer need to be in the simulated user's environment. Harbor would write them to the target's env in the acpx config instead, and list the simulated user's variable names in envBlock so the target does not inherit them. Each agent would then run with only its own variables, and the target-specific workarounds above would no longer be needed.

The cost is that the acpx config would then contain the target's credentials. Harbor currently writes it to .acpxrc.json in the task workspace, where the credentials could end up in anything committed, diffed or graded. Harbor would want to write it to ~/.acpx/config.json instead.

This does not stop either agent from reading the other's credentials. Both agents run as the same Linux user in the same sandbox, so the simulated user could read ~/.acpx/config.json, and each agent can already read the other's environment variables from its running process. This is an existing limitation that the fix neither causes nor addresses.

Status

I have drafted a change to Harbor that would address this. I haven't yet opened a PR because it is blocked on:

  1. openclaw/acpx#1050 being accepted and merged;
  2. an acpx release that includes it;
  3. bumping Harbor's pinned acpx version (currently 0.11.2).

Related

  • #3626 and #1647 cover a similar problem for sidecar containers: credentials meant for a sidecar service reaching the agent.
Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.