Skip to content

feat: support project-local config and prompts - #5341

Closed
ChrisLinn wants to merge 15 commits into
openai:mainfrom
ChrisLinn:feat/different_layer_cfg
Closed

ChrisLinn wants to merge 15 commits into
openai:mainfrom
ChrisLinn:feat/different_layer_cfg

Conversation

@ChrisLinn

@ChrisLinn ChrisLinn commented Oct 19, 2025 •

Copy link
Copy Markdown

Add layered configuration loading to support project-specific settings alongside global user configuration:

Config loading:

  • Add project_config_path field to LoaderOverrides
  • Load from ./.codex/config.toml (project-local)
  • Merge project config over user config, with managed layers on top
  • Add tests: merges_project_overrides_user, managed_overrides_project

Prompts discovery:

  • Implement discover_prompts_merged() to combine global and local prompts
  • Add project_prompts_dir_for() helper for ./.codex/prompts/
  • Project-local prompts override global when names collide
  • Add tests: merges_global_and_local, local_wins_on_conflict

Documentation:

  • Update docs/config.md with precedence rules
  • Update docs/prompts.md with dual-directory behavior

Precedence order (highest to lowest):

  1. CLI overrides
  2. Managed preferences (macOS)
  3. Managed config file
  4. Project-local config (./.codex/config.toml)
  5. Global user config (~/.codex/config.toml)
  6. Built-in defaults

Add layered configuration loading to support project-specific settings
alongside global user configuration:

Config loading:
- Add project_config_path field to LoaderOverrides
- Load from ./.codex/config.toml (project-local)
- Merge project config over user config, with managed layers on top
- Add tests: merges_project_overrides_user, managed_overrides_project

Prompts discovery:
- Implement discover_prompts_merged() to combine global and local prompts
- Add project_prompts_dir_for() helper for ./.codex/prompts/
- Project-local prompts override global when names collide
- Add tests: merges_global_and_local, local_wins_on_conflict

Documentation:
- Update docs/config.md with precedence rules
- Update docs/prompts.md with dual-directory behavior

Precedence order (highest to lowest):
1. CLI overrides
2. Managed preferences (macOS)
3. Managed config file
4. Project-local config (./.codex/config.toml)
5. Global user config (~/.codex/config.toml)
6. Built-in defaults
@github-actions

github-actions Bot commented Oct 19, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ChrisLinn

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 19, 2025

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

fn apply_overlays(
layers: LoadedConfigLayers,
cli_overrides: Vec<(String, TomlValue)>,
) -> TomlValue {
let LoadedConfigLayers {
mut base,
managed_config,
managed_preferences,
} = layers;
for (path, value) in cli_overrides.into_iter() {
apply_toml_override(&mut base, &path, value);
}
for overlay in [managed_config, managed_preferences].into_iter().flatten() {
merge_toml_values(&mut base, &overlay);
}

P1 Badge Apply CLI overrides after managed layers

The new docs say CLI overrides should have the highest precedence, but apply_overlays still merges managed_config and managed_preferences after the CLI values. That means any value set via --config can be overwritten by a device-managed file or profile, contradicting the documented precedence and surprising users who expect the flag to win. Reordering the merge so managed layers are applied first and CLI overrides last would make runtime behaviour match the documented order.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…edence

Reorder overlay application in `apply_overlays` so managed layers (managed_config + managed_preferences) merge first, and CLI `--config` key=value overrides apply last. This ensures flags always win over device-managed config, matching docs/config.md precedence.

Also adds a test (`cli_overrides_take_highest_precedence_over_managed_layers`) to codex-core validating the new order.
@ChrisLinn

ChrisLinn commented Oct 19, 2025 •

Copy link
Copy Markdown
Author

I've updated the PR according to the #5341 (review).
Should I update the branch by merge master into or rebase?

@Nikoqqq

Nikoqqq commented Oct 22, 2025

Copy link
Copy Markdown

Finally someone decided to do it 🔥

@ChrisLinn

Copy link
Copy Markdown
Author

Hi @aibrahim-oai / @joshka-oai / @nornagon-openai / ... , can you take a look? Thanks!

@etraut-openai

Copy link
Copy Markdown
Contributor

Thanks for the contribution, and apologies for the slow response.

We've updated our contribution guidelines to clarify that we're currently accepting contributions for bugs and security fixes, but we're not generally accepting new features at this time. We need to make sure that all new features compose well with both existing and upcoming features and fit into our roadmap.

The feature you're implementing in this PR has received (and continues to receive) a lot of upvotes, so it's likely something that will receive attention by the codex team in the near future. We'll need to do some design work to ensure that the feature composes well with other features that we have in the works — and that it works well across all our local surfaces (CLI and IDE extensions).

We're using this feature request to track this feature. I've added a link to this PR, which I think is a good proof of concept. In the meantime, I'm going to close this PR in an effort to manage the backlog.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 31, 2025
@openai openai unlocked this conversation Oct 31, 2025
@ChrisLinn
ChrisLinn deleted the feat/different_layer_cfg branch November 5, 2025 03:17
youta7 added a commit to youta7/ta-codex that referenced this pull request Nov 10, 2025
swordfish444 pushed a commit to swordfish444/codex that referenced this pull request Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants