Invalid Context error from patching
What version of Codex is running?
v0.1.2504251709
Which model were you using?
grok, claude
What platform is your computer?
Darwin 23.6.0 arm64 arm
What steps can reproduce the bug?
When using models like Grok or Claude, I'm very frequently experiencing Invalid Context error during patching.
I see the diff correctly displayed in the terminal but the patching fails.
What is the expected behavior?
Patching should working just like it does for o4-mini
What do you see instead?
Invalid Context
Additional information
This is how a successful diff from o4-mini looks like
```$ apply_patch << 'EOF'
* Begin Patch
* Update File: pingpong/index.html
@@
- <div id="instructions">
- <p>Use Up and Down arrow keys to move your paddle.</p>
- <button id="startButton">Start Game</button>
- </div>
- <div id="instructions">
- <p>Use Up and Down arrow keys to move your paddle.</p>
- </div>
- <button id="startButton">Start Game</button>
*** End Patch
EOF
This is how an unsuccessful diff from grok3 looks like
$ apply_patch "* Begin Patch
* Update File: pingpong/game.js
@@ const backgroundCanvas = document.getElementById('backgroundCanvas');
const bgCtx = backgroundCanvas.getContext('2d');
+// Set canvas dimensions dynamically
function resizeCanvas() {
const gameArea = document.querySelector('.game-area');
const maxWidth = 800;
const width = Math.min(gameArea.clientWidth, maxWidth);
const height = width / 2; // Maintain 2:1 aspect ratio
canvas.width = width;
canvas.height = height;
backgroundCanvas.width = width;
backgroundCanvas.height = height;
}
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
const startButton = document.getElementById('startButton');
*** End Patch"
Can we have SEARCH/REPLACE diff format also supported in the Parser class?
https://cookbook.openai.com/examples/gpt4-1_prompting_guide#other-effective-diff-formatsThis issue has 2 comments on GitHub. Read the full discussion on GitHub ↗