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
refactor(agent): wrap plan_exit tool in a local adapter
Steven Enamakelb0ed5c505592
diff --git a/crates/openhuman-core/src/agent/registration.rs b/crates/openhuman-core/src/agent/registration.rsindex 16cf097f9e..6011e0c8c5 100644--- a/crates/openhuman-core/src/agent/registration.rs+++ b/crates/openhuman-core/src/agent/registration.rs@@ -58,9 +58,7 @@ pub(crate) fn dialogue_tools(action_dir: &Path, root_config: &Config) -> Vec<Box// Interactive plan-review gate: parks the live turn on a thread-scoped// plan the user must approve before execution (Codex/Claude plan mode).Box::new(crate::plan_review::RequestPlanReviewTool::new()),- Box::new(super::tools::PlanExitTool::new(std::sync::Arc::new(- super::tools::plan_exit::mode_lookup,- ))),+ Box::new(PlanExitTool::new()),// Workflow composition: `run_workflow` runs another workflow as a// subagent and (by default) waits on its result like a function call;// `await_workflow` re-attaches to a run that outlived its inline wait.diff --git a/crates/openhuman-core/src/agent/tools.rs b/crates/openhuman-core/src/agent/tools.rsindex 7e56f7152a..6342904a7b 100644--- a/crates/openhuman-core/src/agent/tools.rs+++ b/crates/openhuman-core/src/agent/tools.rs@@ -26,6 +26,7 @@ pub(crate) mod plan_exit;// them to a disabled-error.mod todo;-pub use tinyagents_harness::tool::plan_exit::{PlanExitTool, PLAN_EXIT_MARKER};+pub use plan_exit::PlanExitTool;+pub const PLAN_EXIT_MARKER: &str = tinyagents_harness::tool::plan_exit::PLAN_EXIT_MARKER;pub use todo::TodoTool;pub(crate) use todo::TodoToolDispatch;diff --git a/crates/openhuman-core/src/agent/tools/plan_exit.rs b/crates/openhuman-core/src/agent/tools/plan_exit.rsindex df11af0096..38edccf38a 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit.rs@@ -1,10 +1,14 @@-//! OpenHuman's tenant-aware lookup for the harness-owned `plan_exit` tool.+//! OpenHuman's tenant-aware adapter for the harness-owned `plan_exit` tool.+use std::sync::{Arc, OnceLock};++use async_trait::async_trait;+use serde_json::Value;use tinyagents_harness::middleware::RunModeHandle;-use tinytools::ToolRunContext;+use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult, ToolRunContext};/// Resolve the live thread mode only when no plan review is still pending.-pub(crate) fn mode_lookup(context: &dyn ToolRunContext) -> Option<RunModeHandle> {+fn mode_lookup(context: &dyn ToolRunContext) -> Option<RunModeHandle> {let thread_id = context.thread_id()?;let dispatch_ctx =crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(Some(context));@@ -21,6 +25,63 @@ pub(crate) fn mode_lookup(context: &dyn ToolRunContext) -> Option<RunModeHandle>))}+static OWNER_TOOL: OnceLock<tinyagents_harness::tool::plan_exit::PlanExitTool> = OnceLock::new();++fn owner_tool() -> &'static tinyagents_harness::tool::plan_exit::PlanExitTool {+ OWNER_TOOL.get_or_init(|| {+ tinyagents_harness::tool::plan_exit::PlanExitTool::new(Arc::new(mode_lookup))+ })+}++/// Public unit-shaped compatibility adapter around TinyAgents' tool engine.+pub struct PlanExitTool;++impl PlanExitTool {+ pub fn new() -> Self {+ Self+ }+}++impl Default for PlanExitTool {+ fn default() -> Self {+ Self::new()+ }+}++#[async_trait]+impl Tool for PlanExitTool {+ fn name(&self) -> &str {+ owner_tool().name()+ }++ fn description(&self) -> &str {+ owner_tool().description()+ }++ fn parameters_schema(&self) -> Value {+ owner_tool().parameters_schema()+ }++ fn permission_level(&self) -> PermissionLevel {+ owner_tool().permission_level()+ }++ async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {+ owner_tool().execute(args).await+ }++ async fn execute_with_context(+ &self,+ args: Value,+ options: ToolCallOptions,+ context: Option<&dyn ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ owner_tool()+ .execute_with_context(args, options, context)+ .await+ }+}+#[cfg(test)]#[path = "plan_exit_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rsindex 4cb3efb0d6..5baa8abf98 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit_tests.rs@@ -41,7 +41,7 @@ async fn plan_exit_does_not_flip_while_a_review_is_parked() {// Let the review register as parked before racing plan_exit against it.tokio::time::sleep(std::time::Duration::from_millis(20)).await;- let tool = PlanExitTool::new(std::sync::Arc::new(super::super::plan_exit::mode_lookup));+ let tool = PlanExitTool::new();let ctx = ThreadContext(thread_id);let result = tool.execute_with_context(@@ -94,7 +94,7 @@ async fn plan_exit_does_not_flip_while_a_review_is_parked() {#[tokio::test]async fn plan_exit_emits_marker() {- let tool = PlanExitTool::new(std::sync::Arc::new(super::super::plan_exit::mode_lookup));+ let tool = PlanExitTool::new();let result = tool.execute(json!({ "plan": "1. Read X\n2. Edit Y" })).await@@ -107,14 +107,14 @@ async fn plan_exit_emits_marker() {#[tokio::test]async fn plan_exit_rejects_empty() {- let tool = PlanExitTool::new(std::sync::Arc::new(super::super::plan_exit::mode_lookup));+ let tool = PlanExitTool::new();let result = tool.execute(json!({ "plan": " " })).await.unwrap();assert!(result.is_error);}#[test]fn plan_exit_metadata() {- let tool = PlanExitTool::new(std::sync::Arc::new(super::super::plan_exit::mode_lookup));+ let tool = PlanExitTool::new();assert_eq!(tool.name(), "plan_exit");assert_eq!(tool.permission_level(), PermissionLevel::None);}