Skip to content

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

fix(tokenjuice): respect caller-supplied config in tests

Steven Enamakel2cce0d86edf2
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index dc2a9fe16b..bb91674dc9 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -267,7 +267,9 @@ pub async fn compact_tool_output(call: ToolOutputCompaction<'_>) -> CompactedToo
},
};
#[cfg(test)]
- let config = if crate::modules::local_artifact("tinyjuice").is_some() {
+ // Only the config loaded from disk is replaced: a caller-supplied one is
+ // what the test is asking about.
+ let config = if runtime_config.is_none() && crate::modules::local_artifact("tinyjuice").is_some() {
// The released-module regression must not inherit an operator's
// persisted compression thresholds or disabled router flags.
std::sync::Arc::new(crate::config::Config::default())
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod_repl_module_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/mod_repl_module_tests.rs
index 24889a837c..f7dc13cf77 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod_repl_module_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod_repl_module_tests.rs
@@ -1,5 +1,6 @@
//! Handle mode and the REPL tools over the real bus. Runs where CI carries the
-//! released module (`TINYJUICE_TEST_MODULE`); skipped otherwise.
+//! module (a `scripts/modules/build.mjs` build or the staged release); skipped
+//! otherwise.
use super::*;
@@ -7,11 +8,11 @@ use super::*;
/// `juice_find` reads the stored original through `Retrieve`.
#[tokio::test]
async fn a_large_result_becomes_a_handle_the_repl_tools_can_query() {
- if std::env::var_os("TINYJUICE_TEST_MODULE").is_none() {
+ if crate::modules::local_artifact("tinyjuice").is_none() {
eprintln!(
- "SKIPPED (not run, not asserted): TINYJUICE_TEST_MODULE is not set. Build \
- vendor/tinyjuice and export TINYJUICE_TEST_MODULE=<path to libtinyjuice_module>, \
- or use scripts/test-rust-with-mock.sh"
+ "SKIPPED (not run, not asserted): no tinyjuice library. Run \
+ `node scripts/modules/build.mjs tinyjuice` and set OPENHUMAN_MODULE_SOURCE_DIR \
+ and OPENHUMAN_MODULE_SOURCE=source, or use scripts/test-rust-with-mock.sh"
);
return;
}
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs
index c0364842a4..1da518b3f9 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs
@@ -135,12 +135,11 @@ async fn an_off_profile_still_discloses_a_registered_summary() {
}
/// A module disabled in configuration cannot install, even when the process
-/// also carries a `TINYJUICE_TEST_MODULE` fixture: the config check runs
+/// also carries a tinyjuice library: the config check runs
/// first. Exercises the config-driven passthrough independent of whatever
/// module happens to be installed for other tests in this binary.
#[tokio::test]
async fn a_module_disabled_in_configuration_discloses_a_wanted_summary() {
- let _lock = crate::config::TEST_ENV_LOCK.lock().await;
let mut config = crate::config::Config::default();
config.modules.enabled = false;
let fixture_aware_call = client(&config)
@@ -151,21 +150,6 @@ async fn a_module_disabled_in_configuration_discloses_a_wanted_summary() {
"a test module artifact must not override modules.enabled=false"
);
- let previous = std::env::var_os("TINYJUICE_TEST_MODULE");
- // SAFETY: serialized by TEST_ENV_LOCK; restored below for every exit path.
- unsafe { std::env::remove_var("TINYJUICE_TEST_MODULE") };
- struct RestoreEnv(Option<std::ffi::OsString>);
- impl Drop for RestoreEnv {
- fn drop(&mut self) {
- // SAFETY: still under TEST_ENV_LOCK for the guarded test's scope.
- match self.0.take() {
- Some(value) => unsafe { std::env::set_var("TINYJUICE_TEST_MODULE", value) },
- None => unsafe { std::env::remove_var("TINYJUICE_TEST_MODULE") },
- }
- }
- }
- let _restore = RestoreEnv(previous);
-
let config = std::sync::Arc::new(config);
let output = compact_tool_output(ToolOutputCompaction {