Skip to content

Support per-agent context-window overrides in agent roles #45164

Open

Description

@jason3333-dev

What variant of Codex are you using?

Codex multi-agent/subagent configuration, observed with current Codex behavior and checked against the current open-source implementation.

What feature would you like to see?

Please allow an agent role to set its own model_context_window and model_auto_compact_token_limit instead of always inheriting those values from the parent session.

Example use case:

  • Primary Astra orchestrator: native/default context window
  • Luna worker: 1M requested context window

A role file can currently contain the Luna model, reasoning effort, and context settings. The model and reasoning effort are applied to the spawned child, but the context-window settings remain parent-derived.

Current implementation observation

In codex-rs/core/src/agent/role.rs, the typed role override layer applies fields such as model and reasoning effort, but does not include the context-window or auto-compaction settings. As a result, those values from the role config do not become effective child configuration.

Expected behavior

Agent roles should be able to request their own context window and auto-compaction threshold, subject to the selected model's normal catalog/runtime maximums.

This would allow context allocation to follow task shape and model cost. For example, an orchestrator can stay on its normal context window while a lower-cost implementation or debugging worker uses a larger window.

Related issues

Activity

  1. added
    enhancement
    subagent
    config
    context
    on Sep 13, 2026
  2. danghung-dev commented on Sep 23, 2026

    @danghung-dev

    +1 - This would be very useful for real multi-agent workflows.

    My main use case is exactly the one described here: keep the orchestrator on its normal/native context window, while allowing a worker model such as Luna to use a much larger context only when the task actually benefits from it.

    Without per-role overrides, context sizing is effectively coupled to the parent session, which makes it harder to optimize cost, latency, and task specialization across agents. It also means a role can select its own model and reasoning effort, but not the context policy that is often just as important for that model.

    A practical setup would be:

    • orchestrator: default/native context
    • implementation/debugging worker: large context
    • lightweight/research workers: smaller/default context
    • per-role model_auto_compact_token_limit aligned with each worker's context size
    • It would be especially helpful if model_context_window and model_auto_compact_token_limit in role TOML files were honored the same way as model and reasoning effort, while still being capped by the selected model's supported maximum.

    This would make multi-agent configuration much more flexible and avoid having to globally increase the parent context just to give one worker a larger window.

  3. ropepop commented on Nov 17, 2026

    @ropepop

    Checked the 0.169.0 source: AgentRoleOverrides and its construction still omit both context settings, even though the role file is parsed as configuration. This remains a separate gap from choosing model defaults for all children.

    A useful acceptance case would create two roles from one parent: a bounded worker requesting a 128,000-token window and compaction at 100,000, and an explorer requesting a larger supported window. Each role should receive its own effective limits, without changing the parent or the other role. Explicit role values should take precedence over any future child defaults from #49195, while staying within the selected model's supported limits.

    Please also test either key supplied alone, and report unsupported or ineffective role settings clearly rather than accepting them silently. The separate request to change an already-running session's limits is #40429; new-role defaults and live session changes should have clear, separate scope.

    These observations come from the versioned source; I have not run a fresh end-to-end reproduction.

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

    configcontextenhancementsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions