Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

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

Henry Levy8a0437ff34c9
diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json
index cb66a94270..dbf2606dd5 100644
--- a/codex-rs/core/config.schema.json
+++ b/codex-rs/core/config.schema.json
@@ -1178,6 +1178,9 @@
"step_model_switching": {
"type": "boolean"
},
+ "subagent_default_context_limits": {
+ "type": "boolean"
+ },
"system_proxy_fallback": {
"type": "boolean"
},
@@ -7472,6 +7475,9 @@
"step_model_switching": {
"type": "boolean"
},
+ "subagent_default_context_limits": {
+ "type": "boolean"
+ },
"system_proxy_fallback": {
"type": "boolean"
},
diff --git a/codex-rs/core/src/agent/child_config.rs b/codex-rs/core/src/agent/child_config.rs
index 713c4418a9..3d56d7e646 100644
--- a/codex-rs/core/src/agent/child_config.rs
+++ b/codex-rs/core/src/agent/child_config.rs
@@ -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();
diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs
index 89c19fc6f8..08451de27e 100644
--- a/codex-rs/features/src/lib.rs
+++ b/codex-rs/features/src/lib.rs
@@ -225,6 +225,8 @@ pub enum Feature {
ModelCatalogInContext,
/// Inherit client-defined dynamic tools in fresh V2 subagents.
MultiAgentV2DynamicTools,
+ /// Use each subagent model's default context window and auto-compaction threshold.
+ SubagentDefaultContextLimits,
/// Keep sampling through reasoning and commentary boundaries when agent mail arrives.
/// Pending mail is delivered at the next normal input boundary instead.
DeferMailboxPreemption,
@@ -1464,6 +1466,12 @@ pub const FEATURES: &[FeatureSpec] = &[
stage: Stage::UnderDevelopment,
default_enabled: false,
},
+ FeatureSpec {
+ id: Feature::SubagentDefaultContextLimits,
+ key: "subagent_default_context_limits",
+ stage: Stage::UnderDevelopment,
+ default_enabled: false,
+ },
FeatureSpec {
id: Feature::DeferMailboxPreemption,
key: "defer_mailbox_preemption",