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
test(profiles): add host profile and session import tests
Steven Enamakelade9529749ba
diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rsindex 8aafdcd552..f8fc1af08e 100644--- a/crates/openhuman-core/src/profiles/host_tests.rs+++ b/crates/openhuman-core/src/profiles/host_tests.rs@@ -182,12 +182,12 @@ async fn a_clean_reopen_does_not_recover_but_a_takeover_does() {4,"2026-10-09T00:00:00Z",);- tinyagents_session::turn_state::TurnStateStore::new(workspace.clone())+ crate::agent::session_store::default_turn_states_for(&workspace).put(&state).unwrap();};let lifecycle = |thread: &str| {- tinyagents_session::turn_state::TurnStateStore::new(workspace.clone())+ crate::agent::session_store::default_turn_states_for(&workspace).get(thread).unwrap().unwrap()diff --git a/crates/openhuman-core/src/storage/import/sessions_tests.rs b/crates/openhuman-core/src/storage/import/sessions_tests.rsindex a08ed7c57a..1afa443ee3 100644--- a/crates/openhuman-core/src/storage/import/sessions_tests.rs+++ b/crates/openhuman-core/src/storage/import/sessions_tests.rs@@ -5,7 +5,7 @@ use sha2::Digest as _;use std::collections::BTreeMap;use tempfile::TempDir;use tinyagents_session::transcript::{write_transcript, TranscriptMessage, TranscriptMeta};-use tinyagents_session::turn_state::{TurnState, TurnStateStore};+use tinyagents_session::turn_state::TurnState;fn workspace() -> (TempDir, Config) {let dir = TempDir::new().unwrap();@@ -79,14 +79,20 @@ fn legacy_workspace(config: &Config) {).unwrap();- TurnStateStore::new(config.workspace_dir.clone())- .put(&TurnState::started(- "thread-1",- "req-1",- 4,- "2026-01-01T00:00:00Z",- ))- .unwrap();+ // The classic file layout: turn_states/<hex(thread)>/<hex(request)>.json.+ let snapshot = TurnState::started("thread-1", "req-1", 4, "2026-01-01T00:00:00Z");+ let thread_dir = config+ .workspace_dir+ .join("memory")+ .join("conversations")+ .join("turn_states")+ .join(hex::encode("thread-1"));+ std::fs::create_dir_all(&thread_dir).unwrap();+ std::fs::write(+ thread_dir.join(format!("{}.json", hex::encode("req-1"))),+ serde_json::to_vec(&snapshot).unwrap(),+ )+ .unwrap();let db = config.workspace_dir.join(SESSIONS_DB);std::fs::create_dir_all(db.parent().unwrap()).unwrap();diff --git a/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs b/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rsindex 9e061a9e8f..8ea481eb1f 100644--- a/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs+++ b/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs@@ -9,9 +9,14 @@ use super::*;use crate::threads::store::{self as conversations, run_reply_message_id, ConversationMessage};use serde_json::json;use tempfile::TempDir;-use tinyagents_session::turn_state::store as turn_state_store;+use std::sync::Arc;+use tinyagents_session::port::TurnStates;use tinyagents_session::turn_state::types::TurnState;+fn store(dir: &std::path::Path) -> Arc<dyn TurnStates> {+ crate::agent::session_store::turn_states_for(dir)+}+fn turn_state(thread_id: &str, request_id: &str, started_at: &str) -> TurnState {TurnState::started(thread_id.to_string(), request_id, 25, started_at)}@@ -21,26 +26,17 @@ async fn clear_dropped_turn_states_drops_cut_turn_and_every_later_turn() {let dir = TempDir::new().expect("tempdir");let thread_id = "thread-turn-states";- turn_state_store::put(- dir.path().to_path_buf(),- &turn_state(thread_id, "req-1", "2026-09-24T00:00:00Z"),- )+ store(dir.path()).put(&turn_state(thread_id, "req-1", "2026-09-24T00:00:00Z")).expect("put turn 1");- turn_state_store::put(- dir.path().to_path_buf(),- &turn_state(thread_id, "req-2", "2026-09-24T00:01:00Z"),- )+ store(dir.path()).put(&turn_state(thread_id, "req-2", "2026-09-24T00:01:00Z")).expect("put turn 2");- turn_state_store::put(- dir.path().to_path_buf(),- &turn_state(thread_id, "req-3", "2026-09-24T00:02:00Z"),- )+ store(dir.path()).put(&turn_state(thread_id, "req-3", "2026-09-24T00:02:00Z")).expect("put turn 3");clear_dropped_turn_states(dir.path(), thread_id, "req-2").await;let remaining =- turn_state_store::list_thread(dir.path().to_path_buf(), thread_id).expect("list_thread");+ store(dir.path()).list_thread(thread_id).expect("list_thread");let remaining_ids: Vec<&str> = remaining.iter().map(|t| t.request_id.as_str()).collect();assert_eq!(remaining_ids,@@ -55,15 +51,9 @@ async fn clear_dropped_turn_states_is_best_effort_when_cut_turn_never_got_a_snaplet dir = TempDir::new().expect("tempdir");let thread_id = "thread-turn-states-missing";- turn_state_store::put(- dir.path().to_path_buf(),- &turn_state(thread_id, "req-1", "2026-09-24T00:00:00Z"),- )+ store(dir.path()).put(&turn_state(thread_id, "req-1", "2026-09-24T00:00:00Z")).expect("put turn 1");- turn_state_store::put(- dir.path().to_path_buf(),- &turn_state(thread_id, "req-3", "2026-09-24T00:02:00Z"),- )+ store(dir.path()).put(&turn_state(thread_id, "req-3", "2026-09-24T00:02:00Z")).expect("put turn 3");// "req-2" never produced a snapshot (e.g. it errored before its first@@ -72,7 +62,7 @@ async fn clear_dropped_turn_states_is_best_effort_when_cut_turn_never_got_a_snapclear_dropped_turn_states(dir.path(), thread_id, "req-2").await;let remaining =- turn_state_store::list_thread(dir.path().to_path_buf(), thread_id).expect("list_thread");+ store(dir.path()).list_thread(thread_id).expect("list_thread");let mut remaining_ids: Vec<&str> = remaining.iter().map(|t| t.request_id.as_str()).collect();remaining_ids.sort();assert_eq!(diff --git a/crates/openhuman-core/src/threads/ops_conversion_tests.rs b/crates/openhuman-core/src/threads/ops_conversion_tests.rsindex fb0fed88e9..65c52ecd70 100644--- a/crates/openhuman-core/src/threads/ops_conversion_tests.rs+++ b/crates/openhuman-core/src/threads/ops_conversion_tests.rs@@ -343,12 +343,9 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {.workspace_dir;let snapshot = TurnState::started(thread_id, "req-1", 4, "2026-01-01T00:00:00Z");- tinyagents_session::turn_state::store::put(dir.clone(), &snapshot).expect("put snapshot");- assert!(- tinyagents_session::turn_state::store::get(dir.clone(), thread_id)- .unwrap()- .is_some()- );+ let store = crate::agent::session_store::turn_states_for(&dir);+ store.put(&snapshot).expect("put snapshot");+ assert!(store.get(thread_id).unwrap().is_some());// Queue a finished background sub-agent result for this thread; deleting the// thread must discard it so it's never delivered into a dead thread.@@ -386,7 +383,7 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {}#[tokio::test]-async fn threads_purge_removes_valid_and_corrupted_turn_state_files() {+async fn threads_purge_removes_every_turn_state_snapshot() {let _env_lock = crate::config::TEST_ENV_LOCK.lock().await;let workspace = tempfile::tempdir().expect("workspace");let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());@@ -398,15 +395,11 @@ async fn threads_purge_removes_valid_and_corrupted_turn_state_files() {.workspace_dir;let snapshot = TurnState::started("thread-a", "req-1", 4, "2026-01-01T00:00:00Z");- tinyagents_session::turn_state::store::put(dir.clone(), &snapshot).expect("put snapshot");-- let turn_state_dir = dir.join("memory").join("conversations").join("turn_states");- std::fs::create_dir_all(&turn_state_dir).unwrap();- std::fs::write(- turn_state_dir.join("corrupted.json"),- "{ definitely not json",- )- .unwrap();+ let store = crate::agent::session_store::turn_states_for(&dir);+ store.put(&snapshot).expect("put snapshot");+ store+ .put(&TurnState::started("thread-b", "req-2", 4, "2026-01-01T00:00:01Z"))+ .expect("put second snapshot");// Queue background sub-agent results across sessions; a full purge must wipe// them all since no parent thread survives.@@ -437,14 +430,10 @@ async fn threads_purge_removes_valid_and_corrupted_turn_state_files() {assert!(bg::pending_for(&dir, "thread-a").is_empty());assert!(bg::pending_for(&dir, "thread-b").is_empty());- if turn_state_dir.exists() {- let remaining_json: Vec<_> = std::fs::read_dir(&turn_state_dir)- .unwrap()- .filter_map(Result::ok)- .filter(|entry| entry.path().extension().and_then(|s| s.to_str()) == Some("json"))- .collect();- assert!(remaining_json.is_empty(), "expected no snapshot json files");- }+ assert!(+ store.list().expect("list").is_empty(),+ "a purge leaves no turn snapshot behind"+ );}#[tokio::test]