The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(memory): expose date hint and timeout policy fields
Steven Enamakel06d4040f13b0
diff --git a/crates/openhuman-core/src/memory/lifecycle/views.rs b/crates/openhuman-core/src/memory/lifecycle/views.rsindex e68caeaef1..8b65794a48 100644--- a/crates/openhuman-core/src/memory/lifecycle/views.rs+++ b/crates/openhuman-core/src/memory/lifecycle/views.rs@@ -71,6 +71,16 @@ pub struct PolicySetParams {/// How long a turn waits for its pack, in ms (100–30000).#[serde(default)]pub pre_turn_timeout_ms: Option<u64>,+ /// Whether to use a small model call to identify dates in each turn.+ #[serde(default)]+ pub date_hint: Option<bool>,+ /// How long compaction waits for recalled context, in milliseconds.+ #[serde(default)]+ pub compaction_timeout_ms: Option<u64>,+ /// How long queued belief builds wait for newer writes, in seconds.+ /// Must fit within chrono's supported date range when subtracted from now.+ #[serde(default)]+ pub build_delay_secs: Option<u64>,}fn within<T: PartialOrd + std::fmt::Display + Copy>(@@ -89,6 +99,22 @@ fn within<T: PartialOrd + std::fmt::Display + Copy>(/// Applies `params` to `config`; the caller persists it.pub fn apply_policy_set(config: &mut Config, params: &PolicySetParams) -> MemoryResult<()> {+ // Validate every value before changing the config. Callers may use this+ // function directly, without a persistence layer to discard partial edits.+ let budget_tokens = within("budget_tokens", params.budget_tokens, 100, 16_000)?;+ let learnings_limit = within("learnings_limit", params.learnings_limit, 0, 50)?;+ let brain_limit = within("brain_limit", params.brain_limit, 0, 50)?;+ let history_limit = within("history_limit", params.history_limit, 0, 50)?;+ let team_limit = within("team_limit", params.team_limit, 0, 50)?;+ let build_beliefs_every = within("build_beliefs_every", params.build_beliefs_every, 0, 1000)?;+ let pre_turn_timeout_ms = within(+ "pre_turn_timeout_ms",+ params.pre_turn_timeout_ms,+ 100,+ 30_000,+ )?;+ let build_delay_secs = validate_build_delay_secs(params.build_delay_secs)?;+let recall = &mut config.memory.recall;if let Some(value) = params.log_conversations {config.memory.conversations.enabled = value;@@ -96,42 +122,58 @@ pub fn apply_policy_set(config: &mut Config, params: &PolicySetParams) -> Memoryif let Some(value) = params.recall_enabled {recall.enabled = value;}- if let Some(value) = within("budget_tokens", params.budget_tokens, 100, 16_000)? {+ if let Some(value) = budget_tokens {recall.budget_tokens = value;}- for (name, value, slot) in [- (- "learnings_limit",- params.learnings_limit,- &mut recall.learnings_limit,- ),- ("brain_limit", params.brain_limit, &mut recall.brain_limit),- (- "history_limit",- params.history_limit,- &mut recall.history_limit,- ),- ("team_limit", params.team_limit, &mut recall.team_limit),- ] {- if let Some(value) = within(name, value, 0, 50)? {- *slot = value;- }+ if let Some(value) = learnings_limit {+ recall.learnings_limit = value;+ }+ if let Some(value) = brain_limit {+ recall.brain_limit = value;+ }+ if let Some(value) = history_limit {+ recall.history_limit = value;}- if let Some(value) = within("build_beliefs_every", params.build_beliefs_every, 0, 1000)? {+ if let Some(value) = team_limit {+ recall.team_limit = value;+ }+ if let Some(value) = build_beliefs_every {recall.build_beliefs_every = value;}- if let Some(value) = within(- "pre_turn_timeout_ms",- params.pre_turn_timeout_ms,- 100,- 30_000,- )? {+ if let Some(value) = pre_turn_timeout_ms {recall.pre_turn_timeout_ms = value;}+ if let Some(value) = params.date_hint {+ recall.date_hint = value;+ }+ if let Some(value) = params.compaction_timeout_ms {+ recall.compaction_timeout_ms = value;+ }+ if let Some(value) = build_delay_secs {+ recall.build_delay_secs = value;+ }tracing::info!("[memory:policy] recall policy updated");Ok(())}+fn validate_build_delay_secs(value: Option<u64>) -> MemoryResult<Option<u64>> {+ let Some(seconds) = value else {+ return Ok(None);+ };+ let delay = i64::try_from(seconds)+ .ok()+ .and_then(chrono::Duration::try_seconds);+ if delay+ .and_then(|delay| chrono::Utc::now().checked_sub_signed(delay))+ .is_none()+ {+ return Err(MemoryError::invalid(+ "build_delay_secs must fit within the supported date range",+ ));+ }+ Ok(Some(seconds))+}+/// `memory_pack_preview` params.#[derive(Debug, Clone, Default, Deserialize)]pub struct PackPreviewParams {diff --git a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs b/crates/openhuman-core/src/memory/lifecycle/views_tests.rsindex e4cb4509f8..428aa9a075 100644--- a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs+++ b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs@@ -45,6 +45,21 @@ fn the_policy_round_trips_and_refuses_out_of_range_values() {assert_eq!(view.recall.team_limit, 0);assert_eq!(view.recall.build_beliefs_every, 0);+ apply_policy_set(+ &mut config,+ &PolicySetParams {+ date_hint: Some(true),+ compaction_timeout_ms: Some(12_000),+ build_delay_secs: Some(900),+ ..PolicySetParams::default()+ },+ )+ .unwrap();+ let view = policy_view(&config);+ assert!(view.recall.date_hint);+ assert_eq!(view.recall.compaction_timeout_ms, 12_000);+ assert_eq!(view.recall.build_delay_secs, 900);+for bad in [PolicySetParams {budget_tokens: Some(10),@@ -58,19 +73,25 @@ fn the_policy_round_trips_and_refuses_out_of_range_values() {pre_turn_timeout_ms: Some(0),..PolicySetParams::default()},+ PolicySetParams {+ build_delay_secs: Some(u64::MAX),+ ..PolicySetParams::default()+ },] {let before = serde_json::to_value(&config).unwrap();let log_conversations = !config.memory.conversations.enabled;let recall_enabled = !config.memory.recall.enabled;- let result = apply_policy_set(&mut config, &PolicySetParams {- log_conversations: Some(log_conversations),- recall_enabled: Some(recall_enabled),- ..bad- });+ let result = apply_policy_set(+ &mut config,+ &PolicySetParams {+ log_conversations: Some(log_conversations),+ recall_enabled: Some(recall_enabled),+ ..bad+ },+ );assert!(matches!(result, Err(MemoryError::InvalidRequest(_))));- assert_eq!(- serde_json::to_value(&config).unwrap(),- before,+ assert!(+ serde_json::to_value(&config).unwrap() == before,"invalid policy update must be atomic");}diff --git a/crates/openhuman-core/src/memory/schemas/defs.rs b/crates/openhuman-core/src/memory/schemas/defs.rsindex 8d3e06443f..86efaebc8a 100644--- a/crates/openhuman-core/src/memory/schemas/defs.rs+++ b/crates/openhuman-core/src/memory/schemas/defs.rs@@ -236,6 +236,9 @@ pub fn schema(function: &str) -> ControllerSchema {opt("team_limit", TypeSchema::BoundedU64 { min: 0, max: 50 }, "Other agents' turns per pack; 0 leaves them out."),opt("build_beliefs_every", TypeSchema::BoundedU64 { min: 0, max: 1000 }, "Turns between belief builds; 0 turns them off."),opt("pre_turn_timeout_ms", TypeSchema::BoundedU64 { min: 100, max: 30_000 }, "How long a turn waits for its pack."),+ opt("date_hint", TypeSchema::Bool, "Use a small model call to identify dates in each turn."),+ opt("compaction_timeout_ms", TypeSchema::U64, "How long compaction waits for recalled context, in milliseconds."),+ opt("build_delay_secs", TypeSchema::U64, "How long queued belief builds wait for newer writes, in seconds; must fit within the supported date range."),],outputs: out("Same as memory_policy_get."),},diff --git a/crates/openhuman-core/src/memory/schemas_tests.rs b/crates/openhuman-core/src/memory/schemas_tests.rsindex a86954f64a..ca437e93ed 100644--- a/crates/openhuman-core/src/memory/schemas_tests.rs+++ b/crates/openhuman-core/src/memory/schemas_tests.rs@@ -76,6 +76,15 @@ fn every_spec_method_is_registered_with_its_exact_name() {}}+#[test]+fn policy_set_schema_exposes_all_recall_policy_fields() {+ let schema = schema("policy_set");+ let fields: Vec<_> = schema.inputs.iter().map(|field| field.name).collect();+ assert!(fields.contains(&"date_hint"));+ assert!(fields.contains(&"compaction_timeout_ms"));+ assert!(fields.contains(&"build_delay_secs"));+}+#[test]fn every_function_resolves_through_its_handler_entry() {let expected_handlers: [(&str, crate::core::all::ControllerHandler); 35] = [