fix(code): scope project dotenv to workspaces - #5980
fix(code): scope project dotenv to workspaces#5980Mason Daugherty (mdrxy) wants to merge 3 commits into
Conversation
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
| with use_environment(workspace_env): | ||
| return await _make_graphs_in_environment( | ||
| config=config, | ||
| project_context_override=project_context_override, | ||
| workspace_env=workspace_env, | ||
| workspace_credentials=workspace_credentials, | ||
| ) |
There was a problem hiding this comment.
🟠 Workspace tracing client remains process-global
Building workspace A and then workspace B does not keep their LangSmith credentials isolated. This context only scopes active_environment() while _make_graphs_in_environment() runs, but that function calls configure_langsmith_secret_redaction(), which installs langsmith.configure(client=Client(...)) process-wide. The second workspace therefore replaces the client used by the first runtime; later traces from A can be uploaded with B's API key/endpoint (and a workspace with tracing disabled also leaves the previous configured client intact). The tracing client/configuration needs to be bound per runtime/invocation rather than published globally during each workspace build.
(Refers to lines 277-283)
Your feedback helps Open SWE learn. React with 👍 or 👎 to tell us if this review comment was useful.
The dotenv workspace-scoping change moved the reviewed process-directory reads: `Path.cwd()` moved from `_preview_dotenv_environ` into `_dotenv_environment`, and `find_project_root` moved from `Credentials.from_environment` into `Credentials.snapshot_from_environment`. Update the `check_process_cwd` allowlist to match the actual call sites so `make lint` passes again.
Each validated conversation workspace now keeps its own project
.envvalues without changing the server process environment.The server can host conversations from different workspaces at the same time. Process-wide dotenv reloads could expose one workspace's model settings, credentials, tracing settings, or tool configuration to another workspace.
This change builds one immutable environment snapshot for each validated workspace. It applies launch environment values first, then the nearest project
.env, then the global profile.env. Existing denied-key checks still apply.Runtime construction and supported lazy model paths use that snapshot. Local shell execution receives a frozen copy with environment inheritance disabled. Web search receives a workspace-bound Tavily client. Stored model credentials remain paired with their stored endpoint without writing to
os.environ.The implementation keeps the existing serialized dotenv reload for the single-workspace client. It does not use process-wide reloads in the multi-workspace server because runtime builds and offload work can overlap. It also does not reject later workspaces, because the server is designed to host them concurrently.
Arbitrary third-party code that reads
os.environduring invocation is not isolated by this change. Supported internal consumers keep the workspace snapshot explicitly.Made by Open SWE
References