settings.json env vars not propagated to background (bg-spare) session processes
Description
Environment variables intended to control subagent model selection (CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_SUBAGENT_MODEL_FORCE) are not inherited by background job worker processes (claude bg-spare --bg-spare ...), even when correctly present in the parent daemon's environment. This was reproduced using claude agents view.
Steps to reproduce
- Export
CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1andCLAUDE_CODE_SUBAGENT_MODEL=<model>in shell profile (e.g..zshrc). - Restart the Claude Code daemon (
claude daemon run ...) so it picks up the new shell env — confirmed viaps eww <daemon-pid>that the daemon process itself has both vars set correctly. - Start any background session/job (dispatched via the background agent daemon, spawned as
claude bg-spare --bg-spare <socket>). - Inside that background session, run
env | grep -i SUBAGENT.
Expected: the bg-spare child process inherits the daemon's environment, including these two vars.
Actual: env | grep -i SUBAGENT returns nothing — confirmed both via the shell builtin inside the session and via ps eww <bg-spare-pid> from outside. The vars are present on the daemon (parent) but absent on the bg-spare (child) it spawns.
Impact: settings.json's top-level env block (and exported shell env picked up by the daemon) cannot reliably control subagent model selection for any session started as a background job — only genuinely foreground-launched sessions may be unaffected (untested).
Environment: macOS (Darwin 25.6.0), Claude Code CLI, daemon-managed background sessions (bg-spare architecture).
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗