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
chore: files changed crates/openhuman-core/src/agent/orchestration/background_completions.rs,crates/
Steven Enamakel0387bf3d00ec
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions.rs b/crates/openhuman-core/src/agent/orchestration/background_completions.rsindex 3a68bdde3b..99b139e938 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions.rs@@ -358,6 +358,20 @@ pub(crate) async fn record_awaiting_input(.await;}+/// Drop every workspace's router and all process-local state about them. Called+/// when the core stops (`CoreRuntime::exit_cleanup`), so the completion logs'+/// file handles close before a data reset removes their directory (Windows+/// refuses to delete an open file) and a later boot starts from the logs alone.+/// A delivery still in flight keeps its own router handle until it finishes; the+/// next record or spawn reopens the log. Returns how many routers were released.+pub(crate) fn release_all() -> usize {+ let mut st = state();+ let released = st.routers.len();+ *st = HostState::default();+ log::info!("[background_completions] released {released} router(s) on core shutdown");+ released+}+/// Where one detached child's completion lands: its workspace (which router),/// the parent session (the idle gate) and the parent chat thread (the router's/// parent key). Built once at spawn so every terminal path records the same way.diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rsindex 2aac6f044d..1c8cf5d530 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs@@ -550,3 +550,24 @@ fn the_session_cache_evicts_its_oldest_mapping_only() {"the cache is not cleared wholesale");}++#[test]+fn release_all_closes_every_router_and_the_log_stays_replayable() {+ let _guard = test_guard();+ let ws = workspace();+ let w = ws.path();+ record(w, "sess-rel", "sub-1", "kept on disk", Some("thread-rel"));++ assert!(release_all() >= 1);+ assert!(+ state().routers.get(w).is_none(),+ "the router (and its log handle) is dropped"+ );+ assert!(+ workspace_for_thread("thread-rel").is_none(),+ "process-local maps are cleared"+ );++ // The next boot finds the undelivered completion from the log alone.+ assert_eq!(recover_pending_threads(w), ["thread-rel"]);+}diff --git a/crates/openhuman-core/src/agent/orchestration/mod.rs b/crates/openhuman-core/src/agent/orchestration/mod.rsindex 9618fe8c10..04341f104b 100644--- a/crates/openhuman-core/src/agent/orchestration/mod.rs+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs@@ -44,6 +44,12 @@ pub use command_center::{all_command_center_controller_schemas, all_command_center_registered_controllers,};pub use ops::{AgentOrchestrationSession, OrchestrationError};++/// Release the background-completion logs this process holds open. The core+/// calls this on exit so a data reset can delete the workspace directory.+pub fn release_background_completion_stores() -> usize {+ background_completions::release_all()+}pub use subagent_control::{all_controller_schemas as all_subagent_control_controller_schemas,all_registered_controllers as all_subagent_control_registered_controllers,diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rsindex 26349589d1..6025443393 100644--- a/crates/openhuman-core/src/core/runtime/builder.rs+++ b/crates/openhuman-core/src/core/runtime/builder.rs@@ -774,6 +774,9 @@ impl CoreRuntime {/// to stop either: the user runs Ollama / LM Studio / MLX themselves and/// OpenHuman never spawns it.pub async fn exit_cleanup(&self) {+ // Close the per-workspace background-completion logs (still replayable+ // from disk on the next boot).+ crate::agent::orchestration::release_background_completion_stores();log::debug!("[core] shutdown: exit cleanup done (no owned local runtime to stop)");}