Skip to content

fix(codex): add persistent_instructions to baseline and relax sanity check#974

Open
Lidang-Jiang wants to merge 3 commits intoaffaan-m:mainfrom
Lidang-Jiang:fix/codex-sanity-check-persistent-instructions
Open

fix(codex): add persistent_instructions to baseline and relax sanity check#974
Lidang-Jiang wants to merge 3 commits intoaffaan-m:mainfrom
Lidang-Jiang:fix/codex-sanity-check-persistent-instructions

Conversation

@Lidang-Jiang
Copy link
Copy Markdown
Contributor

@Lidang-Jiang Lidang-Jiang commented Mar 28, 2026

Summary

  • Add persistent_instructions to the baseline .codex/config.toml so that cp .codex/config.toml ~/.codex/config.toml produces a valid global config
  • Downgrade the persistent_instructions sanity check from hard [FAIL] to [WARN], since this field is additive and optional — users who rely solely on AGENTS.md should not be blocked

Partially fixes #967 (the persistent_instructions part; context7 naming is addressed by #970).

Type

  • Skill
  • Agent
  • Hook
  • Command
  • Bug Fix

Changes

.codex/config.toml

Added persistent_instructions with a sensible default and a comment explaining its additive nature (unlike model_instructions_file which replaces AGENTS.md):

persistent_instructions = "Follow project AGENTS.md guidelines. Use available MCP servers when they can help."

scripts/codex/check-codex-global-state.sh

Replaced the hard check_config_pattern call (which uses fail()) with an inline check that uses warn():

if rg -n '^persistent_instructions\s*=' "$CONFIG_FILE" >/dev/null 2>&1; then
  ok "persistent_instructions is configured"
else
  warn "persistent_instructions is not set (recommended but optional)"
fi

Testing

Syntax validation

$ bash -n scripts/codex/check-codex-global-state.sh && echo "Shell syntax OK"
Shell syntax OK

$ python3 -c "import tomllib; tomllib.load(open('.codex/config.toml','rb')); print('TOML syntax OK')"
TOML syntax OK

$ python3 -c "
import tomllib
with open('.codex/config.toml', 'rb') as f:
    data = tomllib.load(f)
print(f'persistent_instructions = \"{data[\"persistent_instructions\"]}\"')
"
persistent_instructions = "Follow project AGENTS.md guidelines. Use available MCP servers when they can help."

End-to-end sanity check comparison

Before (original code) — persistent_instructions shows [FAIL]
$ bash scripts/codex/check-codex-global-state.sh 2>&1; echo "EXIT_CODE=$?"
ECC GLOBAL SANITY CHECK
Repo: /home/devuser/workspace/everything-claude-code
Codex home: /home/devuser/.codex

[OK] Global config.toml exists (/home/devuser/.codex/config.toml)
[OK] Global AGENTS.md exists (/home/devuser/.codex/AGENTS.md)
[FAIL] AGENTS missing ECC root instructions
[FAIL] AGENTS missing ECC Codex supplement
[FAIL] multi_agent is enabled
[OK] deprecated collab flag is absent
[FAIL] persistent_instructions is configured
[FAIL] profiles.strict exists
[FAIL] profiles.yolo exists
[FAIL] MCP section [mcp_servers.github] missing
[FAIL] MCP section [mcp_servers.memory] missing
[FAIL] MCP section [mcp_servers.sequential-thinking] missing
[FAIL] MCP section [mcp_servers.context7-mcp] missing
[OK] No duplicate [mcp_servers.context7] section
  - missing skill: api-design
  - missing skill: article-writing
  - missing skill: backend-patterns
  - missing skill: coding-standards
  - missing skill: content-engine
  - missing skill: e2e-testing
  - missing skill: frontend-patterns
  - missing skill: frontend-slides
  - missing skill: investor-materials
  - missing skill: investor-outreach
  - missing skill: market-research
[FAIL] 11 required skills are missing
[FAIL] Command prompts manifest missing
[FAIL] Extension prompts manifest missing
EXIT_CODE=1
After (fixed code) — persistent_instructions shows [WARN] instead of [FAIL]
$ bash scripts/codex/check-codex-global-state.sh 2>&1; echo "EXIT_CODE=$?"
ECC GLOBAL SANITY CHECK
Repo: /home/devuser/workspace/everything-claude-code
Codex home: /home/devuser/.codex

[OK] Global config.toml exists (/home/devuser/.codex/config.toml)
[OK] Global AGENTS.md exists (/home/devuser/.codex/AGENTS.md)
[FAIL] AGENTS missing ECC root instructions
[FAIL] AGENTS missing ECC Codex supplement
[FAIL] multi_agent is enabled
[OK] deprecated collab flag is absent
[WARN] persistent_instructions is not set (recommended but optional)
[FAIL] profiles.strict exists
[FAIL] profiles.yolo exists
[FAIL] MCP section [mcp_servers.github] missing
[FAIL] MCP section [mcp_servers.memory] missing
[FAIL] MCP section [mcp_servers.sequential-thinking] missing
[FAIL] MCP section [mcp_servers.context7-mcp] missing
[OK] No duplicate [mcp_servers.context7] section
  - missing skill: api-design
  - missing skill: article-writing
  - missing skill: backend-patterns
  - missing skill: coding-standards
  - missing skill: content-engine
  - missing skill: e2e-testing
  - missing skill: frontend-patterns
  - missing skill: frontend-slides
  - missing skill: investor-materials
  - missing skill: investor-outreach
  - missing skill: market-research
[FAIL] 11 required skills are missing
[FAIL] Command prompts manifest missing
[FAIL] Extension prompts manifest missing
EXIT_CODE=1

Key difference: Line 7 changed from [FAIL] persistent_instructions is configured to [WARN] persistent_instructions is not set (recommended but optional). The other failures are unrelated to this PR (incomplete local ECC setup).

For a fully synced environment, users who cp .codex/config.toml ~/.codex/config.toml will now get [OK] persistent_instructions is configured because the baseline includes the field. Users who have a custom global config without persistent_instructions will see a warning instead of a blocking failure.

Checklist

  • Follows format guidelines (conventional commit prefix fix(codex):)
  • Tested with sanity check script
  • No sensitive info (API keys, paths)
  • Shell syntax validated (bash -n)
  • TOML syntax validated (tomllib)

Summary by cubic

Make persistent_instructions part of the baseline config and downgrade its sanity check from FAIL to WARN. The check now detects indented entries so valid configs aren’t missed.

  • Bug Fixes
    • Added default persistent_instructions to .codex/config.toml (additive; does not replace AGENTS.md).
    • Updated scripts/codex/check-codex-global-state.sh to warn when persistent_instructions is missing instead of failing.
    • Relaxed the regex to allow leading whitespace when detecting persistent_instructions.
    • Partially fixes Codex sync sanity check is out of sync with the default config #967.

Written for commit 4b4f077. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Added a persistent system-instruction configuration so project-wide guidance is applied consistently.
    • Relaxed validation for this optional setting: missing entry now raises a warning instead of causing a failure, reducing blocking errors during checks.

…check

The global sanity check (check-codex-global-state.sh) hard-fails when
persistent_instructions is missing from ~/.codex/config.toml, but neither
the baseline .codex/config.toml nor the sync script ever define this field.
This causes a clean install to report a failing sanity check even though the
sync otherwise succeeds (affaan-m#967).

- Add persistent_instructions to the baseline .codex/config.toml so that
  users who cp the config get a working default.
- Downgrade the sanity check from fail to warn, since persistent_instructions
  is additive and optional — users who rely solely on AGENTS.md should not be
  blocked.

Fixes affaan-m#967 (persistent_instructions part; context7 naming addressed by affaan-m#970)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4be8cfa-45eb-49e3-926c-455f786be0f1

📥 Commits

Reviewing files that changed from the base of the PR and between ebd14cd and 4b4f077.

📒 Files selected for processing (1)
  • scripts/codex/check-codex-global-state.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/codex/check-codex-global-state.sh

📝 Walkthrough

Walkthrough

Adds a top-level persistent_instructions key to .codex/config.toml and relaxes the global state checker so a missing persistent_instructions emits a warning instead of failing the sanity check.

Changes

Cohort / File(s) Summary
Configuration addition
\.codex/config.toml
Added persistent_instructions = "Follow project AGENTS.md guidelines. Use available MCP servers when they can help." as a top-level config key.
Sanity check relaxation
scripts/codex/check-codex-global-state.sh
Changed validation to search for persistent_instructions (using rg) and emit [OK] if present or [WARN] if absent; missing key no longer increments failure count.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hop through TOML, bold and spry,
A tiny key beneath the sky,
The checker smiles, no blaring red,
Gentle warnings in its stead,
Hooray — the sync can bounce on by! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding persistent_instructions to the baseline config and relaxing the sanity check validation.
Linked Issues check ✅ Passed The PR successfully addresses issue #967 by adding persistent_instructions to the baseline config and relaxing the sanity check from mandatory failure to warning, directly resolving the stated problem.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue. The modifications to config.toml and the sanity check script both address the out-of-sync baseline and checker problem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 28, 2026

Greptile Summary

This PR makes two small, complementary fixes for persistent_instructions in the ECC Codex integration: it adds a sensible default value to the baseline .codex/config.toml (so a cp to ~/.codex/config.toml yields a working global config), and it downgrades the sanity-check assertion from a hard [FAIL] to a [WARN] for users who don't set the field but rely on AGENTS.md alone.

  • .codex/config.toml — adds persistent_instructions = "Follow project AGENTS.md guidelines. Use available MCP servers when they can help." at the top level with a comment clarifying its additive semantics vs model_instructions_file.
  • scripts/codex/check-codex-global-state.sh — replaces the check_config_pattern call (which hard-fails on absence) with an inline if/else that emits ok when found and warn when absent; the rg pattern also gains a leading \s* anchor ('^\s*persistent_instructions\s*=') making it marginally more robust.
  • No logic errors, shell syntax issues, or security concerns were found. Both files were syntax-validated by the author as documented in the PR description.

Confidence Score: 5/5

Safe to merge — changes are additive and only relax a non-critical sanity check.

Both changes are small, targeted, and well-tested by the author. The TOML field is additive, the shell logic is straightforward, and no existing behavior is broken. All findings are P2 or below.

No files require special attention.

Important Files Changed

Filename Overview
.codex/config.toml Adds a default persistent_instructions value with a clarifying comment; TOML syntax is valid and the field placement is correct.
scripts/codex/check-codex-global-state.sh Replaces hard fail() for missing persistent_instructions with an inline warn(), keeping the same rg pattern approach but relaxing severity appropriately.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[check-codex-global-state.sh] --> B{CONFIG_FILE exists?}
    B -- No --> Z[skip config checks]
    B -- Yes --> C[check_config_pattern: multi_agent enabled]
    C --> D[check_config_absent: collab flag absent]
    D --> E{persistent_instructions set?}
    E -- Yes --> F["[OK] persistent_instructions is configured"]
    E -- No --> G["[WARN] not set — recommended but optional"]
    F --> H[check profiles.strict / profiles.yolo]
    G --> H
    H --> I[check MCP server sections]
Loading

Reviews (2): Last reviewed commit: "fix(codex): allow leading whitespace in ..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/codex/check-codex-global-state.sh`:
- Around line 94-97: The rg pattern used to detect persistent_instructions
currently anchors at line start and will miss indented TOML entries; update the
check in the if that runs rg against "$CONFIG_FILE" to allow leading whitespace
(e.g. use a regex like '^[[:space:]]*persistent_instructions\s*=' or
'^\s*persistent_instructions\s*=') so indented lines are detected and the
warn/ok branch is correct; keep the rest of the surrounding logic (the ok/warn
messages and use of CONFIG_FILE) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a5fbb3f3-73d8-46c2-b825-a023cfe6485c

📥 Commits

Reviewing files that changed from the base of the PR and between 8b6140d and c14765e.

📒 Files selected for processing (2)
  • .codex/config.toml
  • scripts/codex/check-codex-global-state.sh

Lidang-Jiang and others added 2 commits March 28, 2026 11:37
The rg pattern anchored at line start (^persistent_instructions) would
miss indented TOML entries. Use ^\s* prefix to match both top-level and
indented configurations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

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.

Codex sync sanity check is out of sync with the default config

2 participants