Skip to content

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

test(embed): restore tools after withheld turn

Steven Enamakelbe982f35d694
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
index fc2df3ecf3..415d7dadce 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
@@ -80,26 +80,44 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {
let host: crate::agent::HostTools = {
let normally_visible = normally_visible.clone();
- Arc::new(move |_| crate::agent::HostTurnTools {
- withheld: std::collections::HashSet::from([normally_visible.clone()]),
+ Arc::new(move |turn| crate::agent::HostTurnTools {
+ withheld: match turn.session_id() {
+ Some("hidden-turn") => std::collections::HashSet::from([normally_visible.clone()]),
+ _ => std::collections::HashSet::new(),
+ },
..Default::default()
})
};
- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ let hidden_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
&config,
&definition(),
&host,
- None,
+ Some("hidden-turn"),
)
.expect("build a session with a per-turn withheld name");
assert!(
- !agent
+ !hidden_turn
.visible_tool_specs_arc()
.iter()
.any(|spec| spec.name == normally_visible),
"a per-turn host withholding must remove a config-derived tool from the provider view"
);
+
+ let visible_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &config,
+ &definition(),
+ &host,
+ Some("visible-turn"),
+ )
+ .expect("build the next session without the temporary withholding");
+ assert!(
+ visible_turn
+ .visible_tool_specs_arc()
+ .iter()
+ .any(|spec| spec.name == normally_visible),
+ "a withholding for one turn must not alter the agent's next provider view"
+ );
}
/// Without this the seam would be a belt, not a factory, and a host whose