codex icon indicating copy to clipboard operation
codex copied to clipboard

Add a per-thread context-window profile selector

Open dividend3-prog opened this issue 3 months ago • 6 comments

What variant of Codex are you using?

Codex Desktop and Codex CLI with a ChatGPT subscription.

What feature would you like to see?

Please add a per-thread context-window profile selector so each Codex session can choose its own context/usage tradeoff without changing the global configuration.

For example, when creating a thread—and later from that thread's settings—users could select:

  • Efficient: smaller active context, earlier compaction, lower usage
  • Default: OpenAI's recommended profile
  • Extended: larger active context, later compaction, with a clear usage warning

The exact token counts may remain model- and plan-dependent. The important requirement is that the choice is scoped to one thread rather than applied globally.

Why per-thread scope matters

Different tasks have very different context requirements:

  • A small coding fix benefits from an efficient profile.
  • A long research, debugging, or architecture task may need the extended profile.
  • Running several threads at once should not force every thread to use the most expensive context setting.
  • Changing a global setting should not silently alter the context behavior of existing threads.

A global-only setting makes users choose between wasting usage on small tasks and losing continuity on long tasks.

Requested behavior

  1. Add a context profile control to the new-thread UI.
  2. Allow the profile to be changed from an existing thread's settings.
  3. Persist the selected profile in thread/session metadata.
  4. Show the effective token window and auto-compaction threshold before confirmation.
  5. Warn that a larger profile may consume subscription usage faster.
  6. Keep existing threads pinned to their selected profile unless the user changes it.
  7. Expose an equivalent CLI option, for example:
    codex --context-profile efficient
    codex --context-profile default
    codex --context-profile extended
    
  8. If a selected profile is unavailable for the current model or plan, explain why and fall back explicitly rather than silently.

Expected result

Users can optimize context and usage per task while preserving predictable behavior across concurrent and existing sessions.

Related issues

  • #34619 requests restoration of GPT-5.6 Sol's 372k profile or an opt-in setting. This request is broader and specifically asks for a general, persistent per-thread selector across supported models and profiles.
  • #32803 and #32806 discuss context-profile reductions and their impact.

dividend3-prog avatar Aug 24 '26 16:08 dividend3-prog

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #40377

Powered by Codex Action

github-actions[bot] avatar Aug 24 '26 16:08 github-actions[bot]

Please extend the per-thread context profile to spawned agent threads. The spawn operation should optionally accept a context profile/window and auto-compaction threshold. I suppose defaulting to inheritance from the parent or selected custom-agent profile is the path of least surprise? The sub-agent UI/status should show the effective choice, just as it shows the model and reasoning effort.

diogovalada avatar Sep 07 '26 14:09 diogovalada

This is exactly the kind of control I would like to see in the session/thread UI.

A simple selector next to Model / Reasoning would make the intended workflow very clear, for example:

  • Default (~270K): small fixes and normal implementation work
  • Extended (~500K): larger investigations/debugging sessions
  • Maximum (~1M, when supported): document-heavy work, repo-wide reviews, architecture/research, long-running sessions

The key point is that context size is a workload decision, not really a global user preference. I may have several Codex sessions running at once, and only one of them needs the expensive/large context window. Changing config.toml globally is therefore the wrong granularity.

Ideally this could be selected when creating a thread and also increased later from the thread settings without restarting/forking the session. Showing the effective model-supported size (and any usage/cost warning) would be enough to keep the UX safe.

Kroschinsky avatar Sep 14 '26 02:09 Kroschinsky

I work primarily in the Codex desktop UI and need to choose the context budget per chat based on task complexity: a smaller/earlier-compaction profile for routine, bounded changes, and a larger profile for complex debugging or research. Editing global config.toml or launching separate CLI profiles does not fit this workflow.

A profile picker alongside Model/Reasoning in the composer or thread settings—showing the effective model-supported context window and compaction threshold, and available both when creating a chat and later in an existing chat—would make this practical.

Fallet666 avatar Oct 13 '26 12:10 Fallet666

Adding concrete implementation experience from a per-chat context controller I maintain, which now shares one core across Mac and Windows. The use case here matches ours: choose context and compaction behavior for one chat without changing every other chat's settings.

The most useful upstream contract would be a per-thread usable context window and compaction threshold, exposed consistently through the Desktop UI and app-server. Some details from our implementation:

  1. Express the user's choice in usable tokens. Convert centrally using the selected model's effective-window percentage and supported maximum. For example, our fixture maps a requested 400,000 usable tokens at 95% to a raw window of 421,053, which reads back as exactly 400,000. Conversion and validation.
  2. Separate saved, queued, applied and confirmed states. A running turn keeps its current settings; a requested change is handled between turns. A saved target should only become confirmed after matching runtime readback. Cached usage should remain visibly distinct from a live observation. Confirmation rules.
  3. Preserve per-chat ownership. Global defaults affect future chats. A fork receives an independent snapshot of its parent's budget; later parent changes do not overwrite it. Concurrent edits carry an expected revision so an older window cannot silently overwrite newer settings. Fork inheritance and API regression coverage.
  4. Make capacity constraints explicit. Validate retained content, next-turn reserve, available model metadata and compaction bounds before applying a smaller budget. Show unavailable settings and pending transitions clearly.

Explicit request: freely resize the context of an existing chat

The control should support custom numeric values, not only preset profiles, and let the user increase or decrease the context window repeatedly throughout the same chat, within the model/plan's supported range.

  • Apply the change to the existing thread without requiring a new chat, a fork, or an application restart.
  • If a turn is generating, queue the requested value and apply it safely between turns; show the pending and effective values separately.
  • Preserve the thread's history, instructions, tools, permissions and other settings during the change.
  • Before shrinking, account for current usage and the required reserve. If the target cannot fit, explain whether compaction or a larger target is required rather than silently discarding history or reporting success.
  • Let the user adjust the compaction threshold alongside the window, validate their relationship, and confirm the effective values after runtime readback.

This is a request for in-place, per-chat adjustment at any time, with explicit bounds and state feedback.

Our optional 920K mode is an experimental local catalog/configuration override. Its 920K visible ceiling, 904K maximum compaction threshold and minimum 16K reserve are our application's choices, not proof that every model, plan or server route officially supports that capacity. The upstream feature should use authoritative model/plan capabilities rather than hardcode 920K globally.

Shared JS/Swift budget fixtures and the successful dual-platform validation run make the controller behavior inspectable. These checks cover our implementation and synthetic scenarios; they do not establish universal server-side long-context support or real Windows Desktop/Computer Use acceptance.

A native profile picker backed by a stable per-thread app-server operation would make these settings much easier to maintain across Codex updates. Flexible window selection and the accounting bug in #53913 should be handled independently: increasing a budget does not correct an inflated compaction counter.

Fandy-ust avatar Oct 18 '26 11:10 Fandy-ust

I'd like the live-update requirement to be explicit: context size should be adjustable within an existing chat, with custom numeric values as well as any presets, and changes should apply automatically without restarting Codex, forking, or creating a new chat.

In addition to the controls already discussed here, please cover edits to the relevant configuration:

  • Apply a valid context-window/compaction-threshold change before the next safe model request, including between requests in an ongoing agent/tool loop. Do not interrupt an in-flight response.
  • Distinguish sessions following configuration defaults from sessions with an explicit override. Reload defaults for the former without silently overwriting the latter.
  • Show the pending and actually effective values; a successful save alone should not be reported as a successful runtime update.
  • Validate against the model's supported capacity. If shrinking requires compaction, handle that explicitly before continuing rather than silently dropping history.

A useful acceptance check would be changing the setting both while a chat is idle and during a multi-step run, then confirming the next eligible request uses the new limit.

Related subagent requests: #49195 for defaults and #45164 for per-role overrides. Those controls should remain independently scoped.

ropepop avatar Nov 17 '26 02:11 ropepop