Skip to content

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

test(subagent-host): add lifecycle outcome test module

Steven Enamakeld7d663f760cc
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs
index cece350703..cc50e2a4f3 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs
@@ -123,3 +123,7 @@ pub(super) fn host_outcome_to_neutral(
..SubagentOutcome::cancelled(String::new())
}
}
+
+#[cfg(test)]
+#[path = "lifecycle_outcome_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome_tests.rs
new file mode 100644
index 0000000000..0313235028
--- /dev/null
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome_tests.rs
@@ -0,0 +1,45 @@
+use super::*;
+
+#[test]
+fn paused_outcomes_preserve_answer_choices_and_worker_resume_options() {
+ let definitions = crate::agent_registry::host_definition::AgentDefinitionRegistry::builtins_only();
+ let definition = definitions.get("orchestrator").unwrap();
+ let options = SubagentRunOptions {
+ worker_thread_id: Some("worker-thread".into()),
+ skill_filter_override: Some("docs".into()),
+ model_override: Some("worker-model".into()),
+ ..SubagentRunOptions::default()
+ };
+ let outcome = SubagentRunOutcome {
+ task_id: "paused-task".into(),
+ agent_id: definition.id.clone(),
+ output: "partial work".into(),
+ iterations: 2,
+ elapsed: std::time::Duration::from_millis(25),
+ mode: super::super::SubagentMode::Typed,
+ status: SubagentRunStatus::AwaitingUser {
+ question: "Which version?".into(),
+ options: Some(vec!["stable".into(), "preview".into()]),
+ checkpoint: None,
+ },
+ final_history: Vec::new(),
+ usage: super::super::SubagentUsage::default(),
+ artifact_paths: vec!["report.md".into()],
+ persistence_disposition:
+ tinyagents_orchestration::subagent::SubagentPersistenceDisposition::PauseInserted,
+ };
+
+ let neutral = host_outcome_to_neutral(outcome, definition, &options);
+ assert_eq!(neutral.worker_thread_id.as_deref(), Some("worker-thread"));
+ assert_eq!(neutral.model_override.as_deref(), Some("worker-model"));
+ assert_eq!(neutral.extensions["options"], serde_json::json!(["stable", "preview"]));
+ assert_eq!(neutral.extensions["artifact_paths"], serde_json::json!(["report.md"]));
+ assert_eq!(neutral.extensions["elapsed_ms"], 25);
+ let SubagentOutcomeKind::AwaitingInput(pause) = neutral.status else {
+ panic!("a paused host outcome must remain resumable");
+ };
+ assert_eq!(pause.reason, "Which version?");
+ assert_eq!(pause.resume.metadata["worker_thread_id"], "worker-thread");
+ assert_eq!(pause.resume.metadata["skill_filter_override"], "docs");
+ assert_eq!(pause.resume.metadata["model_override"], "worker-model");
+}