Skip to content

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

fix: correct test module paths for tokenjuice config tests

Steven Enamakel5ca859e1a25b
diff --git a/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs b/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs
index fba536a3e5..c3734c4be2 100644
--- a/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs
+++ b/crates/openhuman-core/src/config/schema/load_env_overlay_tests.rs
@@ -574,15 +574,18 @@ fn env_overlay_context_tool_result_budget_env_suppresses_legacy_migration() {
}
#[test]
-fn env_overlay_compaction_default_off_and_switch() {
- // Default is off (tokenjuice compaction cost more retrieval round trips
- // than it saved context).
- assert!(!Config::default().context.compaction_enabled);
+fn env_overlay_compaction_default_on_and_switch() {
+ // Default is on: large results become a stats line, a head and a handle
+ // the REPL tools query.
+ assert!(Config::default().context.compaction_enabled);
+ assert!(Config::default().tokenjuice.router_enabled);
+ assert!(Config::default().tokenjuice.repl_handle_enabled);
- // `OPENHUMAN_COMPACTION=0` keeps it off; `=1` turns it on.
+ // `OPENHUMAN_COMPACTION=0` opts out; `=1` keeps it on.
let mut cfg = Config::default();
cfg.apply_env_overlay_with(&HashMapEnv::new().with("OPENHUMAN_COMPACTION", "0"));
assert!(!cfg.context.compaction_enabled);
+ assert!(!crate::inference::tokenjuice::repl_handle_active(&cfg));
let mut cfg = Config::default();
cfg.apply_env_overlay_with(&HashMapEnv::new().with("OPENHUMAN_COMPACTION", "1"));
assert!(cfg.context.compaction_enabled);
diff --git a/crates/openhuman-core/src/config/schema/tokenjuice_tests.rs b/crates/openhuman-core/src/config/schema/tokenjuice_tests.rs
index c959922492..04002fa1f1 100644
--- a/crates/openhuman-core/src/config/schema/tokenjuice_tests.rs
+++ b/crates/openhuman-core/src/config/schema/tokenjuice_tests.rs
@@ -3,9 +3,12 @@ use super::*;
#[test]
fn defaults_are_sane() {
let c = TokenjuiceConfig::default();
- // The router is opt-in (see `ContextConfig::compaction_enabled`).
- assert!(!c.router_enabled);
+ // The router and the handle preview are on (see
+ // `ContextConfig::compaction_enabled`); the on-disk copy is opt-in.
+ assert!(c.router_enabled);
assert!(c.ccr_enabled);
+ assert!(c.repl_handle_enabled);
+ assert!(!c.repl_save_enabled);
assert!(c.search_enabled);
assert!(!c.ml_compression_enabled);
assert_eq!(c.ml_device, "cpu");
@@ -28,4 +31,13 @@ fn parses_from_toml() {
assert_eq!(c.ccr_ttl_secs, Some(300));
// Untouched fields keep defaults.
assert!(c.code_enabled);
+ assert!(c.repl_handle_enabled);
+}
+
+#[test]
+fn an_older_config_without_the_new_keys_gets_the_on_defaults() {
+ let c: TokenjuiceConfig = toml::from_str("ccr_min_tokens = 900").unwrap();
+ assert!(c.router_enabled);
+ assert!(c.repl_handle_enabled);
+ assert!(!c.repl_save_enabled);
}
diff --git a/crates/openhuman-core/src/inference/tokenjuice/config_patch_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/config_patch_tests.rs
index 7ab739a7f6..d3ad122d2e 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/config_patch_tests.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/config_patch_tests.rs
@@ -9,10 +9,21 @@ fn applies_only_present_fields() {
assert_eq!(cfg.ccr_min_tokens, 1200);
assert!(!cfg.search_enabled);
// Untouched fields keep defaults.
- assert!(!cfg.router_enabled);
+ assert!(cfg.router_enabled);
assert!(cfg.code_enabled);
}
+#[test]
+fn repl_switches_can_be_flipped() {
+ let mut cfg = TokenjuiceConfig::default();
+ let patch: TokenjuiceSettingsPatch =
+ serde_json::from_str(r#"{ "repl_handle_enabled": false, "repl_save_enabled": true }"#)
+ .unwrap();
+ patch.apply(&mut cfg);
+ assert!(!cfg.repl_handle_enabled);
+ assert!(cfg.repl_save_enabled);
+}
+
#[test]
fn ttl_can_be_set_and_cleared() {
let mut cfg = TokenjuiceConfig::default();