mirror of
https://github.com/openai/codex.git
synced 2026-05-06 06:12:59 +03:00
nit: add min values for memories (#18137)
Just add min values to some memories config fields
This commit is contained in:
@@ -31,6 +31,10 @@ pub const DEFAULT_MEMORIES_MAX_ROLLOUT_AGE_DAYS: i64 = 30;
|
||||
pub const DEFAULT_MEMORIES_MIN_ROLLOUT_IDLE_HOURS: i64 = 6;
|
||||
pub const DEFAULT_MEMORIES_MAX_RAW_MEMORIES_FOR_CONSOLIDATION: usize = 256;
|
||||
pub const DEFAULT_MEMORIES_MAX_UNUSED_DAYS: i64 = 30;
|
||||
const MIN_MEMORIES_MAX_RAW_MEMORIES_FOR_CONSOLIDATION: usize = 1;
|
||||
const MAX_MEMORIES_MAX_RAW_MEMORIES_FOR_CONSOLIDATION: usize = 4096;
|
||||
const MIN_MEMORIES_MAX_ROLLOUTS_PER_STARTUP: usize = 1;
|
||||
const MAX_MEMORIES_MAX_ROLLOUTS_PER_STARTUP: usize = 128;
|
||||
|
||||
const fn default_enabled() -> bool {
|
||||
true
|
||||
@@ -185,12 +189,14 @@ pub struct MemoriesToml {
|
||||
/// When `false`, skip injecting memory usage instructions into developer prompts.
|
||||
pub use_memories: Option<bool>,
|
||||
/// Maximum number of recent raw memories retained for global consolidation.
|
||||
#[schemars(range(min = 1, max = 4096))]
|
||||
pub max_raw_memories_for_consolidation: Option<usize>,
|
||||
/// Maximum number of days since a memory was last used before it becomes ineligible for phase 2 selection.
|
||||
pub max_unused_days: Option<i64>,
|
||||
/// Maximum age of the threads used for memories.
|
||||
pub max_rollout_age_days: Option<i64>,
|
||||
/// Maximum number of rollout candidates processed per pass.
|
||||
#[schemars(range(min = 1, max = 128))]
|
||||
pub max_rollouts_per_startup: Option<usize>,
|
||||
/// Minimum idle time between last thread activity and memory creation (hours). > 12h recommended.
|
||||
pub min_rollout_idle_hours: Option<i64>,
|
||||
@@ -244,7 +250,10 @@ impl From<MemoriesToml> for MemoriesConfig {
|
||||
max_raw_memories_for_consolidation: toml
|
||||
.max_raw_memories_for_consolidation
|
||||
.unwrap_or(defaults.max_raw_memories_for_consolidation)
|
||||
.min(4096),
|
||||
.clamp(
|
||||
MIN_MEMORIES_MAX_RAW_MEMORIES_FOR_CONSOLIDATION,
|
||||
MAX_MEMORIES_MAX_RAW_MEMORIES_FOR_CONSOLIDATION,
|
||||
),
|
||||
max_unused_days: toml
|
||||
.max_unused_days
|
||||
.unwrap_or(defaults.max_unused_days)
|
||||
@@ -256,7 +265,10 @@ impl From<MemoriesToml> for MemoriesConfig {
|
||||
max_rollouts_per_startup: toml
|
||||
.max_rollouts_per_startup
|
||||
.unwrap_or(defaults.max_rollouts_per_startup)
|
||||
.min(128),
|
||||
.clamp(
|
||||
MIN_MEMORIES_MAX_ROLLOUTS_PER_STARTUP,
|
||||
MAX_MEMORIES_MAX_ROLLOUTS_PER_STARTUP,
|
||||
),
|
||||
min_rollout_idle_hours: toml
|
||||
.min_rollout_idle_hours
|
||||
.unwrap_or(defaults.min_rollout_idle_hours)
|
||||
|
||||
@@ -41,3 +41,21 @@ fn deserialize_skill_config_with_path_selector() {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memories_config_clamps_count_limits_to_nonzero_values() {
|
||||
let config = MemoriesConfig::from(MemoriesToml {
|
||||
max_raw_memories_for_consolidation: Some(0),
|
||||
max_rollouts_per_startup: Some(0),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
config,
|
||||
MemoriesConfig {
|
||||
max_raw_memories_for_consolidation: 1,
|
||||
max_rollouts_per_startup: 1,
|
||||
..MemoriesConfig::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user