feature: Per-profile exec policy rule toggling

Resolved 💬 2 comments Opened Mar 25, 2026 by aryasaatvik Closed May 10, 2026

Problem

Exec policy rules (.rules files in ~/.codex/rules/) apply globally to all codex invocations from the same CODEX_HOME. There is no way to disable or filter rules per-profile or per-invocation context (interactive vs codex exec).

Use case

I have a commit() shell alias that uses codex exec with a lightweight model to generate commit messages:

commit() {
  codex exec \
    -c model="gpt-5.3-codex-spark" \
    -c model_reasoning_effort="medium" \
    '$commit-staged'
}

I want git commit and git push to always prompt in interactive codex sessions, but skip prompting when invoked via my commit() alias (which is purpose-built and trusted).

The natural approach is:

  1. Create a prefix_rule(pattern=["git","commit"], decision="prompt") in ~/.codex/rules/
  2. Use a profile override (--profile commit) in the alias to bypass the rule

But this doesn't work because:

  • Profiles ([profiles.<name>] in config.toml) cannot toggle exec policy rule loading
  • No approval_policy value can downgrade a rule's Prompt decision to Allow — it's either shown to the user or escalated to Forbidden (by design, per prompt_is_rejected_by_policy() in exec_policy.rs)

Current workarounds

  • Use separate CODEX_HOME directories (fragile, duplicates config)
  • Use soft AGENTS.md instructions instead of rules (not enforced)
  • Don't use rules at all (loses the safety benefit for interactive sessions)

Proposed solution

Add exec policy rule toggling to ConfigProfile. For example:

[profiles.commit]
model = "gpt-5.3-codex-spark"
exec_policy_rules = false  # disable .rules file loading for this profile

Or more granularly:

[profiles.commit]
exec_policy_mode = "skip"  # skip all user-defined rules (requirements still apply)

This would allow:

  • codex (interactive) → loads rules → prompts on git commit
  • codex exec -p commit '$commit-staged' → skips rules → no prompting

Related issues

  • #10625 — Automations not respecting rules (inverse problem: rules should apply but don't)
  • #15214 — Improved Starlark rule support
  • #12283 — Extending rules to configure sandbox policy

Environment

  • codex CLI (Rust)
  • macOS
  • approval_policy = "on-request", sandbox_mode = "danger-full-access"

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗