<!-- llms-explorer concept facts · https://llms-explorer.com/tree/codex-auto-compaction-body-after-prefix-scope/ · pack 2026-10-05 · ~729 tokens -->

# Codex auto-compaction body_after_prefix scope

> The Codex config reference lists `model_auto_compact_token_limit_scope` directly after `model_auto_compact_token_limit` with the values `total` and `body_after_prefix`.

Parent: [Mac local LLMs: Agent clients, context and compaction](https://llms-explorer.com/tree/mac-local-llms-agent-clients-context-and-compaction/) · 1 facets · 10 facts · page: https://llms-explorer.com/tree/codex-auto-compaction-body-after-prefix-scope/

## Facts

- The Codex config reference lists `model_auto_compact_token_limit_scope` directly after `model_auto_compact_token_limit` with the values `total` and `body_after_prefix`. — [source](https://developers.openai.com/codex/config-reference)
- Codex exposes `compact_prompt` (an inline override of the history compaction prompt) and `experimental_compact_prompt_file` (the same override loaded from a file, marked experimental). — [source](https://developers.openai.com/codex/config-reference)
- Codex's hook events include `PreCompact` and `PostCompact`, configured as matcher groups under `hooks.<Event>`. — [source](https://developers.openai.com/codex/config-reference)
- Codex's `tool_output_token_limit` is the token budget for storing an individual tool or function output in history. — [source](https://developers.openai.com/codex/config-reference)
- `model_catalog_json` is an optional path to a JSON model catalog loaded at startup, and a profile file can override it per profile. — [source](https://developers.openai.com/codex/config-reference)
- Codex ships a built-in table of context windows, tool support and input modalities for OpenAI's own models; for any other slug it warns `Model metadata for <slug> not found. Defaulting to fallback metadata`, once per session. — [source](https://unsloth.ai/docs/basics/codex)
- Unsloth's fix for that warning is `model_context_window = 131072` in `~/.codex/config.toml` for a 128K model, and a custom `ModelInfo` entry in the file named by `model_catalog_json` to control tool support and input modalities. — [source](https://unsloth.ai/docs/basics/codex)
- A Codex remote-compaction call to an OpenAI model failed with `context_length_exceeded` ("Your input exceeds the context window of this model") in a long-running session, and the same session first showed a misleading "high demand" message on the older model. — [source](https://github.com/openai/codex/issues/10823)
- Inferred: `body_after_prefix` helps a local server only if the prefix it excludes is stable across compactions, so the local KV cache for that prefix stays warm; the docs do not say whether that is the intent. — source: `asserted`
- Inferred: for a local server with window W, setting `model_context_window` to W and `model_auto_compact_token_limit` below W minus the largest tool result is the same rule as for Claude Code, and the scope key changes only the quantity compared. — source: `asserted`
