The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(tokenjuice): add repl tool definitions for tokenjuice
Steven Enamakela10d8a6e96d1
diff --git a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rsindex 8a494cbcaa..5862027167 100644--- a/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/repl_tools.rs@@ -273,7 +273,8 @@ impl ModuleReplTool {limits: self.limits,context_token: None,scope: None,- })+ },+ ).await;Ok(match response {Ok(Ok(output)) => ToolResult::json(serde_json::to_value(output)?),@@ -293,7 +294,12 @@ impl ModuleReplTool {}/// The handle slot held a path: query the persisted artifact it names.- async fn execute_on_artifact(&self, path: String, args: Value) -> anyhow::Result<ToolResult> {+ async fn execute_on_artifact(+ &self,+ ctx: &DispatchCtx,+ path: String,+ args: Value,+ ) -> anyhow::Result<ToolResult> {let Some(dir) = self.artifacts_dir.clone() else {log::debug!("[tokenjuice][repl] {} artifact path with no workspace",@@ -301,7 +307,7 @@ impl ModuleReplTool {);return Ok(ToolResult::error(not_a_handle_message()));};- let read = crate::core::runtime::DispatchCtx::ambient().spawn_blocking(move || {+ let read = ctx.spawn_blocking(move || {read_tool_result_artifact(&dir, &path, MAX_ARTIFACT_BYTES)}).await@@ -338,18 +344,30 @@ impl Tool for ModuleReplTool {}async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {+ self.execute_with_context(args, ToolCallOptions::default(), None)+ .await+ }++ async fn execute_with_context(+ &self,+ args: Value,+ _options: ToolCallOptions,+ tool_context: Option<&dyn ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ let ctx =+ crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);let Some(raw) = args.get("handle").and_then(Value::as_str) else {return Ok(ToolResult::error("missing required argument: handle"));};let handle = match handle::classify(raw) {handle::HandleArg::Handle(handle) => handle,- handle::HandleArg::Path(path) => return self.execute_on_artifact(path, args).await,+ handle::HandleArg::Path(path) => return self.execute_on_artifact(&ctx, path, args).await,handle::HandleArg::Invalid => {log::debug!("[tokenjuice][repl] {} rejected a non-handle", self.name);return Ok(ToolResult::error(not_a_handle_message()));}};- self.run_query(QueryTarget::Handle { token: handle }, args)+ self.run_query(&ctx, QueryTarget::Handle { token: handle }, args).await}diff --git a/crates/openhuman-core/src/inference/tokenjuice/repl_tools_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/repl_tools_tests.rsindex 5bd883955f..b0f11bc49f 100644--- a/crates/openhuman-core/src/inference/tokenjuice/repl_tools_tests.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/repl_tools_tests.rs@@ -8,7 +8,7 @@ struct RecordingSource(Mutex<Vec<QueryRequest>>);#[async_trait]impl QuerySource for RecordingSource {- async fn query(&self, request: QueryRequest) -> Result<QueryResponse, String> {+ async fn query(&self, _: &DispatchCtx, request: QueryRequest) -> Result<QueryResponse, String> {self.0.lock().unwrap().push(request);Ok(Ok(ReplOutput::Text {text: "needle in the middle".into(),@@ -19,7 +19,7 @@ impl QuerySource for RecordingSource {struct FailingSource;#[async_trait]impl QuerySource for FailingSource {- async fn query(&self, _: QueryRequest) -> Result<QueryResponse, String> {+ async fn query(&self, _: &DispatchCtx, _: QueryRequest) -> Result<QueryResponse, String> {Err("module unavailable".into())}}