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(chat, plan_exit): add external transfer and cancellation events, wire plan exit mode flip
Steven Enamakel72087c96a18f
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.tsindex ed4e05b8dd..8ad55550d9 100644--- a/app/src/services/chatService.ts+++ b/app/src/services/chatService.ts@@ -1458,6 +1458,39 @@ export function subscribeChatEvents(listeners: ChatEventListeners): () => void {handlers.push([EVENTS.artifactFailed, cb]);}+ if (listeners.onExternalTransferPending) {+ const cb = (payload: unknown) => {+ const e = payload as ExternalTransferPendingEvent;+ chatLog(+ '%s thread_id=%s request_id=%s provider=%s',+ EVENTS.externalTransferPending,+ e.thread_id,+ e.request_id,+ e.provider+ );+ listeners.onExternalTransferPending?.(e);+ };+ socket.on(EVENTS.externalTransferPending, cb);+ handlers.push([EVENTS.externalTransferPending, cb]);+ }++ if (listeners.onCancelled) {+ const cb = (payload: unknown) => {+ const e = payload as ChatCancelledEvent;+ chatLog(+ '%s thread_id=%s request_id=%s cancel_reason=%s superseded_by=%s',+ EVENTS.cancelled,+ e.thread_id,+ e.request_id,+ e.cancel_reason,+ e.superseded_by+ );+ listeners.onCancelled?.(e);+ };+ socket.on(EVENTS.cancelled, cb);+ handlers.push([EVENTS.cancelled, cb]);+ }+if (listeners.onDone) {const cb = (payload: unknown) => {const e = payload as ChatDoneEvent;diff --git a/crates/openhuman-core/src/agent/tools/plan_exit.rs b/crates/openhuman-core/src/agent/tools/plan_exit.rsindex fe55d7f573..6b2f7e6704 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit.rs@@ -2,18 +2,20 @@//!//! Coding-harness baseline tool (issue #1205). When a plan-mode agent//! is ready to hand off to an execution-mode agent, it calls-//! `plan_exit { plan }`. The tool returns a structured marker that the-//! agent harness can recognize to transition modes; absent a harness-//! that consumes the marker, callers can still read the rendered plan-//! out of the result.+//! `plan_exit { plan }`. The tool returns a structured marker AND flips the+//! calling thread's `RunMode` (`agent::tinyagents::run_mode::set_mode`) back+//! to `Build`, so the very next tool exposure/execution check on that thread+//! sees every tool again — the actual gating lives in+//! `PlanModeMiddleware` (wired per-turn in `harness_assembly.rs`), not here;+//! this tool only flips the live handle the middleware reads.//!-//! This is intentionally a thin primitive — the actual mode switch-//! lives outside the tool. The follow-up `plan` vs `build` mode work-//! (referenced in issue #1205) will wire the harness side.+//! Threadless callers (no `ToolRunContext::thread_id`, e.g. a test double or+//! a run with no thread identity) have no per-thread mode to flip — the+//! marker is still returned so the plan text is not lost.use async_trait::async_trait;use serde_json::json;-use tinytools::{PermissionLevel, Tool, ToolResult};+use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult, ToolRunContext};/// Stable marker the harness greps for to detect a plan→build hand-off.pub const PLAN_EXIT_MARKER: &str = "[plan_exit]";@@ -63,6 +65,25 @@ impl Tool for PlanExitTool {}async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {+ self.execute_in_context(args, None).await+ }++ async fn execute_with_context(+ &self,+ args: serde_json::Value,+ _options: ToolCallOptions,+ context: Option<&dyn ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ self.execute_in_context(args, context).await+ }+}++impl PlanExitTool {+ async fn execute_in_context(+ &self,+ args: serde_json::Value,+ context: Option<&dyn ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {let plan = args.get("plan").and_then(|v| v.as_str())@@ -71,6 +92,20 @@ impl Tool for PlanExitTool {if trimmed.is_empty() {return Ok(ToolResult::error("`plan` must not be empty"));}+ if let Some(thread_id) = context.and_then(ToolRunContext::thread_id) {+ tracing::info!(+ thread_id = %thread_id,+ "[tool][plan_exit] flipping thread run mode to build"+ );+ crate::agent::tinyagents::run_mode::set_mode(+ thread_id,+ tinyagents_harness::middleware::RunMode::Build,+ );+ } else {+ tracing::debug!(+ "[tool][plan_exit] no thread id on this run context — nothing to flip"+ );+ }Ok(ToolResult::success(format!("{PLAN_EXIT_MARKER}\n{trimmed}")))