Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(runtime-adapter): add sub-agent session identity test

Steven Enamakel9a36d34e099d
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index 94dd7bacad..54517217a7 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -409,3 +409,32 @@ fn availability_notes_are_status_not_instructions() {
assert!(mcp_announcement_note(&[]).is_none());
assert!(skill_announcement_note(&[]).is_none());
}
+
+/// A sub-agent inherits its parent's thread id for correlation, but each spawn
+/// is genuinely its own transcript. It must therefore not claim the
+/// conversation's durable session identity, or two concurrent workers on one
+/// thread would write into the same file.
+#[test]
+fn a_subagent_thread_binding_claims_no_session_identity() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = crate::config::Config {
+ workspace_dir: tmp.path().join("workspace"),
+ action_dir: tmp.path().join("workspace"),
+ config_path: tmp.path().join("config.toml"),
+ ..crate::config::Config::default()
+ };
+ std::fs::create_dir_all(&config.workspace_dir).unwrap();
+
+ let mut root = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator").unwrap();
+ root.set_thread_id(Some("thread-1"));
+ assert_eq!(
+ root.session_id().as_deref(),
+ Some("thread-1.orchestrator"),
+ "a root chat session is addressed by its conversation"
+ );
+
+ let mut child = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator").unwrap();
+ child.session_parent_prefix = Some("1713000000_orchestrator".into());
+ child.set_thread_id(Some("thread-1"));
+ assert_eq!(child.session_id(), None);
+}
diff --git a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
index 89c6cde066..91c3c38ba8 100644
--- a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
+++ b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
@@ -362,24 +362,3 @@ async fn a_thread_binds_one_stable_session_across_cold_boots() {
);
evict(&thread_id).await;
}
-
-/// A sub-agent inherits its parent's thread for correlation, but each spawn is
-/// genuinely its own transcript, so it must not claim the conversation's
-/// session identity.
-#[test]
-fn a_subagent_does_not_take_over_the_conversations_session() {
- let tmp = tempfile::tempdir().unwrap();
- let config = test_config(&tmp);
- let mut host = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator").unwrap();
-
- host.set_thread_id(Some("thread-1"));
- assert!(host.session_id().is_some());
-
- let mut child = OpenHumanSessionHost::builder_for_agent(&config, "orchestrator")
- .unwrap()
- .session_parent_prefix(Some("1713000000_orchestrator".into()))
- .build()
- .unwrap();
- child.set_thread_id(Some("thread-1"));
- assert_eq!(child.session_id(), None);
-}