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
refactor(subagent_host): remove legacy terminal support
Steven Enamakelbb6c9dbf0a3e
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/legacy_terminal.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/legacy_terminal.rsdeleted file mode 100644index 479d230cc4..0000000000--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/legacy_terminal.rs+++ /dev/null@@ -1,15 +0,0 @@-//! Read retired owner terminal formats through the owner's compatibility port.--use super::*;--/// A native document-only task must not create file-era directories or locks.-pub(in crate::agent::subagent_host) fn owner_terminal(- checkpoint_dir: &std::path::Path,- key: &SubagentTaskKey,-) -> Result<Option<SubagentOutcome>, SubagentError> {- if !checkpoint_dir.join("lifecycle").is_dir() {- return Ok(None);- }- tinyagents_orchestration::subagent::FileSubagentPersistence::new(checkpoint_dir)- .terminal_outcome(key)-}diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rsindex 6374be4362..d5fafb66cf 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/persistence.rs@@ -1,8 +1,6 @@use super::*;use crate::agent::subagent_host::types::SubagentCheckpointData;-#[path = "legacy_terminal.rs"]-pub(super) mod legacy_terminal;pub(in crate::agent::subagent_host) struct OpenHumanPersistence {checkpoint_dir: std::path::PathBuf,diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_storage_adoption_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_storage_adoption_tests.rsindex 3171c5886a..4c2c53ac9a 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_storage_adoption_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_storage_adoption_tests.rs@@ -150,9 +150,8 @@ fn legacy_host_kv_pause_is_converted_without_rewriting_the_source_record() {fn owner_file_pause_is_imported_and_the_original_bytes_stay_unchanged() {let workspace = tempfile::tempdir().unwrap();let key = task();- let file_store =- tinyagents_orchestration::subagent::FileSubagentPersistence::new(workspace.path());- let file = file_store.pause_path(&key).unwrap();+ let adapter = super::super::persistence::OpenHumanPersistence::new(workspace.path());+ let file = adapter.legacy_pause_path(&key);std::fs::create_dir_all(file.parent().unwrap()).unwrap();let bytes = serde_json::to_vec(&paused(&key)).unwrap();std::fs::write(&file, &bytes).unwrap();@@ -256,26 +255,24 @@ async fn a_detached_driver_keeps_its_carried_actor_for_lifecycle_reads_and_commidrop(bundle);}-async fn assert_legacy_owner_terminal(format: &str) {+async fn assert_legacy_terminal_fixture(format: &str) {use super::super::persistence::OpenHumanPersistence;let workspace = tempfile::tempdir().unwrap();let key = task();- let owner = tinyagents_orchestration::subagent::FileSubagentPersistence::new(workspace.path());let mut outcome = SubagentOutcome::cancelled(&key.task_id);outcome.output = "legacy terminal".into();- owner.record_terminal(&key, &outcome, None).await.unwrap();- let file = std::fs::read_dir(workspace.path().join("lifecycle"))- .unwrap()- .map(|entry| entry.unwrap().path())- .find(|path| {- path.file_name()- .unwrap()- .to_string_lossy()- .ends_with(".terminal.json")- })- .unwrap();- let mut record: serde_json::Value =- serde_json::from_slice(&std::fs::read(&file).unwrap()).unwrap();+ let file = workspace+ .path()+ .join("lifecycle")+ .join(format!("{}.terminal.json", super::key_component(&key)));+ std::fs::create_dir_all(file.parent().unwrap()).unwrap();+ let record = super::TerminalRecord {+ key: Some(key.clone()),+ outcome,+ agent_id: String::new(),+ elapsed_ms: 0,+ };+ let mut record = serde_json::to_value(record).unwrap();if format == "bare" {record = record["outcome"].clone();record["agent_id"] = serde_json::json!("legacy-owner");@@ -320,15 +317,15 @@ async fn assert_legacy_owner_terminal(format: &str) {#[tokio::test]async fn legacy_owner_terminal_key_bearing_keeps_flattened_extensions() {- assert_legacy_owner_terminal("current").await;+ assert_legacy_terminal_fixture("current").await;}#[tokio::test]async fn legacy_owner_terminal_keyless_keeps_host_metadata() {- assert_legacy_owner_terminal("keyless").await;+ assert_legacy_terminal_fixture("keyless").await;}#[tokio::test]async fn legacy_owner_terminal_bare_outcome_keeps_extensions() {- assert_legacy_owner_terminal("bare").await;+ assert_legacy_terminal_fixture("bare").await;}diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_store.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_store.rsindex 1c40df1ecb..6984525adb 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_store.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_store.rs@@ -323,15 +323,7 @@ fn import_legacy(kv: &StateKv, dir: &Path) -> anyhow::Result<()> {} else if let Some(component) = file.strip_suffix(".terminal.json") {match serde_json::from_slice::<CompatibleTerminalRecord>(&bytes) {Ok(terminal) => {- let mut terminal = TerminalRecord::from(terminal);- if let Some(key) = terminal.key.as_ref() {- if let Some(outcome) = super::persistence::legacy_terminal::owner_terminal(- dir.parent().unwrap_or(dir),- key,- )? {- terminal.outcome = outcome;- }- }+ let terminal = TerminalRecord::from(terminal);kv.update::<LifecycleRecord, ()>(&format!("record/{component}"), move |r| {if r.terminal.is_none() {r.terminal = Some(terminal.clone());diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rsindex b5aa371405..1b902e9784 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/dispatch.rs@@ -103,7 +103,7 @@ pub(in super::super) async fn run_subagent_via_graph(// the child carrier cannot disagree.let thread_id = inherited_thread_id(run_context.thread_id.clone(), thread_id);// Where this child's transcript is written: its turn tree's store.- let transcripts = super::transcript::subagent_transcripts(&run_context, &workspace_dir);+ let transcripts = super::transcript::subagent_transcripts(&run_context, &workspace_dir)?;tracing::info!(model,max_iterations,diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rsindex 87ed813698..6d142bda1a 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs@@ -56,7 +56,7 @@ pub(super) fn failed_run_history(pub(super) fn subagent_transcripts(run_context: &OpenHumanRunContext,workspace_dir: &std::path::Path,-) -> Arc<dyn TranscriptLocator> {+) -> anyhow::Result<Arc<dyn TranscriptLocator>> {subagent_transcripts_in(run_context, workspace_dir, crate::core::runtime::is_saas())}@@ -64,9 +64,9 @@ pub(super) fn subagent_transcripts_in(run_context: &OpenHumanRunContext,workspace_dir: &std::path::Path,saas: bool,-) -> Arc<dyn TranscriptLocator> {+) -> anyhow::Result<Arc<dyn TranscriptLocator>> {if let Some(transcripts) = run_context.transcripts.clone() {- return transcripts;+ return Ok(transcripts);}let core = run_context.core.as_ref().and_then(std::sync::Weak::upgrade);let fallback = run_context@@ -81,17 +81,16 @@ pub(super) fn subagent_transcripts_in("[subagent_host:graph] no turn-tree store and no carried context in SaaS mode; \transcript kept in memory only");- return tinyagents_session::port::SessionStoreProvider::for_agent(- &tinyagents_session::port::InMemorySessionStores::new(),- fallback,- )- .transcripts;+ return detached_memory_transcripts(fallback);}let key = crate::storage::sessions::agent_key_for(&crate::core::runtime::Tenant::default(),fallback,);- return crate::storage::sessions::transcripts_or_files(&key, workspace_dir);+ return Ok(crate::storage::sessions::transcripts_or_files(+ &key,+ workspace_dir,+ ));};let tenant = crate::core::runtime::Tenant::of(&core);let key = crate::storage::sessions::agent_key_for(&tenant, fallback);@@ -99,7 +98,36 @@ pub(super) fn subagent_transcripts_in(profile = tenant.profile.is_some(),"[subagent_host:graph] no turn-tree transcript store; using the carried context's");- crate::storage::sessions::transcripts_or_files_in(&core, &key, workspace_dir)+ Ok(crate::storage::sessions::transcripts_or_files_in(+ &core,+ &key,+ workspace_dir,+ ))+}++/// Creates an intentionally isolated, process-lifetime transcript store for+/// a detached SaaS task whose carried tenant context has already been dropped.+/// It never opens the installed operator/profile backend.+fn detached_memory_transcripts(+ fallback_agent: &str,+) -> anyhow::Result<Arc<dyn TranscriptLocator>> {+ let backend = crate::storage::block_on(crate::storage::open("memory"))+ .map_err(anyhow::Error::msg)?;+ let factory_backend = Arc::clone(&backend);+ let factory: tinyagents_session::port::AgentStorageFactory = Arc::new(move |agent_id| {+ let scope = crate::storage::scope_for_agent(agent_id);+ let storage = factory_backend.for_scope(&scope)?;+ Ok(tinyagents_storage_kit::ScopedStorage::new(+ storage,+ (*scope).clone(),+ ))+ });+ let provider = tinyagents_session::DriverSessionStores::new(factory)+ .map_err(anyhow::Error::msg)?;+ Ok(provider+ .try_for_agent(fallback_agent)+ .map_err(anyhow::Error::msg)?+ .transcripts)}/// Persist a sub-agent turn's raw transcript to `transcripts` underdiff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rsindex 91c080f9ce..cbc6c6a4f1 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph_tests.rs@@ -49,7 +49,7 @@ fn a_subagent_writes_to_its_turn_trees_store_else_its_contexts() {let tree = crate::storage::sessions::transcripts_or_files("tree-key", workspace.path());let mut run_context = crate::agent::tinyagents::host::OpenHumanRunContext::new();run_context.transcripts = Some(tree.clone());- let chosen = super::transcript::subagent_transcripts(&run_context, workspace.path());+ let chosen = super::transcript::subagent_transcripts(&run_context, workspace.path()).unwrap();assert!(Arc::ptr_eq(&chosen, &tree),"the root session's store is used as is"@@ -59,6 +59,7 @@ fn a_subagent_writes_to_its_turn_trees_store_else_its_contexts() {// (here unbound, desktop) tenant.let unbound = crate::agent::tinyagents::host::OpenHumanRunContext::new();let fallback = super::transcript::subagent_transcripts(&unbound, workspace.path())+ .unwrap().destination_key().expect("a workspace store names its destination");assert!(@@ -90,7 +91,8 @@ fn a_detached_subagent_uses_the_store_its_carried_context_selects() {run_context.core = Some(Arc::downgrade(&core));// No ambient context is in scope here, as on a bare `tokio::spawn`.assert!(CoreContext::current().is_none());- let chosen = super::transcript::subagent_transcripts_in(&run_context, workspace.path(), false);+ let chosen = super::transcript::subagent_transcripts_in(&run_context, workspace.path(), false)+ .unwrap();let expected = provider.for_agent(crate::storage::sessions::DEFAULT_AGENT).transcripts@@ -102,7 +104,8 @@ fn a_detached_subagent_uses_the_store_its_carried_context_selects() {fn a_saas_subagent_without_a_context_or_tree_store_is_kept_in_memory() {let workspace = tempfile::tempdir().unwrap();let unbound = crate::agent::tinyagents::host::OpenHumanRunContext::new();- let chosen = super::transcript::subagent_transcripts_in(&unbound, workspace.path(), true);+ let chosen = super::transcript::subagent_transcripts_in(&unbound, workspace.path(), true)+ .unwrap();let operator = crate::storage::sessions::transcripts_or_files(crate::storage::sessions::DEFAULT_AGENT,workspace.path(),