codex-1m-context-window-setup

Configures model-aware context window and auto-compaction limits in Codex CLI config.toml.

1.4k|216|Updated Oct 22, 2025
One-click install
npx skills add https://github.com/daymade/claude-code-skills --skill codex-1m-context-window-setup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: codex-1m-context-window-setup
Source: https://github.com/daymade/claude-code-skills/tree/main/daymade-codex/codex-1m-context-window-setup
Command: npx skills add https://github.com/daymade/claude-code-skills --skill codex-1m-context-window-setup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Codex sessions often run with a default ~258K context window, causing frequent auto-compaction and lost context on long tasks. Manually editing config.toml risks guessing wrong token limits, breaking TOML syntax, or overwriting unrelated settings.

Core Features & Use Cases

  • Model-aware configuration: Reads the live Codex model catalog via codex doctor and codex debug models, then caps the requested 1M window at the selected model's declared maximum instead of guessing.
  • Safe config editing: Changes only model_context_window and model_auto_compact_token_limit (set to 60% of the window), preserves all other TOML content, creates content-addressed backups, and rolls back on validation failure.
  • Three-mode workflow: doctor inspects and reports, apply writes the change atomically, and verify confirms the config still matches the recommendation after upgrades.
  • Use Case: A team notices Codex compacting conversations too aggressively on long refactoring sessions. Run the doctor/apply/verify workflow to raise the context window to the model's maximum (up to 1M tokens) across macOS and Windows workstations.

Quick Start

Ask the assistant to run the codex context window doctor command to inspect the current limit, then apply the recommended model-aware configuration.

Frequently Asked Questions about codex-1m-context-window-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I increase the Codex CLI context window to 1M tokens?

Run the apply mode of the codex_context_window.py script, which sets model_context_window in $CODEX_HOME/config.toml to the smaller of 1,000,000 tokens or your selected model's declared maximum. Start a new Codex session afterward, since running threads are not expanded.

Why does Codex show only 258K context and compact so often?

Codex uses the model's catalog default context window unless model_context_window is overridden in the base config. The doctor mode reports the catalog default, the model maximum, and the current config values so you can see exactly why compaction triggers early.

Does the 1M context setting work with every Codex model?

No. The script reads the live model catalog and caps the request at the selected model's max_context_window, then applies the model's effective_context_window_percent for the usable session window. It refuses to guess or force 1M when the model declares a smaller limit.

Will editing config.toml break my other Codex settings?

No. The script changes only the top-level model_context_window and model_auto_compact_token_limit keys, preserving all other TOML content. It creates a timestamped backup, writes atomically, runs strict-config diagnostics, and restores the prior bytes if validation fails.

Does the new context window apply to my current Codex session?

No. Configuration is read when a session starts, so the running thread keeps its existing window. After a successful apply, start a new CLI thread or open a new Codex Desktop thread to use the expanded context.

How do I verify the Codex context config after an upgrade?

Run the script in verify mode. It re-reads the live model catalog and exits non-zero if the current base config no longer matches the model-aware recommendation, which can happen after Codex upgrades or default-model changes.