Problem
Environment-variable resolution and its user-facing description do not state (or consistently implement) a single precedence order. The intended priority is:
Personal > Project > Agent > Automation
(higher wins on name collision — personal overrides project, which overrides agent, which overrides automation/workflow.)
That order must be reflected in runtime merge behaviour and in every description/help string that explains env vars.
Current behaviour
- Scopes exist separately: personal (
userEnv), project secrets (projectSecrets), agent (agentEnv), automation/workflow (workflowEnv + step env) — see user_env.ts, agent_env.ts, workflow_env.ts, projects/secrets/.
- Shared editor:
EnvVarListEditor (app/components/env/env-var-list-editor.tsx).
- Chat / external-agent injection (
run_external_agent.ts) flips user vs agent by credential mode (managed → agent wins; BYO → user wins). Project secrets are a separate injection channel, not part of that session-env merge.
- Workflow sandbox merge (
merge_sandbox_env.ts / workflow_sandbox_exec.ts) uses workflow < file < step, then agent, then broker — not the Personal > Project > Agent > Automation stack.
- UI copy (
workflows.configuration.envHelp, step envHelp, userEnv.page.*, settings.agents.env.description, projectSecrets.*) describes local override behaviour only — none documents Personal > Project > Agent > Automation. Docs docs/en/platform/member/environment.md likewise omit the cross-scope chain.
Proposed change
- Runtime: Resolve colliding keys in the order Personal > Project > Agent > Automation everywhere sandbox/session env is assembled (chat external-agent turns and workflow sandbox steps), unless a documented security exception (e.g. broker/credential scrub keys) must still win — call those out explicitly.
- Copy: Update env-var descriptions (settings personal env, agent env, project secrets/agent-access blurb, automation/workflow env help, step env help) and self-host/member docs so they state the same priority in plain language.
- Keep secret write-only / scrub behaviour intact; only the documented precedence and merge order change.
Acceptance criteria
Affected service
Platform (web app)
Problem
Environment-variable resolution and its user-facing description do not state (or consistently implement) a single precedence order. The intended priority is:
Personal > Project > Agent > Automation
(higher wins on name collision — personal overrides project, which overrides agent, which overrides automation/workflow.)
That order must be reflected in runtime merge behaviour and in every description/help string that explains env vars.
Current behaviour
userEnv), project secrets (projectSecrets), agent (agentEnv), automation/workflow (workflowEnv+ step env) — seeuser_env.ts,agent_env.ts,workflow_env.ts,projects/secrets/.EnvVarListEditor(app/components/env/env-var-list-editor.tsx).run_external_agent.ts) flips user vs agent by credential mode (managed → agent wins; BYO → user wins). Project secrets are a separate injection channel, not part of that session-env merge.merge_sandbox_env.ts/workflow_sandbox_exec.ts) uses workflow < file < step, then agent, then broker — not the Personal > Project > Agent > Automation stack.workflows.configuration.envHelp, stepenvHelp,userEnv.page.*,settings.agents.env.description,projectSecrets.*) describes local override behaviour only — none documents Personal > Project > Agent > Automation. Docsdocs/en/platform/member/environment.mdlikewise omit the cross-scope chain.Proposed change
Acceptance criteria
Affected service
Platform (web app)