Refactor workflow drifted into cross-language rewrite that corrupted Python

Resolved 💬 2 comments Opened Apr 2, 2026 by j32097072 Closed Apr 2, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

codex-cli 0.114.0

What subscription do you have?

api call

Which model were you using?

gpt 4o mini

What platform is your computer?

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

What terminal emulator and version are you using (if applicable)?

WSL

What issue are you seeing?

The run drifted from bounded readability refactoring into a cross-language style rewrite inside Python test code, producing repository mutations that were syntactically invalid and not recovery-safe.

What steps can reproduce the bug?

  1. Open a repository-backed workspace.
  2. Ask Codex CLI to perform the requested edit, repair, or cleanup workflow reflected by this report.
  3. Observe whether it reproduces the failure described above.

What is the expected behavior?

Codex CLI should either apply a valid change or fail cleanly. It should not corrupt repository state, write invalid syntax, or perform over-broad filesystem actions.

Additional information

prompt_event_bundle.json

View original on GitHub ↗

2 Comments

theanuragg · 4 months ago

The repository is currently clean: ‎git status, ‎git diff, and targeted diffs under ‎sdk/python/tests / ‎sdk/python/src all show no changes. ‎python3 -m compileall … and an AST scan across the Python SDK/tests also pass, and ‎HEAD matches the last known good commit.

The earlier Codex refactor did inject invalid Python and cross‑language churn, but rerunning it in a clean tree leaves no persistent damage — the bad mutations only exist transiently and are cleared by resetting the tree.

That said, the workflow still feels risky because the refactor can wander into unrelated language layers and write unsafe edits. For reproduction / mitigation, it may help to:

  • Capture the exact Codex CLI command and prompt that triggered the cross‑language refactor.
  • List which files were touched and how the edits deviated (invalid syntax, JS‑style constructs in Python, etc.).
  • Note that ‎git reset --hard HEAD or returning to the prior clean commit removes the corruption, so the repo itself isn’t permanently damaged, but the intermediate state is potentially destructive.
  • Consider limiting Codex’s edit scope to the files explicitly requested and stopping when it starts drafting unrelated languages.
etraut-openai contributor · 4 months ago

Thanks for the bug report. We'll share the feedback with the team responsible for training our codex models. If you see other model behavior that you'd like to report, please use the /feedback command. That will provide us with additional details including logs and conversation text.