Skip to content

Add a per-thread context-window profile selector #40429

Open

Description

@dividend3-prog

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

Activity

  1. added
    enhancement
    CLI
    app
    context
    session
    on Aug 24, 2026
  2. github-actions commented on Aug 24, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. diogovalada commented on Sep 7, 2026

    @diogovalada

    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.

  4. Kroschinsky commented on Sep 14, 2026

    @Kroschinsky

    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.

  5. Fallet666 commented on Oct 13, 2026

    @Fallet666

    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.

  6. Fandy-ust commented on Oct 18, 2026

    @Fandy-ust

    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.

  7. ropepop commented on Nov 17, 2026

    @ropepop

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIappcontextenhancementsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions