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
fix(composio): handle missing tool registry gracefully
Steven Enamakelc2bcd5fb60cd
diff --git a/crates/openhuman-core/src/integrations/composio/tools/registry.rs b/crates/openhuman-core/src/integrations/composio/tools/registry.rsnew file mode 100644index 0000000000..e115bd0dbe--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/tools/registry.rs@@ -0,0 +1,52 @@+//! [`all_composio_agent_tools`]: build the full set of Composio agent+//! tools once the user is signed in (backend session or direct-mode key).++use std::sync::Arc;++use crate::tools::traits::Tool;++use super::authorize::ComposioAuthorizeTool;+use super::connect::ComposioConnectTool;+use super::execute::ComposioExecuteTool;+use super::list_connections::ComposioListConnectionsTool;+use super::list_tools::ComposioListToolsTool;+use super::list_toolkits::ComposioListToolkitsTool;++pub fn all_composio_agent_tools(config: &crate::config::Config) -> Vec<Box<dyn Tool>> {+ // Registration gate: ask the mode-aware probe "can this user call+ // composio at all?" — true when EITHER a backend session token OR a+ // stored/inline direct-mode API key is present. The pre-fix path+ // called `build_composio_client(...).is_none()`, which is+ // backend-only and silently dropped the 5 generic agent tools for+ // direct-mode users (#1710). Per-action dispatch inside each tool+ // re-resolves through the factory so the live `composio.mode`+ // toggle keeps winning.+ if !crate::agent::harness::subagent_runner::user_is_signed_in_to_composio(config) {+ tracing::debug!(+ "[composio] agent tools not registered — user is not signed in to composio \+ (no backend session and no direct API key)"+ );+ return Vec::new();+ }+ // All five tools resolve their client per call through the+ // mode-aware factory; they only need a handle to the live root+ // config to do so. Sharing one `Arc<Config>` keeps the registration+ // cheap (no repeated `Config::clone` walks) and ensures every tool+ // sees the same live snapshot.+ let config_arc = Arc::new(config.clone());+ let tools: Vec<Box<dyn Tool>> = vec![+ Box::new(ComposioListToolkitsTool::new(config_arc.clone())),+ Box::new(ComposioListConnectionsTool::new(config_arc.clone())),+ Box::new(ComposioAuthorizeTool::new(config_arc.clone())),+ // Inline-in-chat OAuth connect card (#3993). Raises an approval card+ // with a Connect button instead of handing the agent a raw URL.+ Box::new(ComposioConnectTool::new(config_arc.clone())),+ Box::new(ComposioListToolsTool::new(config_arc.clone())),+ Box::new(ComposioExecuteTool::new(config_arc)),+ // Pref-elevation is intentionally NOT an agent-callable tool;+ // the user must flip it themselves in the Connections UI.+ // See the long comment above the (removed) ComposioEnableScopeTool.+ ];+ tracing::debug!(count = tools.len(), "[composio] agent tools registered");+ tools+}diff --git a/crates/openhuman-core/src/threads/turn_state/mirror/lifecycle.rs b/crates/openhuman-core/src/threads/turn_state/mirror/lifecycle.rsnew file mode 100644index 0000000000..4ad8ba0e07--- /dev/null+++ b/crates/openhuman-core/src/threads/turn_state/mirror/lifecycle.rs@@ -0,0 +1,95 @@+//! Snapshot flush, interrupted-turn finalization, and the partial-answer+//! carry-over into the session transcript.++use super::state::TurnStateMirror;+use crate::threads::turn_state::types::TurnLifecycle;++pub(super) const MIRROR_LOG_PREFIX: &str = "[threads:turn_state:mirror]";++impl TurnStateMirror {+ /// Mark the turn as `Interrupted` on the in-memory snapshot and+ /// flush. Called when the bridge exits without a `TurnCompleted`+ /// event (i.e. the agent loop errored out).+ pub fn finish(mut self) {+ if self.turn_completed {+ return;+ }+ self.state.lifecycle = TurnLifecycle::Interrupted;+ self.state.active_tool = None;+ self.state.active_subagent = None;+ self.state.updated_at = chrono::Utc::now().to_rfc3339();+ self.flush();+ self.persist_interrupted_partial();+ }++ /// Append the partial streamed answer of an interrupted turn to the session+ /// transcript so the derived display view (Phase B) can surface it even+ /// after the live turn_state snapshot is gone. Display-only: the+ /// model-context reader skips `interrupted:true` lines.+ ///+ /// Guard: the root transcript file must already exist. An interrupted+ /// **first** turn has no session file yet (the harness has not persisted a+ /// turn), so there is nothing to append to — that case stays recoverable+ /// from the turn_state snapshot alone, as today. We log and skip it.+ fn persist_interrupted_partial(&self) {+ let partial = self.state.streaming_text.trim();+ if partial.is_empty() {+ return;+ }+ let thread_id = self.state.thread_id.trim();+ if thread_id.is_empty() {+ return;+ }+ let workspace_dir = self.store.workspace_dir();+ let Some(path) =+ crate::agent::harness::session::transcript::find_root_transcript_for_thread(+ workspace_dir,+ thread_id,+ )+ else {+ log::debug!(+ "{MIRROR_LOG_PREFIX} no root transcript for thread={thread_id} yet — leaving interrupted partial ({} chars) in turn_state snapshot only",+ partial.len()+ );+ return;+ };+ let request_id = if self.state.request_id.is_empty() {+ None+ } else {+ Some(self.state.request_id.as_str())+ };+ let thinking = self.state.thinking.trim();+ let reasoning = if thinking.is_empty() {+ None+ } else {+ Some(thinking)+ };+ match crate::agent::harness::session::transcript::append_interrupted_partial(+ &path,+ partial,+ request_id,+ Some(self.state.iteration),+ reasoning,+ ) {+ Ok(()) => log::debug!(+ "{MIRROR_LOG_PREFIX} appended interrupted partial ({} chars, thinking={} chars) for thread={thread_id} request_id={} to {}",+ partial.len(),+ thinking.len(),+ self.state.request_id,+ path.display()+ ),+ Err(err) => log::warn!(+ "{MIRROR_LOG_PREFIX} failed to append interrupted partial for thread={thread_id}: {err}"+ ),+ }+ }++ pub(super) fn flush(&mut self) {+ if let Err(err) = self.store.put(&self.state) {+ log::warn!(+ "{MIRROR_LOG_PREFIX} failed to persist snapshot for thread={}: {err}",+ self.state.thread_id+ );+ }+ }+}