Skip to content

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

fix(agent): preserve run context across host adapter calls

Steven Enamakel03a4be118fd8
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 791f3a015c..44a000af1d 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
@@ -39,6 +39,21 @@ fn transcript_suppression_is_applied_before_resume() {
assert!(state.active_turn_overrides.suppress_tools);
}
+#[test]
+fn a_response_shape_applies_to_exactly_the_next_turn() {
+ use tinyagents_harness::middleware::{ResponseShape, ResponseShapeScope};
+ let mut state = OpenHumanSessionState::default();
+ let scope = ResponseShapeScope::new(ResponseShape::default());
+ state.pending_response_shape = Some(Arc::clone(&scope));
+
+ let first = state.take_turn_inputs();
+ assert!(first
+ .response_shape
+ .as_ref()
+ .is_some_and(|taken| Arc::ptr_eq(taken, &scope)));
+ assert!(state.take_turn_inputs().response_shape.is_none());
+}
+
#[async_trait]
impl SessionDriver<OpenHumanRunContext> for RecordingDriver {
async fn execute(
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
index d7760d36bc..f563962270 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
@@ -449,3 +449,12 @@ fn task_recency_window_reaches_tools_as_a_host_extension_not_a_task_local() {
// Direct dispatch (no run context) is unrestricted.
assert_eq!(task_recency_window_for_tool(None), None);
}
+
+#[test]
+fn a_response_shape_belongs_to_the_root_turn_and_is_not_inherited() {
+ use tinyagents_harness::middleware::{ResponseShape, ResponseShapeScope};
+ let mut root = OpenHumanRunContext::new();
+ root.response_shape = Some(ResponseShapeScope::new(ResponseShape::default()));
+ assert!(root.child().response_shape.is_none());
+ assert!(root.response_shape.is_some());
+}