Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
Resolved 💬 41 comments Opened Jan 11, 2026 by swoiow 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?
v0.80.0
What subscription do you have?
i just at the begining of the chat, with one question.
Which model were you using?
other
What platform is your computer?
win-x64
What issue are you seeing?
<img width="1286" height="250" alt="Image" src="https://github.com/user-attachments/assets/dc2d267a-7475-4657-9aa7-fb5d65eceb44" />
What steps can reproduce the bug?
Uploaded thread: 019bab9f-b98b-7113-9fa8-f439369b7233
---
现在的lua新增路由的时候,是会处理upstream下面所有的路由吗?譬如```--- 1. 更新路由: xx/v1/sync/ ---
路由结果: {'target': 'http://xx:8000', 'host': 'xx', 'status': 'ok'}``` 访问xx/v1/sync/
business 是不是相当于访问http://xx:8000/business
What is the expected behavior?
_No response_
Additional information
💡 Tip: If someone reports the same issue, please use the /feedback slash command to upload your logs. 📝
41 Comments
Please use the
/feedbackslash command to upload your logs and session details for this session, then post the thread ID here.Edit: Apologies, I just noticed that you included a thread ID. I missed it because of the formatting.
yes, please ,see this -> Uploaded thread: 019bab9f-b98b-7113-9fa8-f439369b7233
@etraut-openai Ok, that is fine. i have the same feeling too. the format is control by your template.
even with the latest release ((v0.98.0), I am getting the same error repeatedly and quite often
■ Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
I just downgraded and pinned my version to v0.80.0 (haha). It has fewer latest skills but works with other models. When I start a new conversation, I don't get the 'Codex ran out of room' warning. @sriinnu
Also had some issues around this. In my case, it seems to be the remote compaction feature. They use
/responses/compact, which keeps around every user message ever sent for the whole duration of the entire session history. Only assistant messages, reasoning and some tool calls are really removed.Maybe, I misunderstand the code, but this seems like an issue for longer threads honestly.
I’m seeing the same behavior.
When I run multiple web tool calls (
search_query/open/find) in one turn, the context meter in the UI barely moves, and then the turn fails withcontext_length_exceeded.From a user perspective, it looks like web-tool context is not reflected in live token usage.
Could this be improved by:
1) Including web-tool context in the live context meter (or showing a separate hidden/tool-context counter),
2) Updating the meter after each tool call (not only at turn completion),
3) Adding a client fallback: on
context_length_exceeded, auto-compact and retry once.This would make token behavior much clearer and prevent surprising failures.
yes, i r right @JiepengLab , i have the same feeling (in point 3, maybe is out of context), but i haven't review the codex code, so that i am not sure.
so, maybe the warning can make more clearly @etraut-openai
how can earlier history be cleared
still seeing this in latest version 0.104.0
@yyyyaaa, if you have that thread available still, please use
/feedbackto upload its contents and post the thread ID here.@etraut-openai here's one I just had the problem: 019c9db2-f55d-7e70-bc46-3873bb460bad
I noticed that it's always in the middle of tool calling and getting responses from tool calls
@etraut-openai 019cc95e-222b-7fa3-b3a0-64c2757aa46c the context ran out but I only used one message, it just started happening today
@etraut-openai 019ccb39-9fe9-7de1-ab21-f5aef3e49b28
@etraut-openai 019cd190-df10-7d53-b3a3-068d8beb24e8 on CodeX App for mac
@etraut-openai
019cde40-84b5-7971-8718-5b1ad678248fon CodeX App for Mac M4 Pro@etraut-openai
019cf9f7-b03c-7913-bcd8-1543b3157f2dCodex 5.3 Spark is effectively unusable for me, since this tends to happen after a turn or two. This happened when I tried Spark for the first time at least a week ago; today I decided to try it again but ran into this issue again.
<img width="666" height="533" alt="Image" src="https://github.com/user-attachments/assets/38a7fe14-6507-4088-a091-3a8c8720436a" />
I am also facing the same issue here, I am using GPT-5.4 on Azure AI Foundry
019d078e-b23b-76a3-bce7-abae58560b7dsame issue 019da230-dc53-7f10-8e23-b95079c8a8c1
I tried without any skills, but still face the issue.
This is a usage stopping issue that propped up since yesterday. I rolled back to 0.120 its teh same. think its related to remote compaction. @etraut-openai
A blocker for getting any actual work done with codex as the harness seems to stop every 5-10 minutes recently.
Or mention your thread ID 019db9e0-74c2-7cf3-8e5c-5de5246f7311 in an existing issue.Yeah this is wrecked rn
i have compaction problems non-stop since 5.5 launched
Same.
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.
Uploaded thread 019d4c01-afbc-7021-a5e5-0fa5b5460c90 same issues as above
same issue. Reported context of 53%. Run /compact and I get the following error.
Doesn't matter if codex CLI or codex app. MacOS. GPT 5.5 Medium.
I just experienced this issue in Codex app Version 26.611.62324 on macOS 15.7.7
Feedback ID:
019ed842-9d16-7342-8b08-b603b1a1d856I added the following to my
~/.codex/config.tomland haven't had the same issue again. My suspicion is that these values are incorrectly set somewhere in my pipeline and manually setting them fixes it.necrobump, but I'm facing the same issue today
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.019ed96a-98ef-74c2-8317-bf972ad1ca4e
I frequently encounter the error: "Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying."
It does not automatically compress the context; I am using the latest version.
Same problem here with codex windows. It started today, it's not compressing
Same problem here, twice already
Thanks @globalhuman!
I just added this, restarted Codex.app, and it compacted and allowed me to continue:
Hi everyone,
While tweaking
~/.codex/config.tomlto try or tune, please ensure your parameters align with the actual technical limits of your model. Setting arbitrarily high values can cause unexpected pipeline errors down the line.For optimized and realistic configuration values, you can refer to these official examples:
👉 [issues/12100#issuecomment-4285901666]
@swoiow Those are not official examples, nor do they include any examples limit values. 🫤
also got this error today anyone know how to fix this can't compact it either
To be honest, I haven't seen this issue since 0.116, and I'm moving to 0.141 in the next two days so I probably won't run into it either.
If you want me to help you take a look, I'll need a bit more context. The trace ID can only be accessed by GitHub users with
*-oaistatus (OpenAI employees), so I have to rely on your context to troubleshoot. Could you tell me how many conversation turns there were (so I can estimate the tokens), whether it was a GPT model or another model, and if any MCP tools were used?i got this error today
Try this and update this chat if it's worked for you. It's already helped some others.
https://github.com/openai/codex/issues/9046#issuecomment-4738469744
thanks @globalhuman it didnot help me, i manually ran /compact and it worked
For me doesn't help ran /compact
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.