Skip to content

feature: Per-profile exec policy rule toggling #15751

Closed

Description

@aryasaatvik

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

Environment

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

Activity

  1. changed the title [-]Feature: Per-profile exec policy rule toggling[/-] [+]feature: Per-profile exec policy rule toggling[/+] on Mar 25, 2026
  2. added
    enhancement
    on Mar 25, 2026
  3. etraut-openai commented on Mar 25, 2026

    @etraut-openai
    Contributor

    We are likely going to deprecate profiles. We don't have any plans at this time to extend them.

  4. added
    sandbox
    on Mar 26, 2026
  5. etraut-openai commented on May 10, 2026

    @etraut-openai
    Contributor

    This feature request hasn't received enough upvotes, so I'm going to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions