Skip to content

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

fix(scope): reduce visibility of internal methods and add test module

Steven Enamakel6752e427c76b
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index bcdf458cc3..a1356d1e4a 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -231,7 +231,7 @@ impl OpenHumanTurnPrelude {
/// Takes the declarations the tinyagents session restored for this
/// thread. Called before the boundary refresh so the rebuilt surface can
/// include them.
- pub(super) fn adopt_recorded_tools(&self, recorded: Option<&ToolSnapshot>) {
+ fn adopt_recorded_tools(&self, recorded: Option<&ToolSnapshot>) {
let Some(recorded) = recorded else {
return;
};
@@ -568,7 +568,7 @@ impl OpenHumanTurnPrelude {
/// second turn loop. A revoked delegate is removed from the executable
/// source, schema, and policy together before this request is prepared.
#[cfg(test)]
- pub(super) fn synthesized_tool_names_for_test(&self) -> std::collections::HashSet<String> {
+ fn synthesized_tool_names_for_test(&self) -> std::collections::HashSet<String> {
self.tool_surface
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
@@ -576,7 +576,7 @@ impl OpenHumanTurnPrelude {
.clone()
}
- pub(super) fn refresh_delegation_tool_surface(&self) {
+ fn refresh_delegation_tool_surface(&self) {
use crate::agent::harness::definition::AgentDefinitionRegistry;
use crate::tools::agent_policy::ToolPolicyEngine;
use crate::tools::orchestrator_tools::collect_orchestrator_tools;
@@ -2095,3 +2095,7 @@ async fn load_connected_integrations(
}
}
}
+
+#[cfg(test)]
+#[path = "runtime_session_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
new file mode 100644
index 0000000000..44999defdc
--- /dev/null
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -0,0 +1,67 @@
+//! Tests for the turn prelude's tool surface across a resumed thread.
+
+use std::sync::Arc;
+
+use tinyagents_runtime::ToolSnapshot;
+use tinytools::ToolSpec;
+
+fn spec(name: &str) -> ToolSpec {
+ ToolSpec {
+ name: name.into(),
+ description: format!("{name} description"),
+ parameters: serde_json::json!({ "type": "object", "properties": {} }),
+ }
+}
+
+/// The incident this guards: a thread resumed in a fresh process (empty
+/// integrations cache) lost every Composio action, so the orchestrator's
+/// `tool_search` had nothing to find although its restored prompt told it to
+/// search for the Gmail action. The session now restores the declarations the
+/// thread was sent, and the prelude rebuilds them as executors.
+#[tokio::test]
+async fn a_resumed_orchestrator_keeps_the_integration_actions_it_was_sent() {
+ let _ = crate::agent::harness::definition::AgentDefinitionRegistry::init_global_builtins();
+ let action_dir = tempfile::tempdir().expect("tempdir");
+ let model: Arc<dyn tinyinference_llm::model::ChatModel<()>> =
+ Arc::new(tinyagents_harness::testkit::ScriptedModel::new(Vec::new()));
+ let mut host = crate::agent::SessionHostBuilder::new()
+ .chat_model(model)
+ .tools(Vec::new())
+ .action_dir(action_dir.path().to_path_buf())
+ .memory(crate::memory::test_support::noop_memory())
+ .tool_dispatcher(Box::new(tinytools_agent::dialect::XmlDialect))
+ .agent_definition_name("orchestrator")
+ .build()
+ .expect("session build");
+ host.ensure_runtime_session().expect("runtime session");
+
+ let state = host
+ .runtime_state
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner());
+ let prelude = state.prelude.as_ref().expect("prelude");
+
+ // Fresh process: no integrations known, so no actions are synthesised.
+ prelude.refresh_delegation_tool_surface();
+ assert!(!prelude
+ .synthesized_tool_names_for_test()
+ .contains("GMAIL_SEND_EMAIL"));
+
+ // Resume hands back what the thread was sent.
+ let recorded = ToolSnapshot::new(vec![
+ spec("GMAIL_SEND_EMAIL"),
+ spec("GMAIL_FETCH_EMAILS"),
+ spec("web_fetch"),
+ ])
+ .expect("snapshot");
+ prelude.adopt_recorded_tools(Some(&recorded));
+ prelude.refresh_delegation_tool_surface();
+
+ let names = prelude.synthesized_tool_names_for_test();
+ assert!(names.contains("GMAIL_SEND_EMAIL"), "{names:?}");
+ assert!(names.contains("GMAIL_FETCH_EMAILS"), "{names:?}");
+ assert!(
+ !names.contains("web_fetch"),
+ "only integration actions are rebuilt from the record"
+ );
+}