fix(terminal): stop leaking provider env to local subprocesses#1004
Open
PeterFile wants to merge 2 commits intoNousResearch:mainfrom
Open
fix(terminal): stop leaking provider env to local subprocesses#1004PeterFile wants to merge 2 commits intoNousResearch:mainfrom
PeterFile wants to merge 2 commits intoNousResearch:mainfrom
Conversation
Keep the normal shell environment for local terminal commands and background processes, but stop inheriting Hermes runtime provider credentials by default. This prevents OPENAI_BASE_URL and related provider settings from leaking into unrelated CLIs such as Codex while still allowing explicit env overrides when a caller opts in. Refs: NousResearch#1002
Drop the AGENTS.md update from this bugfix branch so the PR stays focused on the terminal environment scoping fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR fixes terminal subprocess environment leakage for local execution.
Hermes currently loads provider credentials and endpoint overrides from
~/.hermes/.envinto the parent process environment. Local terminalsubprocesses and local background processes then inherit that full
environment by default. As a result, unrelated external CLIs such as
Codex can be silently pointed at Hermes' custom provider endpoint.
This change adds a shared subprocess environment helper and uses it in
the local terminal execution paths so Hermes runtime provider variables
are removed before spawning child processes.
Updated code paths:
tools/environments/base.pytools/environments/local.pytools/process_registry.pyBehavior after this change:
env vars by default
by default
when they intentionally need those variables
Why
This keeps the normal shell environment intact while preventing Hermes'
provider credentials and endpoint overrides from leaking across tool
boundaries into unrelated subprocesses.
It is a focused bug fix with a small surface area and avoids changing
provider resolution, config format, or terminal interfaces.
How to test
Set a custom endpoint in
~/.hermes/.env:Run Hermes with the local terminal backend.
From Hermes, run a child process that prints the variable:
python -c 'import os; print(os.getenv("OPENAI_BASE_URL", ""))'Confirm the child process prints an empty string by default.
Confirm explicit env injection still works for local subprocesses when
intentionally provided by the caller.
Run the targeted regression tests:
Platforms tested
Related issues
Fixes #1002