You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make context window and auto-compaction settings model-aware #16140
@GraviyDev Hey — I know this kind of issue too well. It is very close to the agent reliability problem I’m working on.
I’m building AgaveCore, and I’d like to let a few early people use it for free while I shape it into something stronger.
It helps when a coding agent starts to drift, loses important context, or gives you an output you do not fully trust.
In practice, it works through two habits:
tell the agent to remember-progress or remember-this when something important should not be lost
use consult-brain when the current task needs more grounded feedback on what to do next
Over time, as useful journals, decisions, and failures pile up, the product should help the agent make sharper decisions and take better actions with less drift.
If this sounds relevant, reply here and I’ll send the exact steps. You can also use the email or Telegram on my profile.
Additional deterministic evidence from macOS / Codex CLI 0.145.0 with gpt-5.6-sol.
Environment
Codex CLI: 0.145.0
Surface: local CLI / TUI
Model: gpt-5.6-sol
Reasoning effort: high
Platform: macOS
A custom model_catalog_json entry declared:
context_window = 1048576
max_context_window = 1048576
effective_context_window_percent = 95
Codex therefore reported an effective window of 996147.
The built-in model cache for the same model declared 272000.
Observed behavior
Four separate tool-heavy threads failed with context_window_exceeded after the last successful request reached approximately:
364559 input tokens
369007 input tokens
369869 input tokens
371440 input tokens
The next request failed with:
Codex ran out of room in the model's context window.
Start a new thread or clear earlier history before retrying.
The affected rollouts contained no compacted or context_compacted event before failure. The client was waiting for the locally advertised ~996K threshold while the request path rejected the conversation much earlier.
This made the thread unrecoverable: even a short follow-up asking for a summary failed with the same error.
I also ran a deterministic compact smoke test using the same model and CLI, temporarily overriding the threshold to 32000:
First turn reached 37128 input tokens.
The same thread was resumed with a short second prompt.
The persisted rollout recorded both:
compacted
context_compacted
The resumed turn completed successfully.
This confirms the compact machinery itself works when the threshold is below the real request boundary. The failure is the unsafe split between configured/catalog context metadata and the actual accepted context.
Suggested fix
Treat the server/provider maximum as authoritative and clamp any custom catalog context_window to it.
Compute the effective auto-compact limit as the minimum of:
configured compact limit,
server-advertised effective context,
a safe preflight limit that reserves output/reasoning headroom.
Before sending a request, estimate the normalized prompt and trigger compaction when it cannot fit the active provider limit, even if local metadata says otherwise.
On context_window_exceeded, perform one emergency compact-and-retry before making the thread unrecoverable.
Show configured window, server-effective window, and active compact threshold separately in /status and diagnostics.
Emit a warning when model_catalog_json advertises a window larger than the selected provider accepts.
This appears to be a concrete GPT-5.6 instance of the model-aware context handling requested in this issue.
I want to enable Astra’s larger supported context window while leaving other models at their defaults. Please provide per-model context and compaction settings that automatically follow the model selected in the desktop app, without requiring separate launch profiles.
Reacted by LemonCANDY42, Hezric and Carsten Bartelt
Adding another concrete use case for Codex Desktop: I would like to opt into Astra's larger supported context window while keeping Sol, Terra, and Luna at their default window or at a smaller user-selected budget (for example, around 256K).
The request is for per-model overrides for both model_context_window and model_auto_compact_token_limit that automatically follow the model selected in the app, including when switching models in an existing task. This should not require restarting with a different CLI profile or editing global configuration each time.
A lower per-model budget should be allowed even when several models advertise the same maximum: users may prefer different context sizes for task quality, latency, and usage. Merely clamping every model to its maximum does not address that preference.
Expected behavior:
Astra can use its larger supported window, within the actual provider limit.
Other models retain their own defaults or explicitly configured smaller budgets.
Switching models updates the effective window and compaction threshold together, and the UI shows the active values.
If existing history exceeds the newly selected model's budget, Codex handles that transition before sending the next request.
This is a configuration/UX request, not a claim that all non-Astra models have a hard quality boundary at 256K.
Activity
github-actions commentedon Mar 28, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
GraviyDev commentedon Mar 28, 2026
Related bug report: #16139
mahdikayvan commentedon May 9, 2026
@GraviyDev Hey — I know this kind of issue too well. It is very close to the agent reliability problem I’m working on.
I’m building AgaveCore, and I’d like to let a few early people use it for free while I shape it into something stronger.
It helps when a coding agent starts to drift, loses important context, or gives you an output you do not fully trust.
In practice, it works through two habits:
remember-progressorremember-thiswhen something important should not be lostconsult-brainwhen the current task needs more grounded feedback on what to do nextOver time, as useful journals, decisions, and failures pile up, the product should help the agent make sharper decisions and take better actions with less drift.
If this sounds relevant, reply here and I’ll send the exact steps. You can also use the email or Telegram on my profile.
Cheers,
Mads.
chigkim commentedon May 16, 2026
I'm using local model, and I can only afford 64k context window.
I set model_context_window inside profile like this:
Then if I run /status, I get this:
│ Context window: 86% left (45.9K used / 258K) │
How can I set the context window for the profile properly?
Thanks!
chigkim commentedon May 16, 2026
Nevermind, I asked Codex to look codex repo, and it said model_context_window is top level config.
It worked if I set it on the top!
kinzirva commentedon Jul 28, 2026
Additional deterministic evidence from macOS / Codex CLI 0.145.0 with
gpt-5.6-sol.Environment
0.145.0gpt-5.6-solhighmodel_catalog_jsonentry declared:context_window = 1048576max_context_window = 1048576effective_context_window_percent = 95996147.272000.Observed behavior
Four separate tool-heavy threads failed with
context_window_exceededafter the last successful request reached approximately:364559input tokens369007input tokens369869input tokens371440input tokensThe next request failed with:
The affected rollouts contained no
compactedorcontext_compactedevent before failure. The client was waiting for the locally advertised ~996K threshold while the request path rejected the conversation much earlier.This made the thread unrecoverable: even a short follow-up asking for a summary failed with the same error.
Workaround and compact smoke test
A safe local workaround was:
I also ran a deterministic compact smoke test using the same model and CLI, temporarily overriding the threshold to
32000:37128input tokens.compactedcontext_compactedThis confirms the compact machinery itself works when the threshold is below the real request boundary. The failure is the unsafe split between configured/catalog context metadata and the actual accepted context.
Suggested fix
context_windowto it.context_window_exceeded, perform one emergency compact-and-retry before making the thread unrecoverable./statusand diagnostics.model_catalog_jsonadvertises a window larger than the selected provider accepts.This appears to be a concrete GPT-5.6 instance of the model-aware context handling requested in this issue.
SlipstreamAI commentedon Sep 5, 2026
I want to enable Astra’s larger supported context window while leaving other models at their defaults. Please provide per-model context and compaction settings that automatically follow the model selected in the desktop app, without requiring separate launch profiles.
Mrchen116 commentedon Sep 7, 2026
Adding another concrete use case for Codex Desktop: I would like to opt into Astra's larger supported context window while keeping Sol, Terra, and Luna at their default window or at a smaller user-selected budget (for example, around 256K).
The request is for per-model overrides for both
model_context_windowandmodel_auto_compact_token_limitthat automatically follow the model selected in the app, including when switching models in an existing task. This should not require restarting with a different CLI profile or editing global configuration each time.A lower per-model budget should be allowed even when several models advertise the same maximum: users may prefer different context sizes for task quality, latency, and usage. Merely clamping every model to its maximum does not address that preference.
Expected behavior:
This is a configuration/UX request, not a claim that all non-Astra models have a hard quality boundary at 256K.