# 코덱스 컨텍스트 초과: ran out of room in the model's context window

> 코덱스(Codex) 대화가 모델의 컨텍스트 창을 넘었다는 뜻입니다. /new로 새 대화를 열거나 /compact로 앞 대화를 요약해 공간을 비우면 됩니다.

- URL: https://retn.me/posts/codex-ran-out-of-room-context-window/
- Published: 2026-11-17
- Written by: Claude Code · Reviewed by: 심규섭 (2026-11-17)
- Tool: Codex · Cause: 대화·파일 크기
- Last checked: 2026-11-17

## 메시지 원문

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

---

## 한 줄 답

지금 대화가 모델이 한 번에 읽을 수 있는 양(컨텍스트 창)을 넘었다는 뜻입니다. `/new`로 새 대화를 열거나 `/compact`로 앞 대화를 요약한 뒤 다시 보내면 됩니다.

## 이 메시지가 뜨는 이유

모델 서버가 요청을 `context_length_exceeded` 오류로 거절하면 Codex는 이 메시지를 띄웁니다([codex-api/src/error.rs, rust-v0.169.0](https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/codex-api/src/error.rs), [protocol/src/error.rs, rust-v0.169.0](https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/protocol/src/error.rs)). 보낸 요청이 모델이 받을 수 있는 크기보다 커졌다는 뜻입니다.

Codex는 대화가 일정 토큰을 넘으면 기록을 스스로 요약합니다. 그 기준은 설정 `model_auto_compact_token_limit`이고, 비워 두면 모델별 기본값을 씁니다([Codex config reference](https://learn.chatgpt.com/docs/config-file/config-reference)). 요약 요청마저 창을 넘으면 Codex는 가장 오래된 기록부터 하나씩 빼고 다시 시도합니다. 더 뺄 기록이 없으면 이 메시지로 멈춥니다([compact.rs, rust-v0.169.0](https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/core/src/compact.rs)).

## 해결 순서

1. `/status`로 지금 세션의 설정과 토큰 사용량을 봅니다([Codex CLI developer commands](https://learn.chatgpt.com/docs/developer-commands)).
2. 지금 대화를 이어 가야 하면 `/compact`를 실행합니다. 문서는 이 명령이 보이는 대화를 요약해 토큰을 비운다고 씁니다. 긴 작업 뒤에 쓰면 요점은 남기고 컨텍스트 창을 넘지 않게 해 준다고 씁니다([Codex CLI developer commands](https://learn.chatgpt.com/docs/developer-commands)).
3. 요약 뒤에도 메시지가 뜨면 `/new`로 같은 CLI 세션 안에서 새 대화를 엽니다. 화면까지 지우고 새로 시작하려면 `/clear`를 씁니다([Codex CLI developer commands](https://learn.chatgpt.com/docs/developer-commands)). 새 대화에는 이어 갈 작업의 요점과 필요한 파일 경로만 다시 적습니다.
4. 새 대화에서도 금방 차면 매번 들어가는 컨텍스트를 줄입니다. OpenAI 문서는 `AGENTS.md`를 저장소 안에 나눠 두어 크기를 줄이고, 쓰지 않는 MCP 서버를 끄라고 권합니다. MCP 서버마다 메시지에 컨텍스트가 더 붙기 때문입니다([Codex Pricing](https://learn.chatgpt.com/docs/pricing)).
5. 파일과 자료는 필요한 것만 넘깁니다. 문서는 관련 파일만 주고 자료 범위를 좁히라고 권합니다([Codex Pricing](https://learn.chatgpt.com/docs/pricing)).

## 관련 한도와 요금제

컨텍스트를 많이 쓰는 긴 작업은 메시지 하나에 요금제 사용량을 훨씬 더 씁니다. OpenAI 문서는 모델 선택, 컨텍스트, 추론, 도구 사용이 모두 사용량에 영향을 준다고 씁니다([Codex Pricing](https://learn.chatgpt.com/docs/pricing)).

## 참고

- Claude의 대화 길이와 컨텍스트는 retn.kr의 [Claude 대화 길이 글](https://retn.kr/blog/claude-maximum-conversation-length/)이 다룹니다.

## 출처

- [Codex CLI developer commands (ChatGPT Learn)](https://learn.chatgpt.com/docs/developer-commands)
- [Codex config reference (ChatGPT Learn)](https://learn.chatgpt.com/docs/config-file/config-reference)
- [Codex Pricing (ChatGPT Learn)](https://learn.chatgpt.com/docs/pricing)
- [Codex rust-v0.169.0 protocol/src/error.rs (메시지 문구)](https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/protocol/src/error.rs)
- [Codex rust-v0.169.0 codex-api/src/error.rs (context_length_exceeded 처리)](https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/codex-api/src/error.rs)
- [Codex rust-v0.169.0 core/src/compact.rs (요약 중 넘칠 때)](https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/core/src/compact.rs)
