test(harness): regression-guard run_cli parent env propagation#544
Merged
test(harness): regression-guard run_cli parent env propagation#544
Conversation
Adds a small unit test asserting that ``run_cli``:
1. Propagates parent process env to the subprocess (the contract that lets
CLI providers inherit deployment-level vars like OPENCODE_ENABLE_EXA /
EXA_API_KEY)
2. Lets explicit per-call env override parent env on conflict
3. Layers explicit env on top of parent env additively
4. Inherits parent env even when the explicit env arg is None
Motivates why this matters: opencode's built-in websearch / webfetch tools
are gated on env vars (OPENCODE_ENABLE_EXA + EXA_API_KEY). They reach the
opencode subprocess only because run_cli's ``merged_env = {**os.environ}``
preserves parent env. If a refactor ever drops that line, every CLI
provider quietly stops seeing deployment env and tools that depend on
them silently break across every consumer (SWE-AF, PR-AF, github-buddy).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Performance
✓ No regressions detected |
Contributor
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
Contributor
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
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.
Summary
Adds a small unit test asserting that `run_cli` propagates parent process env to subprocesses — the contract that lets CLI-based providers (opencode, codex, gemini) inherit deployment-level env vars like `OPENCODE_ENABLE_EXA` and `EXA_API_KEY`.
Why
Opencode's built-in `websearch` / `webfetch` tools are gated on env vars. Reasoners running through agentfield's harness rely on those vars reaching the opencode subprocess, which works only because `run_cli` does:
```python
merged_env = {**os.environ}
if env:
merged_env.update(env)
```
If a refactor ever drops that `{**os.environ}` line, every CLI provider silently stops seeing parent env and tools that depend on them break across every consumer. This test catches that regression early.
What's tested
Tests are pure — `bash -c "echo $VAR"`, no network, no fixtures. Run in <1s.
🤖 Generated with Claude Code