Skip to content

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

test(tools): wire per-call tests to the context helper

Steven Enamakel5a64b1eb982c
diff --git a/crates/openhuman-core/src/tools/per_call.rs b/crates/openhuman-core/src/tools/per_call.rs
index c57e39efa2..d23f873ffe 100644
--- a/crates/openhuman-core/src/tools/per_call.rs
+++ b/crates/openhuman-core/src/tools/per_call.rs
@@ -27,3 +27,7 @@ pub(crate) fn context(context: Option<&dyn ToolRunContext>) -> PerCallContext {
dispatch: dispatch_ctx_for_tool(context),
}
}
+
+#[cfg(test)]
+#[path = "per_call_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-core/src/tools/per_call_tests.rs b/crates/openhuman-core/src/tools/per_call_tests.rs
index 57f4bf683f..01baa02dd3 100644
--- a/crates/openhuman-core/src/tools/per_call_tests.rs
+++ b/crates/openhuman-core/src/tools/per_call_tests.rs
@@ -48,8 +48,8 @@ fn chat(thread: &str) -> ApprovalChatContext {
}
fn tool() -> PerCallTool<Probe> {
- PerCallTool::new(|chat, _ctx| Probe {
- built_for: chat.cloned(),
+ PerCallTool::new(super::context, |context| Probe {
+ built_for: context.chat,
})
}
@@ -120,10 +120,10 @@ async fn each_call_is_built_around_its_runs_dispatch_context() {
let seen: Arc<Mutex<Vec<Option<Arc<CoreContext>>>>> = Arc::default();
let sink = Arc::clone(&seen);
- let tool = PerCallTool::new(move |chat, ctx: &DispatchCtx| {
- sink.lock().unwrap().push(ctx.core().cloned());
+ let tool = PerCallTool::new(super::context, move |context| {
+ sink.lock().unwrap().push(context.dispatch.core().cloned());
Probe {
- built_for: chat.cloned(),
+ built_for: context.chat,
}
});
seen.lock().unwrap().clear();