Context compaction fails with unknown parameter 'prompt_cache_retention'

Resolved 💬 38 comments Opened Apr 14, 2026 by obahareth Closed Apr 14, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

26.409.20454 (1462)

What subscription do you have?

ChatGPT Pro

What platform is your computer?

Darwin 25.2.0 arm64 arm

What issue are you seeing?

While using the Codex Mac app, automatic context compaction fails instead of compacting the thread.

The app shows this error inline in the chat UI:

<img width="1632" height="632" alt="Image" src="https://github.com/user-attachments/assets/d53d4d7c-d97a-4255-b5d1-6cfecb070f21" />

Error running remote compact task: { "error": { "message": "Unknown parameter: 'prompt_cache_retention'.", "type": "invalid_request_error", "param": "prompt_cache_retention", "code": "unknown_parameter" } }

This appears during the "Automatically compacting context" step. Instead of compacting the conversation, the app surfaces the raw API error.

What steps can reproduce the bug?

  1. Open the Codex macOS app.
  2. Work in a thread until the app attempts automatic context compaction.
  3. Wait for the "Automatically compacting context" message to appear.
  4. Observe that the compact task fails with:
   Error running remote compact task: { "error": { "message": "Unknown parameter: 'prompt_cache_retention'.", "type": "invalid_request_error", "param": "prompt_cache_retention", "code": "unknown_parameter" } }

What is the expected behavior?

Automatic context compaction should complete successfully and continue the conversation normally.

Additional information

Running /compact manually on the same thread from the CLI results in this:

Error running remote compact task: {
  "error": {
    "message": "Unknown parameter: 'prompt_cache_retention'.",
    "type": "invalid_request_error",
    "param": "prompt_cache_retention",
    "code": "unknown_parameter"
  }
}

View original on GitHub ↗

38 Comments

monkey-sheng · 3 months ago

Getting this too in VS Code extension, thread id: 019d8b82-66f8-7d22-a34d-40e6f025fe4e

Mygod · 3 months ago

+1 on CLI

JamesticCS · 3 months ago

Getting this too in CLI

atonderski · 3 months ago

getting this codex-cli 0.120.0

popperwin · 3 months ago

Same issue

TigerHix · 3 months ago

oh my god not now codex

dotdioscorea · 3 months ago

+1 on CLI across many accounts and machines

mvarchdev · 3 months ago

Probably just api is down

Gk0Wk · 3 months ago

+1 on cli, win11, 0.119.0

valmedia · 3 months ago

new model incoming

frdmir · 3 months ago

same issue, cannot compact context.

Higor-Matos · 3 months ago

+1 cli, MacOs, v0.120.0

physics-programmer · 3 months ago

+1 on cli, macosx, v0.120.0

EricSongXinLe · 3 months ago

+1 on cli, v0.120.0. 019d4b5b-01b3-7533-a3c0-b4aaed5d56c8

fanaev · 3 months ago

+1 on cli, v0.120.0, 019d8d21-0988-73f1-a1aa-52f83b52d35d

kokorog · 3 months ago

+1

to-sora · 3 months ago

+1

pjasicek · 3 months ago

+1

jayjongcheolpark · 3 months ago

+1

to-sora · 3 months ago

good night guy , let work tmt

CarlosFelipeArantes · 3 months ago

+1. error: Error running remote compact task: { "error": { "message": "Unknown parameter: 'prompt_cache_retention'.", "type": "invalid_request_error", "param": "prompt_cache_retention", "code": "unknown_parameter" } }

lastknowngood · 3 months ago

+1

Biblejustin · 3 months ago

Adding one more concrete reproduction from Codex Desktop on macOS.

  • Date observed: 2026-04-14
  • Thread id: 019d89b3-b6cf-7fd3-8b9f-292f471fc457
  • Local session metadata shows: originator=Codex Desktop, cli_version=0.119.0-alpha.28, model_provider=openai
  • Local config at repro time: model = "gpt-5.4", model_reasoning_effort = "xhigh"

What I found locally:

  • Right before failure, token count event showed last input_tokens=236952 with model_context_window=258400, so compaction appears to be triggering near the context limit as expected.
  • Immediately after that, the session logs show the inline error:
Error running remote compact task: {
  "error": {
    "message": "Unknown parameter: 'prompt_cache_retention'.",
    "type": "invalid_request_error",
    "param": "prompt_cache_retention",
    "code": "unknown_parameter"
  }
}

Possible root cause:

  • OpenAI docs for POST /v1/responses include prompt_cache_retention
  • OpenAI docs for POST /v1/responses/compact do not appear to accept that field
  • This looks like the compaction path is forwarding a create-response-only parameter into the compact endpoint

So this does not look thread-specific. It looks like a request-shape mismatch in the compaction path.

Higor-Matos · 3 months ago

I found a fallback

Eu encontrei um fallback.

Summary

There is an upstream Codex bug where automatic context compaction can fail with:

Unknown parameter: 'prompt_cache_retention'

I added an opt-in workaround profile to ~/.codex/config.toml so Codex can try a different compaction path without changing your default setup.

This does not change your project code.
This does not redirect traffic to a third-party provider.
This only affects Codex when you explicitly use the workaround profile.

What changed

I added this block to ~/.codex/config.toml:

[profiles.inline_compact_workaround]
model_provider = "openai_inline"

[model_providers.openai_inline]
name = "OpenAI Inline"
requires_openai_auth = true
supports_websockets = true

Current location in the file:

  • ~/.codex/config.toml:40
  • ~/.codex/config.toml:43

What this means

Before this change:

  • your normal Codex setup used the built-in openai provider

After this change:

  • your normal Codex setup is still unchanged
  • there is now an additional profile called inline_compact_workaround
  • that profile uses a custom provider entry named openai_inline

Important:

  • if you run Codex normally, nothing changes
  • the workaround is only used if you start Codex with the dedicated profile

How to use it

To resume the affected thread with the workaround:

codex -p inline_compact_workaround resume 019d8c16-d49f-72a1-b7f9-bd7ad5410a5f

To start a new session with the workaround:

codex -p inline_compact_workaround

Why this fallback may help

Confirmed facts

  • As of April 14, 2026, your local CLI version is codex-cli 0.120.0.
  • As of April 11, 2026, 0.120.0 is the latest published Codex release.
  • As of April 14, 2026, there is an open upstream Codex issue for the same failure:

Context compaction fails with unknown parameter 'prompt_cache_retention'

  • The issue is public here:

https://github.com/openai/codex/issues/17809

Confirmed facts from the workaround config

  • I did not set base_url
  • I did not set env_key
  • I did not set http_headers
  • I did not set query_params
  • I set requires_openai_auth = true

That means this provider still uses the normal OpenAI authentication flow instead of sending traffic somewhere else.

Technical inference

Based on the public Codex source:

  • Codex uses a special remote compaction path when the provider is recognized as built-in OpenAI
  • the custom provider name OpenAI Inline may avoid that exact path
  • if that happens, Codex should fall back to the regular inline/local compaction flow instead of the failing remote compact path

This is why the workaround is reasonable.

Is it safe?

Safe in the network/authentication sense

Yes, this workaround is safe in the sense that:

  • it still uses OpenAI authentication
  • it does not point to a different vendor
  • it does not add custom headers
  • it does not inject a custom API URL

Not a guaranteed official fix

No, this is not an official upstream fix.

It is a fallback workaround, not a confirmed product patch.

What did not change

  • your repo at /Users/higordedeusmatos/Work/S/Projects/mimir
  • your source code
  • your tests
  • your shell environment
  • your default Codex behavior when you do not use the workaround profile

How to revert it

If you want to undo the workaround, remove this block from ~/.codex/config.toml:

[profiles.inline_compact_workaround]
model_provider = "openai_inline"

[model_providers.openai_inline]
name = "OpenAI Inline"
requires_openai_auth = true
supports_websockets = true

After removal, Codex returns to the previous configuration.

Known limitations

Facts

  • I validated that the config file still loads correctly after the change.
  • I validated that the new profile is accepted by the CLI.

Unknowns

  • I did not force a long enough live conversation to trigger compaction under this profile during validation.
  • Because of that, the final runtime behavior is still a real-world test rather than a mathematically guaranteed outcome.

Recommended next step

Run:

codex -p inline_compact_workaround resume 019d8c16-d49f-72a1-b7f9-bd7ad5410a5f

If compaction succeeds, keep using this profile temporarily until upstream ships a proper fix.

If it still fails, remove the workaround and wait for an upstream patch in Codex.

Reference links

  • Upstream bug report:

https://github.com/openai/codex/issues/17809

  • Latest Codex release:

https://github.com/openai/codex/releases/tag/rust-v0.120.0

  • Codex config reference:

https://developers.openai.com/codex/config-reference

  • OpenAI prompt caching guide:

https://developers.openai.com/api/docs/guides/prompt-caching

pinciottima · 3 months ago

+1 macOS Codex Desktop

Jonomir · 3 months ago

Damm, now I have to start another tread and its going to take some time to gather context until its not dumb anymore

MarcusNeufeldt · 3 months ago

Seeing the same issue here on Windows 11 with codex-cli 0.120.0 using ChatGPT sign-in and gpt-5.4.

It started suddenly on April 14, 2026 after previously working reliably. Automatic compaction fails with:

Error running remote compact task: {
  "error": {
    "message": "Unknown parameter: 'prompt_cache_retention'.",
    "type": "invalid_request_error",
    "param": "prompt_cache_retention",
    "code": "unknown_parameter"
  }
}

/compact fails with the same error, so the affected thread becomes unusable once compaction kicks in.

Thread ID from my local logs: 019d8b82-60a7-77d1-b8dc-48030b8c7772.

videogorl · 3 months ago

+1 on macOS Codex Desktop

swapnil-sudhir · 3 months ago

+1 on macOS codex desktop -

Error running remote compact task: { "error": { "message": "Unknown parameter: 'prompt_cache_retention'.", "type": "invalid_request_error", "param": "prompt_cache_retention", "code": "unknown_parameter" } }

KFCDeveloper · 3 months ago

+1 Error running remote compact task: { "error": { "message": "Unknown parameter: 'prompt_cache_retention'.", "type": "invalid_request_error", "param": "prompt_cache_retention", "code": "unknown_parameter" } }

kmalyshev · 3 months ago

+1 Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)

swapnil-sudhir · 3 months ago

Quit and Reopened the app on MacOS, and its working now, in the same thread.

dotdioscorea · 3 months ago

Panic over, all working again

CarlosFelipeArantes · 3 months ago

Working fine!

Rafael135790 · 3 months ago
# Encontré una alternativa > Eu encontré um fallback. ## Resumen Existe un error en Codex en la versión principal donde la compactación automática del contexto puede fallar con: `` Unknown parameter: 'prompt_cache_retention' ` He añadido un **perfil de solución alternativa opcional** para ~/.codex/config.tomlque Codex pueda intentar una ruta de compactación diferente sin modificar la configuración predeterminada. Esto **no** modifica el código de tu proyecto. Esto **no** redirige el tráfico a un proveedor externo. Esto solo afecta a Codex cuando utilizas explícitamente el perfil de solución alternativa. ## ¿Qué cambió? Agregué este bloque a ~/.codex/config.toml: [profiles.inline_compact_workaround] model_provider = "openai_inline" [model_providers.openai_inline] name = "OpenAI Inline" requires_openai_auth = true supports_websockets = true Ubicación actual en el archivo: * ~/.codex/config.toml:40 * ~/.codex/config.toml:43 ## Lo que esto significa Antes de este cambio: * openaiSu configuración normal de Codex utilizaba el proveedor integrado. Después de este cambio: * Tu configuración normal del Códice sigue sin cambios. * Ahora hay un perfil adicional llamadoinline_compact_workaround * ese perfil utiliza una entrada de proveedor personalizada llamadaopenai_inline Importante: * Si ejecutas Codex normalmente, no cambia nada. * Esta solución alternativa solo se utiliza si inicias Codex con el perfil dedicado. ## Cómo usarlo Para reanudar el hilo afectado con la solución alternativa: codex -p inline_compact_workaround resume 019d8c16-d49f-72a1-b7f9-bd7ad5410a5f Para iniciar una nueva sesión con la solución alternativa: codex -p inline_compact_workaround ## Por qué esta alternativa puede ser útil ### Hechos confirmados * A partir **del 14 de abril de 2026** , su versión local de CLI es codex-cli 0.120.0. * A fecha de **11 de abril de 2026** , 0.120.0esta es la última versión publicada del Codex. * A fecha de **14 de abril de 2026** , existe un problema abierto en el Codex 2026 relacionado con el mismo fallo: Context compaction fails with unknown parameter 'prompt_cache_retention' * El asunto es público aquí: https://github.com/openai/codex/issues/17809 ### Hechos confirmados a partir de la configuración de la solución alternativa. * **No** lo configurébase_url * **No** lo configuréenv_key * **No** lo configuréhttp_headers * **No** lo configuréquery_params * Yo establecírequires_openai_auth = true Eso significa que este proveedor sigue utilizando el flujo de autenticación normal de OpenAI en lugar de enviar el tráfico a otro lugar. ### Inferencia técnica Basado en la fuente pública del Codex: * Codex utiliza una ruta **de compactación remota** especial cuando el proveedor se reconoce como integrado.OpenAI * El nombre del proveedor personalizado OpenAI Inlinepuede evitar esa ruta exacta. * Si eso sucede, Codex debería recurrir al flujo de compactación local/en línea habitual en lugar de la ruta de compactación remota que está fallando. Por eso, la solución alternativa es razonable. ## ¿Es seguro? ### Seguro en el sentido de red/autenticación Sí, esta solución alternativa es segura en el sentido de que: * Todavía utiliza la autenticación de OpenAI. * No apunta a un proveedor diferente. * no agrega encabezados personalizados * No inyecta una URL de API personalizada. ### No es una solución oficial garantizada. No, esta no es una solución oficial de la versión principal. Se trata de una **solución provisional** , no de un parche confirmado para el producto. ## Lo que no cambió * tu repositorio en/Users/higordedeusmatos/Work/S/Projects/mimir * tu código fuente * tus pruebas * tu entorno shell * Comportamiento predeterminado del Codex cuando no utiliza el perfil de solución alternativa ## Cómo revertirlo Si desea deshacer la solución alternativa, elimine este bloque de ~/.codex/config.toml`: [profiles.inline_compact_workaround] model_provider = "openai_inline" [model_providers.openai_inline] name = "OpenAI Inline" requires_openai_auth = true supports_websockets = true Tras su eliminación, Codex vuelve a la configuración anterior. ## Limitaciones conocidas ### Hechos Comprobé que el archivo de configuración se sigue cargando correctamente después del cambio. He comprobado que el nuevo perfil es aceptado por la interfaz de línea de comandos (CLI). ### Desconocidos No provoqué una conversación en directo lo suficientemente larga como para activar la compactación bajo este perfil durante la validación. Por ello, el comportamiento final en tiempo de ejecución sigue siendo una prueba en el mundo real, en lugar de un resultado garantizado matemáticamente. ## Paso siguiente recomendado Correr: codex -p inline_compact_workaround resume 019d8c16-d49f-72a1-b7f9-bd7ad5410a5f Si la compactación se realiza correctamente, siga utilizando este perfil temporalmente hasta que el desarrollador publique una solución definitiva. Si el problema persiste, elimine la solución temporal y espere a que se publique un parche en Codex. ## Enlaces de referencia Informe de error del proyecto original: La compactación del contexto falla con el parámetro desconocido 'prompt_cache_retention'  #17809 [](https://github.com/openai/codex/issues/17809) Última versión de Codex: https://github.com/openai/codex/releases/tag/rust-v0.120.0 Referencia de configuración de Codex: https://developers.openai.com/codex/config-reference Guía de almacenamiento en caché de indicaciones de OpenAI: https://developers.openai.com/api/docs/guides/prompt-caching

WORKING

etraut-openai contributor · 3 months ago

We rolled back the change that caused this regression, so this should be addressed now. Apologies for the inconvenience.

codinghasnat · 3 months ago

Okay they said its fixed, by my tokens for this 5h sprint are all eaten now ahaha

David-D-Com · 3 months ago
We rolled back the change that caused this regression, so this should be addressed now. Apologies for the inconvenience.

I'm curious, what was the change?