mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
Rename the history notes extension config option (#39830)
## What changed Rename the token-budget configuration key and its Rust field from `use_history_notes_history` to `use_history_notes_extension`. Update the config schema, extension gating, explicit-setting detection, and tests to use the new name consistently. GitOrigin-RevId: b6a514e23f02095fcd1d35dc42eeb7394b800c77
This commit is contained in:
@@ -33,7 +33,7 @@ async fn app_server_registers_history_and_notes_tools_for_token_budget_threads()
|
||||
.with_provider_base_url(&format!("{}/backend-api/codex", server.uri()))
|
||||
.with_provider_config("supports_websockets = false\nrequires_openai_auth = true")
|
||||
.with_extra_config(
|
||||
"[features.token_budget]\nenabled = true\nuse_history_notes_history = true",
|
||||
"[features.token_budget]\nenabled = true\nuse_history_notes_extension = true",
|
||||
)
|
||||
.write(codex_home.path())?;
|
||||
write_chatgpt_auth(
|
||||
|
||||
@@ -3378,7 +3378,7 @@
|
||||
"minimum": 1.0,
|
||||
"type": "integer"
|
||||
},
|
||||
"use_history_notes_history": {
|
||||
"use_history_notes_extension": {
|
||||
"description": "Whether to expose the built-in history and notes extension.",
|
||||
"type": "boolean"
|
||||
}
|
||||
|
||||
@@ -654,7 +654,7 @@ async fn load_config_resolves_token_budget_config() -> std::io::Result<()> {
|
||||
r#"
|
||||
[features.token_budget]
|
||||
enabled = true
|
||||
use_history_notes_history = true
|
||||
use_history_notes_extension = true
|
||||
reminder_threshold_tokens = 16000
|
||||
reminder_message_template = "Custom reminder: {n_remaining} tokens."
|
||||
guidance_message = "Preserve important state before compaction."
|
||||
@@ -662,7 +662,7 @@ auto_compact_fallback_prompt = " Write notes immediately. "
|
||||
auto_compact_fallback_buffer_tokens = 8000
|
||||
"#,
|
||||
TokenBudgetConfig {
|
||||
use_history_notes_history: true,
|
||||
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()),
|
||||
|
||||
@@ -1087,7 +1087,7 @@ const AUTO_COMPACT_FALLBACK_PROMPT_MAX_BYTES: usize = 2000;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct TokenBudgetConfig {
|
||||
pub use_history_notes_history: bool,
|
||||
pub use_history_notes_extension: bool,
|
||||
pub reminder_threshold_tokens: Option<i64>,
|
||||
pub reminder_message_template: String,
|
||||
pub guidance_message: Option<String>,
|
||||
@@ -1180,7 +1180,7 @@ impl TokenBudgetConfig {
|
||||
impl Default for TokenBudgetConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
use_history_notes_history: false,
|
||||
use_history_notes_extension: false,
|
||||
reminder_threshold_tokens: None,
|
||||
reminder_message_template: DEFAULT_TOKEN_BUDGET_REMINDER_MESSAGE_TEMPLATE.to_string(),
|
||||
guidance_message: None,
|
||||
@@ -2720,8 +2720,8 @@ fn resolve_token_budget_config(
|
||||
}
|
||||
|
||||
let token_budget_config = token_budget_toml_config(config_toml.features.as_ref());
|
||||
let use_history_notes_history = token_budget_config
|
||||
.and_then(|config| config.use_history_notes_history)
|
||||
let use_history_notes_extension = token_budget_config
|
||||
.and_then(|config| config.use_history_notes_extension)
|
||||
.unwrap_or_default();
|
||||
let reminder_threshold_tokens =
|
||||
token_budget_config.and_then(|config| config.reminder_threshold_tokens);
|
||||
@@ -2740,7 +2740,7 @@ fn resolve_token_budget_config(
|
||||
token_budget_config.and_then(|config| config.auto_compact_fallback_buffer_tokens);
|
||||
|
||||
let token_budget = TokenBudgetConfig {
|
||||
use_history_notes_history,
|
||||
use_history_notes_extension,
|
||||
reminder_threshold_tokens,
|
||||
reminder_message_template,
|
||||
guidance_message,
|
||||
|
||||
@@ -16,11 +16,11 @@ pub(super) fn has_explicit_settings(config: &Config) -> bool {
|
||||
.is_some_and(|settings| {
|
||||
settings
|
||||
.keys()
|
||||
.any(|key| !matches!(key.as_str(), "enabled" | "use_history_notes_history"))
|
||||
.any(|key| !matches!(key.as_str(), "enabled" | "use_history_notes_extension"))
|
||||
})
|
||||
|| config.token_budget.as_ref().is_some_and(|token_budget| {
|
||||
let mut settings = token_budget.clone();
|
||||
settings.use_history_notes_history = false;
|
||||
settings.use_history_notes_extension = false;
|
||||
settings != TokenBudgetConfig::default()
|
||||
})
|
||||
}
|
||||
@@ -39,10 +39,10 @@ pub(super) fn apply_model_defaults(config: &mut Config, model_info: &ModelInfo)
|
||||
};
|
||||
|
||||
let token_budget = TokenBudgetConfig {
|
||||
use_history_notes_history: config
|
||||
use_history_notes_extension: config
|
||||
.token_budget
|
||||
.as_ref()
|
||||
.is_some_and(|token_budget| token_budget.use_history_notes_history),
|
||||
.is_some_and(|token_budget| token_budget.use_history_notes_extension),
|
||||
reminder_threshold_tokens: Some(model_defaults.reminder_threshold_tokens),
|
||||
reminder_message_template: model_defaults.reminder_message_template.clone(),
|
||||
guidance_message: Some(model_defaults.guidance_message.clone()),
|
||||
|
||||
@@ -294,7 +294,7 @@ async fn token_budget_uses_model_message_defaults() -> Result<()> {
|
||||
.with_pre_build_hook(|home| {
|
||||
std::fs::write(
|
||||
home.join("config.toml"),
|
||||
"[features.token_budget]\nenabled = true\nuse_history_notes_history = true\n",
|
||||
"[features.token_budget]\nenabled = true\nuse_history_notes_extension = true\n",
|
||||
)
|
||||
.expect("write token-budget configuration");
|
||||
})
|
||||
|
||||
@@ -35,7 +35,7 @@ impl HistoryNotesExtension {
|
||||
if config
|
||||
.token_budget
|
||||
.as_ref()
|
||||
.is_some_and(|token_budget| token_budget.use_history_notes_history)
|
||||
.is_some_and(|token_budget| token_budget.use_history_notes_extension)
|
||||
&& config.model_provider.is_openai()
|
||||
&& self.auth_manager.current_auth_uses_codex_backend()
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ async fn installed_extension_exposes_and_invokes_history_notes_tools() -> TestRe
|
||||
.await?;
|
||||
config.model_provider.base_url = Some(format!("{}/backend-api/codex", server.uri()));
|
||||
config.token_budget = Some(TokenBudgetConfig {
|
||||
use_history_notes_history: true,
|
||||
use_history_notes_extension: true,
|
||||
..TokenBudgetConfig::default()
|
||||
});
|
||||
|
||||
@@ -173,7 +173,7 @@ async fn history_notes_require_an_openai_provider_and_codex_backend_auth() -> Te
|
||||
.build()
|
||||
.await?;
|
||||
config.token_budget = Some(TokenBudgetConfig {
|
||||
use_history_notes_history: true,
|
||||
use_history_notes_extension: true,
|
||||
..TokenBudgetConfig::default()
|
||||
});
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ pub struct TokenBudgetConfigToml {
|
||||
pub enabled: Option<bool>,
|
||||
/// Whether to expose the built-in history and notes extension.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub use_history_notes_history: Option<bool>,
|
||||
pub use_history_notes_extension: Option<bool>,
|
||||
/// Number of tokens remaining before auto-compaction when the wrap-up reminder is emitted.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[schemars(range(min = 1))]
|
||||
|
||||
Reference in New Issue
Block a user