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(subagent-host): cover graph failure and run paths
Steven Enamakel48ce0006a72f
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph_failed_run_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph_failed_run_tests.rsindex b70d485c9c..55ace1efed 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph_failed_run_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph_failed_run_tests.rs@@ -32,6 +32,40 @@ impl ChatModel<()> for FailsOnThirdCallProvider {}}+/// Reads the transcript a sub-agent run wrote under `stem` back through the+/// store it wrote to.+fn read_stem(+ locator: &dyn tinyagents_session::transcript::TranscriptLocator,+ stem: &str,+) -> tinyagents_session::transcript::SessionTranscript {+ let seed = tinyagents_session::transcript::TranscriptMeta {+ agent_name: String::new(),+ agent_id: None,+ agent_type: None,+ dispatcher: String::new(),+ provider: None,+ model: None,+ created: String::new(),+ updated: String::new(),+ turn_count: 0,+ prefix_message_count: None,+ input_tokens: 0,+ output_tokens: 0,+ cached_input_tokens: 0,+ charged_amount_usd: 0.0,+ thread_id: None,+ task_id: None,+ session_id: None,+ parent_session_id: None,+ };+ locator+ .open_stem(stem, seed)+ .expect("open the child stem")+ .read_session()+ .expect("read the child transcript")+ .expect("the child transcript was written")+}+/// #6281: a failed sub-agent run persists only the round a provider accepted as/// structured history; the round only the rejected request carried goes into the/// failure marker as text, so a resumed sub-agent cannot replay it.@@ -46,6 +80,9 @@ async fn failed_subagent_run_keeps_its_unanswered_round_out_of_history() {let mut history = vec![TranscriptMessage::user("please echo twice")];let workspace = tempfile::TempDir::new().expect("temp workspace");let stem = "root-session__failed_run";+ let locator = crate::agent::session_store::transcripts_or_files("orchestrator", workspace.path());+ let mut run_context = crate::agent::tinyagents::host::OpenHumanRunContext::new();+ run_context.transcripts = Some(locator.clone());let result = run_subagent_via_graph(crate::agent::tinyagents::TurnModelSource::from_model(provider),@@ -63,7 +100,7 @@ async fn failed_subagent_run_keeps_its_unanswered_round_out_of_history() {"task-failed",false,None,- crate::agent::tinyagents::host::OpenHumanRunContext::new(),+ run_context,None,workspace.path().to_path_buf(),None,@@ -77,10 +114,7 @@ async fn failed_subagent_run_keeps_its_unanswered_round_out_of_history() {.await;assert!(result.is_err(), "the rejected third call fails the run");- use tinyagents_session::transcript;- let path =- transcript::resolve_keyed_transcript_path(workspace.path(), stem).expect("transcript path");- let persisted = transcript::read_transcript(&path).expect("failed run transcript");+ let persisted = read_stem(locator.as_ref(), stem);let tool_rows: Vec<&str> = persisted.messages.iter()diff --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 4213c61da9..d6b7389339 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@@ -9,9 +9,44 @@ use tinyinference_llm::tool::ToolCall;use tinytools::Tool;use tinytools::ToolResult;+/// Reads the transcript a sub-agent run wrote under `stem` back through the+/// store it wrote to.+fn read_stem(+ locator: &dyn tinyagents_session::transcript::TranscriptLocator,+ stem: &str,+) -> tinyagents_session::transcript::SessionTranscript {+ let seed = tinyagents_session::transcript::TranscriptMeta {+ agent_name: String::new(),+ agent_id: None,+ agent_type: None,+ dispatcher: String::new(),+ provider: None,+ model: None,+ created: String::new(),+ updated: String::new(),+ turn_count: 0,+ prefix_message_count: None,+ input_tokens: 0,+ output_tokens: 0,+ cached_input_tokens: 0,+ charged_amount_usd: 0.0,+ thread_id: None,+ task_id: None,+ session_id: None,+ parent_session_id: None,+ };+ locator+ .open_stem(stem, seed)+ .expect("open the child stem")+ .read_session()+ .expect("read the child transcript")+ .expect("the child transcript was written")+}+#[test]fn subagent_transcript_keeps_cumulative_spend_separate_from_unknown_last_call() {let workspace = tempfile::tempdir().unwrap();+ let locator = crate::agent::session_store::transcripts_or_files("orchestrator", workspace.path());let usage = AggregatedUsage {input_tokens: 120,output_tokens: 30,@@ -22,7 +57,7 @@ fn subagent_transcript_keeps_cumulative_spend_separate_from_unknown_last_call()},};super::transcript::persist_subagent_transcript(- workspace.path(),+ locator.as_ref(),"root__usage","worker","task",@@ -35,10 +70,7 @@ fn subagent_transcript_keeps_cumulative_spend_separate_from_unknown_last_call()"test",2,);- let root = crate::agent::session_store::transcript_root(workspace.path());- let path = tinyagents_session::transcript::resolve_keyed_transcript_path(&root, "root__usage")- .unwrap();- let transcript = tinyagents_session::transcript::read_transcript(&path).unwrap();+ let transcript = read_stem(locator.as_ref(), "root__usage");let recorded = &transcript.messages.last()@@ -149,8 +181,10 @@ fn parallel_worker_without_thread_keeps_parent_transcript_affinity() {#[tokio::test]async fn explicit_worker_thread_replaces_parent_for_model_run_and_transcript() {let workspace = tempfile::tempdir().expect("workspace");+ let locator = crate::agent::session_store::transcripts_or_files("orchestrator", workspace.path());let mut parent = crate::agent::tinyagents::host::OpenHumanRunContext::new();parent.thread_id = Some("parent-thread".to_owned());+ parent.transcripts = Some(locator.clone());let mut history = vec![TranscriptMessage::user("finish this")];run_subagent_via_graph(@@ -185,13 +219,7 @@ async fn explicit_worker_thread_replaces_parent_for_model_run_and_transcript() {.await.expect("worker run");- let path = tinyagents_session::transcript::resolve_keyed_transcript_path(- workspace.path(),- "root__worker-thread",- )- .expect("transcript path");- let persisted =- tinyagents_session::transcript::read_transcript(&path).expect("worker transcript");+ let persisted = read_stem(locator.as_ref(), "root__worker-thread");assert_eq!(persisted.meta.thread_id.as_deref(), Some("worker-thread"));assert_ne!(persisted.meta.thread_id.as_deref(), Some("parent-thread"));}