Skip to content

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

feat(tokenjuice): add repl_tools_for to conditionally register repl tools

Steven Enamakel48137e0604c8
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index b107e46180..4db284697e 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -12,7 +12,7 @@ pub mod types;
use tinyjuice_bus::names::methods;
-pub use repl_tools::{is_repl_tool, repl_tools, REPL_TOOL_NAMES};
+pub use repl_tools::{is_repl_tool, repl_tools, repl_tools_for, REPL_TOOL_NAMES};
pub use tools::TokenjuiceRetrieveTool;
pub use types::{AgentTokenjuiceCompression, CompressorKind, ContentKind};
diff --git a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs
index a5f585d01c..a0a40479e3 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs
@@ -84,6 +84,21 @@ pub fn repl_tools() -> Vec<Box<dyn Tool>> {
repl_tools_with(Arc::new(ModuleSource), ReplLimits::default())
}
+/// The REPL tools, or none while large results are not stored behind a handle
+/// (compaction, router, CCR or `repl_handle_enabled` off): without a handle to
+/// name there is nothing to query, and the schemas would be dead weight on
+/// every turn.
+pub fn repl_tools_for(config: &crate::config::Config) -> Vec<Box<dyn Tool>> {
+ if !super::repl_handle_active(config) {
+ return Vec::new();
+ }
+ log::debug!(
+ "[tokenjuice][repl] registering {}",
+ REPL_TOOL_NAMES.join(", ")
+ );
+ repl_tools()
+}
+
pub(crate) fn repl_tools_with(
source: Arc<dyn OriginalSource>,
limits: ReplLimits,
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 25f9d013d9..85be1dba19 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -239,9 +239,6 @@ pub fn all_tools_with_runtime(
// by byte/line range) for a `⟦tj:<hash>⟧` marker from the CCR cache.
// Supersedes `retrieve_tool_output`; both are kept live during migration.
Box::new(crate::inference::tokenjuice::TokenjuiceRetrieveTool::new()),
- // The REPL half of that recovery surface (`juice_find` / `juice_extract`
- // / `juice_summarize`) is added right after this list, and only while
- // the handle preview that names them is in effect.
// Deterministic time-expression → timestamp resolver. `current_time`
// only returns *now*, leaving the model to do epoch arithmetic by hand
// (a real incident had an agent compute "24h ago" ~10 months off, then
@@ -655,17 +652,8 @@ pub fn all_tools_with_runtime(
memory_hybrid_search, memory_store_raw_search, memory_store_raw_chunks, memory_store_kinds"
);
- // REPL tools over a stored tool result. Registered only while large results
- // are actually stored behind a handle (compaction on, router + CCR on,
- // `tokenjuice.repl_handle_enabled`): without a handle to name there is
- // nothing for them to query, and their schemas would be dead weight on
- // every turn.
- if crate::inference::tokenjuice::repl_handle_active(root_config) {
- tools.extend(crate::inference::tokenjuice::repl_tools());
- log::debug!(
- "[tools::ops][tokenjuice] registered juice_find, juice_extract, juice_summarize"
- );
- }
+ // `juice_find` / `juice_extract` / `juice_summarize`: only while a handle can name them.
+ tools.extend(crate::inference::tokenjuice::repl_tools_for(root_config));
// Presentation generation (#2778). Native-Rust engine (ppt-rs
// backed) as of the #2780-follow-up rust-engine refactor — no