Codex ran out of room in the model's context window. Start a new conversation or clear earlier history before retrying.
Resolved 💬 10 comments Opened Dec 17, 2025 by robertotcestari Closed Jun 29, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
codex-cli 0.73.0
What subscription do you have?
pro
Which model were you using?
gpt-5.2
What platform is your computer?
Darwin 25.1.0 arm64 arm
What issue are you seeing?
Error running remote compact task: {
"error": {
"message": "Your input exceeds the context window of this model. Please adjust your input and try
again.",
"type": "invalid_request_error",
"param": "input",
"code": "context_length_exceeded"
}
}
What steps can reproduce the bug?
Uploaded thread thread ID 019b2c32-a042-7aa0-af6e-43be27e1451b
What is the expected behavior?
_No response_
Additional information
_No response_
10 Comments
thread ID 019b2c32-a042-7aa0-af6e-43be27e1451b
Manually edit the session file
~/.codex/sessions/xxxx/xx/xx/session-id.jsonlto remove the huge line of text, then do resume the session, then/compact. If the problem still exists, continuous removal of large text lines.Excuse me, what does the manually edit actually do on the Agent's side? Is there any side effects?
Happened to me when I was running a task that required a bunch of internet searches
<img width="1024" height="1536" alt="Image" src="https://github.com/user-attachments/assets/cb15377f-0d4a-47f1-bdd0-921b0ae4ab38" />
Mine was also right after a bunch of web searches, why does auto compaction not kick in here?
Maybe like a minify attack.
The fact that this hasen't been fixed for 4 months now is embarassing
The fact that this hasen't been fixed for 6 months now is embarassing
English
For conversations already affected by this issue, enter
/compactin the chat box to manually compress the context so you can continue the conversation. To prevent this issue from recurring, navigate toC:\Users\[Username]\.codex\config.tomland reduce the value ofmodel_auto_compact_token_limit. The probable cause is context length overflow: either the compression mechanism fails to work properly, or the context length of the last conversation surges past the maximum limit immediately after exceeding the minimum compression threshold, leaving no time for compression to execute.You can also resolve the problem by cutting down the initial context length, such as shortening system prompts, disabling extra skills and plugins.
Another root cause may be that the current conversation carries background data from other dialogues. Deleting old chat logs can also fix the issue, yet I do not want to lose historical records, so I opted for the previous solution. Here is the second workaround:
~/.codex/sessions/Year/Month/Day/session-id.jsonl; this file may become extremely large.中文
已经出现该问题的对话,在对话框输入
/compact手动压缩上下文后即可继续对话。若想要避免再次出现该问题,可打开路径C:\Users\用户名\.codex\config.toml,将model_auto_compact_token_limit参数数值调小。问题推测为上下文长度溢出:自动压缩机制未正常生效,或是上一轮对话上下文刚达到压缩最低阈值就直接超限,系统来不及执行压缩操作。也可以精简系统提示词、关闭多余技能与插件,缩减初始上下文长度以解决故障。
另一种成因是当前对话会附带其他会话的历史内容,删除旧对话记录也能解决问题,但我不想丢失历史聊天记录,因此选用了第一种方案。以下是第二种解决方法:
~/.codex/sessions/年/月/日/session-id.jsonl,该文件体积可能会很大;Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use
/feedbackand open a new bug report.