Codex falling in a loop `no apply_patch tool available` and cannot call `multi_tool_use.parallel`
Open 💬 6 comments Opened Mar 24, 2026 by lexoliu
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of Codex CLI is running?
0.116.0
What subscription do you have?
Team
Which model were you using?
gpt-5.4
What platform is your computer?
Darwin 25.1.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
Warp
What issue are you seeing?
Codex fails to patch file or call tool parallelly, but it still could execute command.
What steps can reproduce the bug?
Work with GPT-5.4 in a large repo, it compacts the conversation repeatedly and starts to fall in a tool call failure loop.
What is the expected behavior?
_No response_
Additional information
_No response_
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Here is some thinking process gpt 5.4 displays:
Even if i asked him to call tool sequently, it would still fall a parallel tool call failure loop later. And he would apologize that he doesn't follow the parallel tool call prompt provided by
developerI also cann't rollback to previous state at this time. When I restarted the codex CLI, i lost bunch of chat history.
<img width="1512" height="90" alt="Image" src="https://github.com/user-attachments/assets/dd35d4c4-314c-4ef8-bf03-3be93c4d5a60" />
Yeah, weird. I would have thought
codexandgpt-osswould have worked right out of the box together. But I've found a rather funny interim solution:This looks like a post-compaction tool-surface preservation boundary, not only a missing apply_patch tool.
The runtime should separate:
tool was available earlier in the session
≠
tool is still available after context compaction / state reconstruction
In the report, shell execution still works, but the agent falls into a loop where:
Minimal invariant:
ToolSurfaceAfterCompaction == ToolSurfaceBeforeCompaction
or, if the surface intentionally changes:
ToolSurfaceChange must be explicit, visible, and reflected in the next planning state.
Failure shape:
large repo session
+
context compaction occurs
+
tool surface is reconstructed incompletely
+
model continues planning as if apply_patch / parallel tool use exists
+
runtime rejects or cannot dispatch those tools
+
loop continues
=>
the post-compaction state no longer supports the tool transitions the agent is trying to perform
A useful local verifier:
def validate_tool_surface_after_compaction(before, after):
before_tools = set(before["available_tools"])
after_tools = set(after["available_tools"])
missing = before_tools - after_tools
added = after_tools - before_tools
if missing:
return {
"decision": "tool_surface_changed",
"reason": "tools_missing_after_compaction",
"missing_tools": sorted(missing),
"added_tools": sorted(added),
}
return {
"decision": "tool_surface_preserved",
"missing_tools": [],
"added_tools": sorted(added),
}
Regression cases:
=> planning may use apply_patch
=> local tools_missing_after_compaction diagnostic
=> model planning state must be refreshed before next tool attempt
=> classify as partial tool-surface loss, not global tool failure
=> expose the new tool surface and force replanning
=> bounded diagnostic, no infinite loop
The key boundary is:
context compaction must preserve not only conversation content,
but also the executable tool surface needed for the next transition.
If the tool surface cannot be preserved, Codex should stop and replan against the actual available tools instead of looping on tools that are no longer supported.