Skip to content

HERDR_* environment variables not inherited in codex #910

Description

@y1zhou

Is this a reproducible bug?

  • I confirm this is a reproducible bug, not a feature request, idea, question, contribution proposal, or direction check.

Current behavior

When setting up the agent skill as described in https://herdr.dev/docs/agent-skill/ for codex, I found that the codex agent does not see any of the herdr-managed environment variables with !env. When asking it to manage subagents with herdr, it also fails to identify itself in HERDR_ENV=1 and falls back to codex-managed sessions.

Expected behavior

Should work as the docs say. The problem is probably with shell_environment_policy.inherit defaulting to "none" in codex. Setting it to "core" or "all" in ~/.codex/config.toml would let HERDR_* environment variables be correctly identified in codex sessions. Maybe the setting could be toggled in install_codex()?

let config_path = dir.join("config.toml");
let existing_config = if config_path.is_file() {
fs::read_to_string(&config_path)?
} else {
String::new()
};
let new_config = build_codex_config_with_hooks(&existing_config);
if new_config != existing_config {
fs::write(&config_path, new_config)?;
}

Ideally the change should also update shell_environment_policy.include_only to avoid unexpected inclusion of sensitive environment variables.

Reproduction

See current behavior.

Impact

Codex does not automatically manage subagents with herdr.

Environment

  • Herdr version: 0.7.1
  • Update channel (stable or preview): stable
  • Operating system: Fedora Linux 44 (Server Edition) x86_64
  • Terminal: Ghostty / Windows terminal via SSH connection
  • Shell, if relevant: Fish
  • Relevant config, if any:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions