/compact does not work.
Resolved 💬 20 comments Opened Oct 6, 2025 by EnterOgawa Closed Nov 26, 2025
💡 Likely answer: A maintainer (aibrahim-oai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
0.44.0
Which model were you using?
gpt-5-codex high
What platform is your computer?
Windows11Pro 24H2 build 26100.6725
What steps can reproduce the bug?
If the context window is fully used, /compact cannot be executed.
Also, since the consumption is not displayed, it's difficult to determine the right timing to perform /compact.
What is the expected behavior?
I want /compact to be usable even when the context window is fully used.
Also, I’d like the remaining percentage to be displayed at all times, as it used to be, so I can know when to perform /compact.
What do you see instead?
_No response_
20 Comments
Also compact make codex lose context. It does not remember the latest discussion but instead it remember the middle of the previous context/discussion. Needs some improvement in how to compact efficiently without losing what was done and where it stopped before compact.
The following features would be ideal:
Currently, /compact alone is not sufficient, and although instructions for work logging are given in prompts and AGENTS.md, some information is missed.
If this functionality were implemented as a feature, it would greatly improve continuity.
As an urgent measure for now, I’d like the remaining percentage to be displayed as before.
That alone would be enough to handle the situation for the time being.
The main issue at the moment is that the remaining context is displayed during inference, but not when waiting for a prompt.
That's on our roadmap. As a work around you can edit the previous messages (using
esc esc) to gain back some context then compact.Excellent looking forward to that
.45 same thing, /compact name loses all context, /compact alone, 0 percent context left, even after a compact.
In the end, the best solution is to proceed with the work while keeping a work log.
Thank you👍
With Codex 0.45 I am getting a stream error when calling
/compact. Other prompts like "hello" are working as expected. I am using gpt-5-codex on Azure AI Foundry using the responses API.Thank you for the report.
For the time being, I’ll operate under the policy of not using /compact and instead clearing the context with esc -> esc -> enter to continue in a new session.
By the way, I experienced a memory error that caused Codex to crash while using 0.45, but since I can’t reproduce it, I’ll monitor the situation for now.
@EnterOgawa could you share some logs on this memory error?
You can find internal logs in
~/.codex/log/codex-tui.logCame across this issue and just wanted to chime in on what my experience has been. I am noticing that i need to run /compact with some minimum percentage left so that it can work. If its below a certain percentage it will fail with the stream error messages. It needs this minimum percentage because it seems to add to the context the first time /compact is run as the context % left value always decreases further on the first run. If I then run /compact again it works as expected. Maybe its doing the compact the first time and adding the compacted context to the current context before using it when compact is run again? Not sure, but this is how its working for me after the update.
on .46:
stream error: unexpected status 400 Bad Request: {
"error": {
"message": "No tool call found for function call output with call_id call_aWKmTzyNSS5A7142Mq2TMXvt.",
"type": "invalid_request_error",
"param": "input",
"code": null
}
}; retrying 5/5 in 3.464s…
during compact, and compact fails
So I have been dealing with his problem as well (similar Azure deployed
gpt-5-codexmodel gets the exact result listed here when trying to use/compact.I finally became fed up after the issue persisted for so many release tags unresolved and decided to take a crack at fixing it myself in a fork. I love working with Codex interactively and its killing me not being able to compact in long running interactive sessions.
The approach I took was capturing the exact prompt that CodexCLI is sending during the
/compactevent and then looking at the API's refusal. Turns out - it's Azure's own content violation system. There is something about the way that the prompt is written that causes Azure's filtering mechanism to flag it as a content rejection (most likely a system that looks for malicious prompt injection is misbehaving).Azure Block Diagnosis
"content_filter", proving the refusal comes from Azure’s policy layer—not the CLI.
jailbreak/prompt-injection pattern and blocks it.
response.completed, confirming the filter is triggered by specific language rather than the task itself.
I literally just changed the /compact prompt in a fork to:
Based on the direct SSE traces, the only thing triggering Azure’s filter was the wording of the original compact handoff prompt:
That language closely mirrors common prompt-injection patterns (“you have exceeded…”, “stop coding”, “write a note”), which adversaries often use to convince a model to drop guardrails. Azure’s content-moderation heuristics appear to treat it as a jailbreak attempt and immediately emit response.incomplete / content_filter, even though the rest of the instructions are benign.
Once I rephrased the request to a neutral, status-report framing (“The conversation history is about to roll off. Draft a concise handoff note…”), Azure streamed a full response and ended with
response.completed. So the functionality is unchanged; I simply avoided trigger phrases that look like injection or policy-evasion attempts.@jif-oai edited to tag jif on this since their name is on the prompt file I had to adjust in my fork
I was late in noticing the message 💦
Thank you, everyone.
@jif-oai
I’ve understood the location of the logs. I’ll make sure to attach them next time an issue occurs.
@bradvb1234
@deksden
@tylerstraub
Thank you for the information.
I’ll refer to this information to ensure proper usage.
I look forward to your continued support.
It's worth noting for Azure that in my branch of CodeCLI I propigated the content filter refusal error up to the client so I can see whenever it happens - and it's not just rejecting this one prompt. Sometimes random instructions will just be refused by Azure because of its overly agressive prompt injection detection system. I don't even think we can bypass it as customers which sucks.
update I am silly:
sooo it turns out Azure does allow you to define your own adjustments to their filtering in "Guardrails + controls" with Azure AI Foundry.
completely hacked around the problem when I could have just read the manual
¯\_(ツ)_/¯maybe this is just a documentation item rather than a bug
There is still something going on with the /compact command for Codex with this build. I have to run it twice before the session runs out of context to get it to reset the context. If I run i with minimal or 0 context left, it will error as shown in @EnterOgawa's initial post. In previous build, I only had to run it once and could run it with 0% context remaining.
Thank you, @brad-worksafely .
We are currently operating by resetting the session before it reaches 0%, and this approach has been functioning without any particular issues.
By the way, regarding the next issue, it seems to be automatically excluded, so could you consider reviewing and possibly fixing it?
#5274
I'm getting the same error 😢
And if you have already lost all %, you can use the
escescto go back a few messages to get somewhat around15% (or more)context back and edit one of those previous messages to then run/compacttwice, and you should get the 100% backI think this bug has been fixed since the bug report was filed. If you see this problem again, please use the
/feedbackslash command to upload the session and provide a thread ID.