Add experimental context management activation (#42385)

## What changed

- Add the under-development `features.context_management.experimental_mode` configuration and schema.
- For eligible ChatGPT Plus, Pro, and Pro Lite sessions using the Codex backend, enable token-budget context, history notes, and the `new_context` tool when experimental context management is configured.
- Keep the feature disabled for custom providers, provider credentials, non-Codex endpoints, and temporary structured threads.

## Testing

- Cover subscription eligibility, backend restrictions, configuration resolution, token-budget guidance, and temporary-thread overrides.

GitOrigin-RevId: 19402af19c4d69e09a7cdb3687ee7d233f6a562a
This commit is contained in:
pmccrary-oai authored and copyberry committed 2026-09-02 23:37:39 +00:00
1 parent 312709252d
commit cff76fa96f
11 files changed
+236 -16

No files matched your search

+15 -5
View File
@@ -707,7 +707,11 @@ async fn load_config_resolves_token_budget_config() -> std::io::Result<()> {
for (config_toml, expected) in [
(
"[features]\ntoken_budget = true\n",
TokenBudgetConfig::default(),
Some(TokenBudgetConfig::default()),
),
(
"features.context_management.experimental_mode = true\n",
None,
),
(
r#"
@@ -720,14 +724,14 @@ guidance_message = "Preserve important state before compaction."
auto_compact_fallback_prompt = " Write notes immediately. "
auto_compact_fallback_buffer_tokens = 8000
"#,
TokenBudgetConfig {
Some(TokenBudgetConfig {
use_history_notes_extension: true,
reminder_threshold_tokens: Some(16_000),
reminder_message_template: "Custom reminder: {n_remaining} tokens.".to_string(),
guidance_message: Some("Preserve important state before compaction.".to_string()),
auto_compact_fallback_prompt: Some("Write notes immediately.".to_string()),
auto_compact_fallback_buffer_tokens: Some(8_000),
},
}),
),
] {
let codex_home = tempdir()?;
@@ -739,8 +743,14 @@ auto_compact_fallback_buffer_tokens = 8000
)
.await?;
assert!(config.features.enabled(Feature::TokenBudget));
assert_eq!(config.token_budget, Some(expected));
assert_eq!(
config.features.enabled(Feature::TokenBudget),
expected.is_some()
);
if expected.is_none() {
assert!(config.features.enabled(Feature::ContextManagement));
}
assert_eq!(config.token_budget, expected);
}
Ok(())
}
+1 -1
View File
@@ -2766,7 +2766,7 @@ fn resolve_multi_agent_v2_config(config_toml: &ConfigToml) -> MultiAgentV2Config
}
}
fn resolve_token_budget_config(
pub(crate) fn resolve_token_budget_config(
config_toml: &ConfigToml,
features: &ManagedFeatures,
) -> std::io::Result<Option<TokenBudgetConfig>> {