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(agent): correct tier resolution for composio integration
Steven Enamakele9fd42d0a885
diff --git a/crates/openhuman-core/src/agent/harness/definition/tier.rs b/crates/openhuman-core/src/agent/harness/definition/tier.rsindex 4101381727..3d1c86affc 100644--- a/crates/openhuman-core/src/agent/harness/definition/tier.rs+++ b/crates/openhuman-core/src/agent/harness/definition/tier.rs@@ -31,7 +31,7 @@ pub enum AgentTier {/// to one or more `Worker`s. Must NOT delegate to another/// `Reasoning` agent.Reasoning,- /// Leaf executor — code executors, critics, archivists,+ /// Leaf executor — code executors, critics, summarizers,/// integration specialists, etc. Workers do the actual work and must/// NOT spawn further subagents (a `Worker` with a non-empty/// `subagents` list is rejected by the loader).diff --git a/crates/openhuman-core/src/agent/harness/definition_tests.rs b/crates/openhuman-core/src/agent/harness/definition_tests.rsindex 4dac49de53..6e87f8821a 100644--- a/crates/openhuman-core/src/agent/harness/definition_tests.rs+++ b/crates/openhuman-core/src/agent/harness/definition_tests.rs@@ -172,7 +172,7 @@ named = ["query_memory"]/// `subagents` is optional — omitting it should yield an empty Vec/// rather than a deserialization error. Most non-delegating agents-/// (archivist, code_executor, etc.) will not list any.+/// (critic, summarizer, etc.) will not list any.#[test]fn subagents_defaults_to_empty_when_omitted() {let toml_src = r#"@@ -364,12 +364,6 @@ fn all_builtin_agent_definitions_have_expected_effective_max_iterations() {let expected: &[(&str, usize)] = &[// Extended policy (or high `max_iterations`) -> effective cap raised.("orchestrator", 15),- // #5204: general-purpose read-only flow context/memory retrieval- // agent — `iteration_policy = "extended"` so it can loop across- // several retrievals in one turn. `#[cfg(feature = "flows")]`-gated- // (like the other flow agents), so this audit entry is too.- #[cfg(feature = "flows")]- ("flow_memory_agent", 50),("planner", 50),("task_manager_agent", 50),// Gated with `flows` (#4797) — absent from a slim build.@@ -379,13 +373,9 @@ fn all_builtin_agent_definitions_have_expected_effective_max_iterations() {("workflow_builder", 50),// Strict policy, declared `max_iterations` below the old global// default (10) -> effective cap lowered.- ("agent_memory", 6),- ("archivist", 3),("critic", 5),- ("goals_agent", 5),("image_agent", 8),("morning_briefing", 8),- ("profile_memory_agent", 8),("summarizer", 1),("trigger_reactor", 6),("trigger_triage", 2),diff --git a/crates/openhuman-core/src/flows/mod.rs b/crates/openhuman-core/src/flows/mod.rsindex a30d58be8f..db9473d6c1 100644--- a/crates/openhuman-core/src/flows/mod.rs+++ b/crates/openhuman-core/src/flows/mod.rs@@ -78,6 +78,6 @@ pub use tinyflows_catalog::{// subscriber, `flows_delete` and the tinyflows `memory` node adapter reach the// same helpers through these re-exports so every caller tags identically.pub use memory_tools::{- cross_flow_filter, flow_filter, flow_key_of, flow_meta, flow_tag, forget_matching,+ cross_flow_filter, flow_filter, flow_key_of, flow_key_tag, flow_meta, flow_tag, forget_matching,remember_keyed, FLOWS_TAG,};diff --git a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rsnew file mode 100644index 0000000000..fba731c46a--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs@@ -0,0 +1,257 @@+//! Routes `ComposioConnectionCreated` events: once the connection is+//! confirmed active, refreshes the integrations cache, then (after+//! onboarding) fetches the account profile and starts an initial+//! `composio_sync` for toolkits with a native sync provider.++use std::time::Duration;++use async_trait::async_trait;+use tinybus::EventHandler;++use crate::config::rpc as config_rpc;+use crate::config::Config;+use crate::core::events::DomainEvent;+use crate::integrations::composio::client::{resolve_composio_route, ComposioRoute};+use crate::integrations::composio::module_client::{self as connectors, methods};+use crate::integrations::composio::ops;+use crate::integrations::composio::types::ComposioConnectionsResponse;+use crate::integrations::composio::FetchConnectedIntegrationsStatus;++/// How long to keep polling after `composio_authorize` returns a+/// `connectUrl`, waiting for the user to finish the hosted OAuth flow.+const CONNECTION_READY_TIMEOUT: Duration = Duration::from_secs(60);++/// Poll backoff schedule (start, max): aggressive first so the fast path+/// feels immediate, then backing off for users who still have to log in.+const CONNECTION_READY_INITIAL_BACKOFF: Duration = Duration::from_millis(500);+const CONNECTION_READY_MAX_BACKOFF: Duration = Duration::from_secs(4);++/// Reloads the live config and requires it to route through the backend+/// tenant — the readiness probe is a backend-only metadata call, and routing+/// it through the wrong tenant is worse than refusing (#1710). Reloaded rather+/// than taken from the snapshot: the OAuth completion being reacted to may+/// have written credentials since.+async fn backend_composio_config(config: &Config, toolkit: &str) -> anyhow::Result<Config> {+ let live_config = config_rpc::reload_config_from_paths(&config.config_path, &config.workspace_dir)+ .await+ .map_err(|e| anyhow::anyhow!("composio backend client: failed to reload live config: {e}"))?;+ match resolve_composio_route(&live_config)? {+ ComposioRoute::Backend => Ok(live_config),+ ComposioRoute::Direct(_) => Err(anyhow::anyhow!(+ "composio direct mode is not supported on this helper path; toolkit={toolkit}"+ )),+ }+}++/// Handles `ComposioConnectionCreated`.+pub struct ComposioConnectionCreatedSubscriber;++impl ComposioConnectionCreatedSubscriber {+ pub fn new() -> Self {+ Self+ }+}++impl Default for ComposioConnectionCreatedSubscriber {+ fn default() -> Self {+ Self::new()+ }+}++#[async_trait]+impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {+ fn name(&self) -> &str {+ "composio::connection_created"+ }++ fn domains(&self) -> Option<&[&str]> {+ Some(&["composio"])+ }++ async fn handle(&self, event: &DomainEvent) {+ let DomainEvent::ComposioConnectionCreated {+ toolkit,+ connection_id,+ connect_url: _,+ } = event+ else {+ return;+ };+ tracing::info!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ "[composio:bus] connection_created"+ );+ // The cache refresh runs for every toolkit; only the profile fetch and+ // initial sync are gated on a native provider.+ let toolkit = toolkit.clone();+ let connection_id = connection_id.clone();+ tokio::spawn(async move { on_connection_created(toolkit, connection_id).await });+ }+}++async fn on_connection_created(toolkit: String, connection_id: String) {+ let config = match config_rpc::load_config_with_timeout().await {+ Ok(c) => c,+ Err(e) => {+ tracing::warn!(+ toolkit = %toolkit,+ error = %e,+ "[composio:bus] failed to load config for connection_created dispatch"+ );+ return;+ }+ };+ if resolve_composio_route(&config).is_err() {+ tracing::debug!(+ toolkit = %toolkit,+ "[composio:bus] no composio client (not signed in?), skipping hook"+ );+ return;+ }+ let live_config = match backend_composio_config(&config, &toolkit).await {+ Ok(c) => c,+ Err(e) => {+ tracing::debug!(+ toolkit = %toolkit,+ error = %e,+ "[composio:bus] backend client unavailable for connection-readiness poll; skipping"+ );+ return;+ }+ };+ match wait_for_connection_active(&live_config, &connection_id).await {+ Ok(status) => {+ tracing::info!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ status = %status,+ "[composio:bus] connection observed active; invalidating + eagerly warming integrations cache"+ );+ ops::invalidate_connected_integrations_cache();+ match ops::fetch_connected_integrations_status(&live_config).await {+ FetchConnectedIntegrationsStatus::Authoritative(entries) => {+ super::publish_integrations_changed(&entries);+ }+ FetchConnectedIntegrationsStatus::Unavailable => tracing::warn!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ "[composio:bus] eager cache warm after connection became active skipped: backend unavailable"+ ),+ }+ }+ Err(WaitError::Timeout { last_status }) => {+ tracing::warn!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ last_status = ?last_status,+ timeout_secs = CONNECTION_READY_TIMEOUT.as_secs(),+ "[composio:bus] timed out waiting for connection to become active; skipping cache refresh + initial sync"+ );+ return;+ }+ Err(WaitError::Lookup { error }) => {+ tracing::warn!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ error = %error,+ "[composio:bus] backend lookup failed while waiting for connection; skipping cache refresh + initial sync"+ );+ return;+ }+ }++ // Connections made during the setup wizard would otherwise spend cloud+ // credits on embedding before the user chose their AI routing (#3097).+ if !live_config.onboarding_completed {+ tracing::info!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ "[composio:bus] onboarding not yet complete — skipping profile fetch and initial sync"+ );+ return;+ }+ if !crate::integrations::composio::providers::has_native_provider(&toolkit) {+ tracing::debug!(+ toolkit = %toolkit,+ "[composio:bus] no native sync provider for toolkit; skipping profile fetch and initial sync"+ );+ return;+ }+ if let Err(e) = ops::composio_get_user_profile(&live_config, &connection_id).await {+ tracing::warn!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ error = %e,+ "[composio:bus] connection bootstrap (profile fetch) failed"+ );+ }+ match ops::composio_sync(+ &live_config,+ &connection_id,+ Some("connection_created".to_string()),+ )+ .await+ {+ Ok(_) => tracing::info!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ "[composio:bus] initial sync started"+ ),+ Err(error) => tracing::debug!(+ toolkit = %toolkit,+ connection_id = %connection_id,+ error = %error,+ "[composio:bus] initial sync not started (memory off or unavailable)"+ ),+ }+}++// ── Connection-readiness polling ────────────────────────────────────++#[derive(Debug)]+pub(super) enum WaitError {+ /// Polling exhausted [`CONNECTION_READY_TIMEOUT`] without observing the+ /// connection active; `last_status` is what the backend last reported.+ Timeout { last_status: Option<String> },+ /// The backend lookup itself never succeeded.+ Lookup { error: String },+}++/// Polls `ListConnections` until `connection_id` is active, or until+/// [`CONNECTION_READY_TIMEOUT`]. Returns the observed status.+async fn wait_for_connection_active(config: &Config, connection_id: &str) -> Result<String, WaitError> {+ let started = std::time::Instant::now();+ let mut backoff = CONNECTION_READY_INITIAL_BACKOFF;+ let mut last_status: Option<String> = None;+ loop {+ match connectors::call_bare::<ComposioConnectionsResponse>(config, methods::LIST_CONNECTIONS).await {+ Ok(resp) => {+ if let Some(conn) = resp.connections.into_iter().find(|c| c.id == connection_id) {+ if conn.is_active() {+ return Ok(conn.status);+ }+ last_status = Some(conn.status);+ }+ }+ Err(e) => {+ tracing::debug!(+ connection_id = %connection_id,+ error = %e,+ "[composio:bus] list_connections failed during readiness poll (will retry)"+ );+ last_status = last_status.or_else(|| Some(format!("lookup_error: {e}")));+ }+ }+ if started.elapsed() >= CONNECTION_READY_TIMEOUT {+ if let Some(status) = last_status.as_ref().filter(|s| s.starts_with("lookup_error:")) {+ return Err(WaitError::Lookup {+ error: status.clone(),+ });+ }+ return Err(WaitError::Timeout { last_status });+ }+ tokio::time::sleep(backoff).await;+ backoff = (backoff * 2).min(CONNECTION_READY_MAX_BACKOFF);+ }+}diff --git a/crates/openhuman-core/src/integrations/composio/bus/registration.rs b/crates/openhuman-core/src/integrations/composio/bus/registration.rsindex df9596dd59..5c2618ed1a 100644--- a/crates/openhuman-core/src/integrations/composio/bus/registration.rs+++ b/crates/openhuman-core/src/integrations/composio/bus/registration.rs@@ -14,14 +14,9 @@ static COMPOSIO_TRIGGER_HANDLE: OnceLock<SubscriptionHandle> = OnceLock::new();static COMPOSIO_CONNECTION_HANDLE: OnceLock<SubscriptionHandle> = OnceLock::new();static COMPOSIO_CONFIG_HANDLE: OnceLock<SubscriptionHandle> = OnceLock::new();-/// Register both long-lived composio subscribers on the global event-/// bus, and initialise the default provider registry. Idempotent.+/// Register the three long-lived composio subscribers on the global event+/// bus. Idempotent.pub fn register_composio_trigger_subscriber() {- // No host-side provider registry any more. It existed so this process- // could answer `get_provider`; the driver answers that question now, and- // the module initialises its own registry in its own process- // (tinymemory#105) — which a `cdylib`'s separate statics require anyway.-if COMPOSIO_TRIGGER_HANDLE.get().is_none() {match BUS.subscribe(Arc::new(ComposioTriggerSubscriber::new())) {Some(handle) => {diff --git a/crates/openhuman-core/src/integrations/composio/bus_tests.rs b/crates/openhuman-core/src/integrations/composio/bus_tests.rsindex f16403f78a..9f61eef10e 100644--- a/crates/openhuman-core/src/integrations/composio/bus_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/bus_tests.rs@@ -271,7 +271,7 @@ async fn connection_subscriber_ignores_other_composio_event_variants() {}#[tokio::test]-async fn connection_subscriber_skips_when_no_provider_registered() {+async fn connection_subscriber_skips_when_not_signed_in() {// Pass a toolkit that has no native provider — the subscriber// must hit the `no provider registered` early-return branch.//diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rsindex 6e03627c7e..bc95e176d7 100644--- a/crates/openhuman-core/src/tools/ops.rs+++ b/crates/openhuman-core/src/tools/ops.rs@@ -15,7 +15,7 @@ use tinytools_std::detect_tools::DetectToolsTool;use tinytools_std::filesystem::{ApplyPatchTool, CsvExportTool, EditFileTool, FileReadTool, FileWriteTool, GitOperationsTool,GlobTool, GrepTool, ImageInfoTool, ListFilesTool, ReadDiffTool, RunLinterTool, RunTestsTool,- UpdateMemoryMdTool, WorkspaceStateTool,+ WorkspaceStateTool,};use tinytools_std::network::{CurlTool, PushoverTool};