Skip to content

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

test(builder): add tests for recovery tool visibility with compaction

Steven Enamakel60443b2f01e0
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
index f6e9c9d170..d8de61606d 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
@@ -393,3 +393,46 @@ fn is_empty_tool_scope_distinguishes_the_three_states() {
.collect();
assert!(!is_empty_tool_scope(&mixed));
}
+
+#[tokio::test]
+async fn a_summarized_agent_sees_the_recovery_tool_with_compaction_off() {
+ // A summary's footer names `tinyjuice_retrieve`, and summaries run with
+ // the compaction router off (the default). The orchestrator is the agent
+ // that gets them, so it must see the tool whatever the router says.
+ use crate::agent::session_host::types::OpenHumanSessionHost;
+ use crate::inference::tokenjuice::RETRIEVE_TOOL_NAME;
+
+ let _ = crate::agent::harness::definition::AgentDefinitionRegistry::init_global_builtins();
+
+ let tmp = tempfile::TempDir::new().unwrap();
+ let mut config = test_config(&tmp);
+ config.context.compaction_enabled = false;
+ assert!(super::summarizes_tool_output("orchestrator", &config));
+ let agent = OpenHumanSessionHost::from_config_for_agent(&config, "orchestrator")
+ .expect("orchestrator is a shipped agent definition");
+ let visible = agent.visible_tool_names_for_test();
+ assert!(
+ visible.is_empty() || visible.contains(RETRIEVE_TOOL_NAME),
+ "the orchestrator's summaries point at a tool it must be able to call"
+ );
+}
+
+#[test]
+fn the_recovery_tool_joins_a_belt_only_when_something_can_point_at_it() {
+ use crate::inference::tokenjuice::RETRIEVE_TOOL_NAME;
+ let belt = || std::collections::HashSet::from(["web_fetch".to_string()]);
+
+ let mut unused = belt();
+ super::ensure_recovery_tool_visible(&mut unused, false);
+ assert!(!unused.contains(RETRIEVE_TOOL_NAME));
+
+ let mut needed = belt();
+ super::ensure_recovery_tool_visible(&mut needed, true);
+ assert!(needed.contains(RETRIEVE_TOOL_NAME));
+
+ let tmp = tempfile::TempDir::new().unwrap();
+ let mut config = test_config(&tmp);
+ assert!(!super::summarizes_tool_output("researcher", &config));
+ config.context.summarizer_payload_threshold_tokens = 0;
+ assert!(!super::summarizes_tool_output("orchestrator", &config));
+}