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. 📝

View original on GitHub ↗

41 Comments

etraut-openai contributor · 6 months ago

Please use the /feedback slash 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.

swoiow · 6 months ago
Please use the /feedback slash 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.

sriinnu · 5 months ago

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.

swoiow · 5 months ago
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

alexeichhorn · 5 months ago

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.

JiepengLab · 5 months ago

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 with context_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.

swoiow · 5 months ago

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

siridris · 5 months ago

how can earlier history be cleared

yyyyaaa · 4 months ago

still seeing this in latest version 0.104.0

etraut-openai contributor · 4 months ago

@yyyyaaa, if you have that thread available still, please use /feedback to upload its contents and post the thread ID here.

yyyyaaa · 4 months ago

@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

schooldev49 · 4 months ago

@etraut-openai 019cc95e-222b-7fa3-b3a0-64c2757aa46c the context ran out but I only used one message, it just started happening today

chownation · 4 months ago

@etraut-openai 019ccb39-9fe9-7de1-ab21-f5aef3e49b28

CaixyPromise · 4 months ago

@etraut-openai 019cd190-df10-7d53-b3a3-068d8beb24e8 on CodeX App for mac

zsecducna · 4 months ago

@etraut-openai 019cde40-84b5-7971-8718-5b1ad678248f on CodeX App for Mac M4 Pro

petekp · 4 months ago

@etraut-openai 019cf9f7-b03c-7913-bcd8-1543b3157f2d

Codex 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.

Liquid72 · 4 months ago

<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-abae58560b7d

TerrorJack · 3 months ago

same issue 019da230-dc53-7f10-8e23-b95079c8a8c1

sriinnu · 3 months ago
> 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

I tried without any skills, but still face the issue.

ShravanSunder · 2 months ago

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.

ParkerRex · 2 months ago

Yeah this is wrecked rn

enki · 2 months ago

i have compaction problems non-stop since 5.5 launched

joinaunion · 2 months ago

Same.
Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.

wwwdorsey · 1 month ago

Uploaded thread 019d4c01-afbc-7021-a5e5-0fa5b5460c90 same issues as above

globalhuman · 1 month ago

same issue. Reported context of 53%. Run /compact and I get the following error.

Your input exceeds the context window of this model. Please adjust your input and try again.

Doesn't matter if codex CLI or codex app. MacOS. GPT 5.5 Medium.

quinncomendant · 1 month ago

I just experienced this issue in Codex app Version 26.611.62324 on macOS 15.7.7
Feedback ID: 019ed842-9d16-7342-8b08-b603b1a1d856

globalhuman · 1 month ago

I added the following to my ~/.codex/config.toml and 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.

model = "gpt-5.5"
model_context_window = 272000
model_auto_compact_token_limit = 120000
nos1609 · 1 month ago

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

mrchenmo · 1 month ago

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.

DaviDeMo89 · 1 month ago

Same problem here with codex windows. It started today, it's not compressing

coendeurloo · 1 month ago

Same problem here, twice already

quinncomendant · 1 month ago
I added the following to my ~/.codex/config.toml and haven't had the same issue again.

Thanks @globalhuman!

I just added this, restarted Codex.app, and it compacted and allowed me to continue:

model_auto_compact_token_limit = 200000
swoiow · 1 month ago

Hi everyone,

While tweaking ~/.codex/config.toml to 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]

quinncomendant · 1 month ago
you can refer to these official examples

@swoiow Those are not official examples, nor do they include any examples limit values. 🫤

NPT1601 · 29 days ago

also got this error today anyone know how to fix this can't compact it either

swoiow · 29 days ago

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 *-oai status (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?

tiklup11 · 29 days ago

i got this error today

globalhuman · 29 days ago
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

tiklup11 · 28 days ago

thanks @globalhuman it didnot help me, i manually ran /compact and it worked

developerisnow · 24 days ago

For me doesn't help ran /compact

etraut-openai contributor · 21 days ago

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 /feedback and open a new bug report.