openai / openai/codex

Support per-agent context-window overrides in agent roles

Open
#45,164 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

config context enhancement subagent
Dominant language
Rust
Stars
125k
Forks
19.5k
PR merge metrics
PR metrics pending

Description

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
  • #40429 requests per-thread context profiles; this request specifically concerns spawned agent-role configuration.
  • #43229 discusses context behavior in mixed-model worker trees; this request asks for a direct role-level setting.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in codex-rs/core/src/agent/role.rs, where typed role overrides currently apply model and reasoning effort but omit context-window and auto-compaction settings. Trace how role configuration becomes child configuration and how selected-model catalog/runtime maximums are enforced. Done means a role's model_context_window and model_auto_compact_token_limit affect its spawned child without exceeding those limits.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
ai-infra-agents
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.