fix: replace REACH_SESSION in harness environments rather than appending it - #16
Merged
Merged
Conversation
This was referenced Aug 22, 2026
…ing it Every launcher built its child environment as os.Environ() plus "REACH_SESSION=<name>". When the operator's shell already exported REACH_SESSION — the documented way to bind a shell to a session — the child received the key twice, and which of the two a program reads is not defined. The shim would then resolve a different session than the launch had just named on stderr, and the agent's commands would run on that session's target while every message said this one. replaceEnv already existed for exactly this reason and was already used for CODEX_HOME and HOME; it is now used for REACH_SESSION as well, and for CLAUDE_CODE_SHELL_PREFIX, which had the same shape. The harness seam probes had the same bug with worse consequences: they copy the current environment and append the throwaway probe session, so an inherited REACH_SESSION could win and route the probe's canary through the operator's real session. The probe would then report a verdict about a seam it never exercised, which is the one thing a fail-closed guard must never do. baseProbeEnv and claudeCodeEnv now strip an inherited value before setting their own. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WMXbmmHmEkyWWRc72uvPW
bojieli
force-pushed
the
fix-duplicate-reach-session-env
branch
from
August 22, 2026 04:44
376ca98 to
86383b3
Compare
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 this changes
Every harness launcher built its child environment as
os.Environ()plus"REACH_SESSION=<name>". When the operator's shell already exportedREACH_SESSION— the documented way to bind a shell to a session — the child received the key twice, and which of the two a program reads is not defined.The failure that matters: the shim would resolve a different session than the launch had just named on stderr, so the agent's commands would run on that session's target while every message said this one. That is silent wrong-target execution, arrived at through reach's own environment handling.
replaceEnvalready existed for exactly this reason and was already used forCODEX_HOMEandHOME. It is now used forREACH_SESSIONin every launcher, and forCLAUDE_CODE_SHELL_PREFIX, which had the same shape.The harness seam probes had the same bug with worse consequences:
baseProbeEnvandclaudeCodeEnvcopy the current environment and append the throwaway probe session, so an inheritedREACH_SESSIONcould win and route the probe's canary through the operator's real session. The probe would then return a verdict about a seam it never exercised — the one thing a fail-closed guard must never do. Both now strip an inherited value before setting their own.Checklist
make checkandmake lintpassmake integrationpasses, if this touches transports or file operations — not run; this touches neitherIf this touches a harness adapter:
docs/RESEARCH.mdrecords what was observed — no new harness observationVerified by unit tests and
make checkonly: reproducing the duplicate-key path end to end needs a real harness and a target, and was not run here.🤖 Generated with Claude Code
https://claude.ai/code/session_018WMXbmmHmEkyWWRc72uvPW