Skip to content

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

refactor(tokenjuice): source focus, generate and retrieve tool from tinyjuice-host

Steven Enamakel241d7152d430
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.toml
index 75347fdf81..7f6f2379b1 100644
--- a/crates/openhuman-core/Cargo.toml
+++ b/crates/openhuman-core/Cargo.toml
@@ -422,6 +422,7 @@ tinyvoice-bus = { path = "../../vendor/tinyvoice/crates/tinyvoice-bus", optional
#
# After cloning: `git submodule update --init vendor/tinyjuice`.
tinyjuice-bus = { path = "../../vendor/tinyjuice/crates/tinyjuice-bus", features = ["storage"] }
+tinyjuice-host = { path = "../../vendor/tinyjuice/crates/tinyjuice-host" }
# Transport-free vocabulary for the compiled TinyHosts provider module.
# Optional: exclusive to the default-OFF `hosting` feature.
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index caf55666f7..dc0aab1ee4 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -1,19 +1,17 @@
//! OpenHuman host adapter for the separately released TinyJuice module.
pub mod config_patch;
-pub mod focus;
-pub mod generate;
-pub mod repl_tools;
+pub use tinyjuice_host::{focus, generate};
+mod repl_tools;
pub mod savings;
pub mod schemas;
-pub mod tools;
use crate::core::runtime::DispatchCtx;
use tinyjuice_bus::names::methods;
use tinyjuice_bus::types::{AgentTokenjuiceCompression, CompressorKind};
pub use repl_tools::{is_repl_tool, repl_tools, repl_tools_for};
-pub use tools::TokenjuiceRetrieveTool;
+pub use tinyjuice_host::retrieve_tool::RetrieveToolOutputTool as TokenjuiceRetrieveTool;
use tinyjuice_bus::wire::InstallRequest;
@@ -38,6 +36,13 @@ pub fn is_recovery_tool(name: &str) -> bool {
RECOVERY_TOOL_NAMES.contains(&name)
}
+/// Build TinyJuice's retrieval adapter over the OpenHuman module lookup.
+pub fn retrieve_tool() -> TokenjuiceRetrieveTool {
+ TokenjuiceRetrieveTool::new(std::sync::Arc::new(|token, range| {
+ Box::pin(async move { retrieve(token, range).await })
+ }))
+}
+
/// Whether the `[components] juice` switch is on. Off means turns truncate
/// tool output only: no compaction, no summary, no `juice_*` / recovery tools,
/// and the module is never loaded for it.
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 487a0b1f62..ce80810b04 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -287,7 +287,7 @@ pub fn all_tools_with_runtime_and_pack_handle(
if crate::inference::tokenjuice::enabled(root_config) {
tools.push(Box::new(retrieve_tool_output_tool()));
tools.push(Box::new(
- crate::inference::tokenjuice::TokenjuiceRetrieveTool::new(),
+ crate::inference::tokenjuice::retrieve_tool(),
));
} else {
tracing::debug!("[tools::ops] juice component off; recovery tools not registered");