Skip to content

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

refactor(tokenjuice): wrap retrieve tool in a local compatibility type

Steven Enamakel4ffc183f8339
diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
index dc0aab1ee4..0bc44cd09a 100644
--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs
+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs
@@ -11,7 +11,53 @@ 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 tinyjuice_host::retrieve_tool::RetrieveToolOutputTool as TokenjuiceRetrieveTool;
+/// Compatibility constructor for the tool registry; execution and its
+/// declaration are owned by TinyJuice's host crate.
+pub struct TokenjuiceRetrieveTool(tinyjuice_host::retrieve_tool::RetrieveToolOutputTool);
+
+impl TokenjuiceRetrieveTool {
+ pub fn new() -> Self {
+ Self(tinyjuice_host::retrieve_tool::RetrieveToolOutputTool::new(
+ std::sync::Arc::new(|token, range| {
+ Box::pin(async move { retrieve(token, range).await })
+ }),
+ ))
+ }
+}
+
+#[async_trait::async_trait]
+impl tinytools::Tool for TokenjuiceRetrieveTool {
+ fn name(&self) -> &str {
+ tinytools::Tool::name(&self.0)
+ }
+
+ fn description(&self) -> &str {
+ tinytools::Tool::description(&self.0)
+ }
+
+ fn parameters_schema(&self) -> serde_json::Value {
+ tinytools::Tool::parameters_schema(&self.0)
+ }
+
+ fn permission_level(&self) -> tinytools::PermissionLevel {
+ tinytools::Tool::permission_level(&self.0)
+ }
+
+ fn is_concurrency_safe(&self, args: &serde_json::Value) -> bool {
+ tinytools::Tool::is_concurrency_safe(&self.0, args)
+ }
+
+ fn external_effect(&self) -> bool {
+ tinytools::Tool::external_effect(&self.0)
+ }
+
+ async fn execute(
+ &self,
+ args: serde_json::Value,
+ ) -> anyhow::Result<tinytools::ToolResult> {
+ tinytools::Tool::execute(&self.0, args).await
+ }
+}
use tinyjuice_bus::wire::InstallRequest;
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index ce80810b04..487a0b1f62 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::retrieve_tool(),
+ crate::inference::tokenjuice::TokenjuiceRetrieveTool::new(),
));
} else {
tracing::debug!("[tools::ops] juice component off; recovery tools not registered");