Skip to content

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

Closed

Description

@robertotcestari

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

Activity

  1. robertotcestari commented on Dec 17, 2025

    @robertotcestari
    Author

    thread ID 019b2c32-a042-7aa0-af6e-43be27e1451b

  2. added
    contextIssues related to context management (including compaction)
    on Dec 17, 2025
  3. wudi commented on Dec 30, 2025

    @wudi

    Manually edit the session file ~/.codex/sessions/xxxx/xx/xx/session-id.jsonl to remove the huge line of text, then do resume the session, then /compact. If the problem still exists, continuous removal of large text lines.

  4. acllm commented on Jan 14, 2026

    @acllm

    Manually edit the session file ~/.codex/sessions/xxxx/xx/xx/session-id.jsonl to 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?

  5. armaanahluwalia commented on Feb 15, 2026

    @armaanahluwalia

    Happened to me when I was running a task that required a bunch of internet searches

    Image
  6. kdawgwilk commented on Feb 25, 2026

    @kdawgwilk

    Mine was also right after a bunch of web searches, why does auto compaction not kick in here?

  7. plugyawn commented on Feb 26, 2026

    @plugyawn

    Maybe like a minify attack.

  8. antonkoetzler commented on Jun 14, 2026

    @antonkoetzler

    The fact that this hasen't been fixed for 4 months now is embarassing

  9. AXsss commented on Jun 18, 2026

    @AXsss

    The fact that this hasen't been fixed for 6 months now is embarassing

  10. Han-1413141 commented on Jun 18, 2026

    @Han-1413141

    English

    For conversations already affected by this issue, enter /compact in the chat box to manually compress the context so you can continue the conversation. To prevent this issue from recurring, navigate to C:\Users\[Username]\.codex\config.toml and reduce the value of model_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:

    1. Locate the session file path: ~/.codex/sessions/Year/Month/Day/session-id.jsonl; this file may become extremely large.
    2. Remove outdated sessions: manually delete session files with earlier dates while keeping recent chat records.
    3. Restart Codex: reboot the Codex tool after cleanup to apply the modifications.

    中文

    已经出现该问题的对话,在对话框输入 /compact 手动压缩上下文后即可继续对话。若想要避免再次出现该问题,可打开路径 C:\Users\用户名\.codex\config.toml,将 model_auto_compact_token_limit 参数数值调小。问题推测为上下文长度溢出:自动压缩机制未正常生效,或是上一轮对话上下文刚达到压缩最低阈值就直接超限,系统来不及执行压缩操作。

    也可以精简系统提示词、关闭多余技能与插件,缩减初始上下文长度以解决故障。

    另一种成因是当前对话会附带其他会话的历史内容,删除旧对话记录也能解决问题,但我不想丢失历史聊天记录,因此选用了第一种方案。以下是第二种解决方法:

    1. 定位会话文件:文件路径为 ~/.codex/sessions/年/月/日/session-id.jsonl,该文件体积可能会很大;
    2. 删除早期会话:手动移除日期较早的会话文件,保留近期聊天记录;
    3. 重启Codex:清理完成后重启Codex工具,使修改生效。
  11. etraut-openai commented on Jun 29, 2026

    @etraut-openai
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcontextIssues related to context management (including compaction)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions