feat(agent): three-axis env inheritance via [agent.clear_env]#722
feat(agent): three-axis env inheritance via [agent.clear_env]#722dogzzdogzz wants to merge 4 commits intoopenabdev:mainfrom
Conversation
Replaces the flat [agent].inherit_env allow-list with a structured
[agent.clear_env] table that supports both allow-list and deny-list
filtering plus an enabled toggle.
Decision tree:
if enabled (default true):
if allow_list non-empty -> only those keys pass through
elif deny_list non-empty -> all process env passes EXCEPT deny_list
else -> nothing inherited (pure secure default)
else:
full process env inherited; both lists ignored (escape hatch)
Use case: AWS-IRSA / web-identity workloads where k8s auto-injects many
AWS_* env vars. Listing every benign one in an allow-list is brittle;
deny_list = ["DISCORD_BOT_TOKEN", ...] is a much better fit.
Helm values structure:
agents.<name>.clearEnv:
enabled: true
allowList: []
denyList: []
BREAKING CHANGE (beta): agents.<name>.inheritEnv is removed. Migration:
inheritEnv: ["A", "B"] -> clearEnv.allowList: ["A", "B"]
The helm template hard-fails with a migration message if the legacy key
is encountered. TOML config users: rename `inherit_env = [...]` to
`[agent.clear_env]\nallow_list = [...]`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
config-reference.md: replace inherit_env row with clear_env table + sub-table for enabled/allow_list/deny_list; add decision tree, baseline note, and AWS-IRSA use case example. AGENTS.md: update arch-tree comment from "env_clear whitelist" to "[agent.clear_env] policy"; expand Security section with the decision tree and guidance on when to reach for allow_list vs deny_list. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Make it explicit that HOME/PATH/USER (Unix) and USERPROFILE/USERNAME/ PATH/SystemRoot/SystemDrive (Windows) are always added unconditionally, so: - allow_list = ["FOO"] does NOT mean "only FOO" — the agent still receives the baseline + [agent].env + FOO. - deny_list = ["PATH"] does NOT remove PATH — baseline keys cannot be denied. Adds the clarification to the config-reference.md table rows for allow_list and deny_list, plus the matching ClearEnvConfig field docstrings in src/config.rs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the three-knob clearEnv block to each commented-out agent example (claude, opencode, cursor) so operators discover it via `helm show values` rather than only reading templates/configmap.yaml. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
OpenAB PR ScreeningThis is auto-generated by the OpenAB project-screening flow for context collection and reviewer handoff.
Screening report## IntentPR #722 is trying to replace OpenAB’s current flat agent environment allow-list with a more expressive environment inheritance policy. The operator-visible problem is that FeatFeature, with a beta breaking config change. The PR introduces
It also keeps Who It ServesPrimary beneficiaries: deployers and agent runtime operators. Secondary beneficiaries: maintainers and reviewers, because the new model makes environment propagation behavior explicit and testable instead of relying on one overloaded allow-list. Rewritten PromptImplement structured agent environment inheritance for spawned agents. Replace the legacy [agent.clear_env]
enabled = true
allow_list = []
deny_list = []Behavior must be:
Update Rust config parsing, agent process environment construction, Helm values/templates/tests, example config, and config documentation. Add tests covering allow-list mode, deny-list mode, empty secure default, disabled filtering, precedence of explicit agent env, missing variables, and migration behavior for removed Helm Merge PitchThis is worth advancing because it addresses a real deployment gap for AWS IRSA and sidecar-style Kubernetes environments while preserving a secure default. The current allow-list-only model pushes operational fragility onto deployers and can break silently when platforms add or rename injected variables. Risk profile is moderate. The main reviewer concern will be the breaking removal of Best-Practice ComparisonOpenClaw principles that apply:
Hermes Agent principles that apply:
Overall, the PR moves OpenAB closer to isolated execution best practices by making inherited process environment a structured policy instead of a single allow-list. Implementation OptionsOption 1: Conservative compatibility layer Keep supporting legacy Option 2: Balanced beta breaking change Accept the PR’s proposed shape: remove Option 3: Ambitious policy model Introduce a named environment policy object with modes such as Option 4: Runtime observability add-on Keep the PR’s config model, but add startup or agent-spawn debug logs indicating the selected inheritance mode and counts of inherited keys, without logging values. This improves operator confidence without changing semantics. Comparison Table
RecommendationAdvance the balanced beta breaking-change path, with one reviewer focus: confirm that OpenAB is comfortable removing The proposed |
Review SummaryLGTM on the core feature ✅ — replacing 🔴 BLOCKING — Remove
|
Closes #723.
Discussion: https://discord.com/channels/1491295327620169908/1500049405984772096/1500055699261231267
Summary
Replaces the flat
[agent].inherit_envallow-list with a structured[agent.clear_env]table that supports allow-list, deny-list, and a pure escape-hatch toggle.Decision tree:
allow_listtakes priority overdeny_listwhen both are set underenabled = true(the deny-list branch is only reached when allow-list is empty).[agent].envalways wins on key conflict.Why
The existing
inherit_envallow-list is brittle for AWS-IRSA / web-identity workloads where Kubernetes auto-injects many env vars (AWS_ROLE_ARN,AWS_WEB_IDENTITY_TOKEN_FILE,AWS_REGION, ...) that the user did NOT add manually but DO need to pass through to the agent. Listing every benign key in an allow-list misses new ones as platforms evolve.With
deny_list, users can run in "inherit all minus known-secret keys" mode — the natural shape of AWS-IRSA + sidecar deployments where most injected env is benign but a few keys (DISCORD_BOT_TOKEN,SLACK_BOT_TOKEN) must stay contained.See #723 for the full problem statement.
Helm values
TOML config
BREAKING CHANGE (beta)
agents.<name>.inheritEnvis removed. Migration:The Helm template hard-fails with a migration message if the legacy key is encountered, so misconfigured upgrades fail loudly rather than silently regressing.
TOML config users: rename
inherit_env = [...]to[agent.clear_env]table withallow_list = [...].Files
src/config.rs— newClearEnvConfig { enabled, allow_list, deny_list }src/acp/connection.rs— rewritesbuild_agent_envwith the decision tree + 4 new testssrc/acp/pool.rs— passes the struct throughcharts/openab/templates/configmap.yaml— emits[agent.clear_env]block + hard-fails on legacyinheritEnvcharts/openab/tests/configmap_test.yaml— covers all four shapes incl. migration failureconfig.toml.example— documents the decision tree with three example shapesdocs/config-reference.md— replacesinherit_envrow withclear_envtable + sub-table, decision tree, AWS-IRSA use caseAGENTS.md— arch-tree comment + Security section updated with decision treeTest plan
cargo clippy -- -D warningscleancargo test --bin openab— 201 tests pass, including 7 newbuild_agent_envtests covering: explicit-env precedence, allow-list-only mode, deny-list-only mode (when allow-list empty), allow-list takes priority when both set,enabled=falseignores both lists,enabled=trueempty-lists inherits nothing, missing-var skipclearEnv.allowList,clearEnv.enabled=false,clearEnv.denyList, and the legacy-inheritEnvmigration failureenabled=false+denyListand confirm AWS_* env vars reach the agent whileDISCORD_BOT_TOKENstays out🤖 Generated with Claude Code