Add an opt-in feature for subagent model context defaults (#52659)

## What changed

Add the disabled-by-default `subagent_default_context_limits` feature and expose it in the configuration schema. When enabled, shared configuration for spawning and resuming subagents clears inherited `model_context_window` and `model_auto_compact_token_limit` overrides so subagents use their model's default context window and auto-compaction threshold.

GitOrigin-RevId: 5168ae2b4fbe72c533d8c6152922a8bceb2c5cbd
This commit is contained in:
Henry Levy
2026-10-09 17:48:50 +00:00
committed by copyberry
parent 89c8759d8c
commit 8a0437ff34
3 changed files with 22 additions and 0 deletions
+8
View File
@@ -9,6 +9,7 @@ use crate::config::Config;
use crate::session::session::Session;
use crate::session::step_context::StepContext;
use crate::session::turn_context::TurnContext;
use codex_features::Feature;
use codex_models_manager::manager::RefreshStrategy;
use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;
use codex_protocol::models::BaseInstructions;
@@ -131,6 +132,13 @@ pub(crate) fn build_agent_resume_config(turn: &TurnContext) -> Result<Config, St
fn build_agent_shared_config(turn: &TurnContext) -> Result<Config, String> {
let base_config = turn.config.clone();
let mut config = (*base_config).clone();
if config
.features
.enabled(Feature::SubagentDefaultContextLimits)
{
config.model_context_window = None;
config.model_auto_compact_token_limit = None;
}
// Preserve activation for history forks without freezing the parent's model-owned prompts.
// Fresh child startup restores configured preferences from the retained snapshot.
config.token_budget = turn.configured_token_budget.clone();