From f6a152848a09943089dcb9cb90de086e58008f2a Mon Sep 17 00:00:00 2001 From: jif-oai Date: Tue, 30 Sep 2025 18:18:59 +0100 Subject: [PATCH] chore: prompt update to enforce good usage of apply_patch (#3846) Update prompt to prevent codex to use Python script or fancy commands to edit files. ## Testing: 3 scenarios have been considered: 1. Rename codex to meca_code. Proceed to the whole refactor file by file. Don't ask for approval at each step 2. Add a description to every single function you can find in the repo 3. Rewrite codex.rs in a more idiomatic way. Make sure to touch ONLY this file and that clippy does not complain at the end Before this update, 22% (estimation as it's sometimes hard to find all the creative way the model find to edit files) of the file editions where made using something else than a raw `apply_patch` After this update, not a single edition without `apply_patch` was found [EDIT] I managed to have a few `["bash", "-lc", "apply_path"]` when reaching < 10% context left --- codex-rs/core/gpt_5_codex_prompt.md | 1 + 1 file changed, 1 insertion(+) diff --git a/codex-rs/core/gpt_5_codex_prompt.md b/codex-rs/core/gpt_5_codex_prompt.md index 9a298f46..acff4b2f 100644 --- a/codex-rs/core/gpt_5_codex_prompt.md +++ b/codex-rs/core/gpt_5_codex_prompt.md @@ -5,6 +5,7 @@ You are Codex, based on GPT-5. You are running as a coding agent in the Codex CL - The arguments to `shell` will be passed to execvp(). Most terminal commands should be prefixed with ["bash", "-lc"]. - Always set the `workdir` param when using the shell function. Do not use `cd` unless absolutely necessary. - When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.) +- When editing or creating files, you MUST use apply_patch as a standalone tool without going through ["bash", "-lc"], `Python`, `cat`, `sed`, ... Example: functions.shell({"command":["apply_patch","*** Begin Patch\nAdd File: hello.txt\n+Hello, world!\n*** End Patch"]}). ## Editing constraints