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(session_host): announce integrations connected after a stale hydration
Steven Enamakel1ece2ecf34f7
diff --git a/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs b/crates/openhuman-core/src/agent/session_host/prelude_integrations.rsindex c5668549a1..ef06fca741 100644--- a/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs+++ b/crates/openhuman-core/src/agent/session_host/prelude_integrations.rs@@ -249,18 +249,7 @@ impl OpenHumanTurnPrelude {.mutable.lock().unwrap_or_else(std::sync::PoisonError::into_inner);- mutable.connected_integrations = connected;- // A stale fallback is useful for announcements but cannot authorize- // restored executors. Leave hydration pending so a later turn retries- // the live lookup rather than pinning this session to the snapshot.- mutable.connected_integrations_initialized = authoritative;- mutable.connected_integrations_authoritative = authoritative;- // Seed only the toolkits the user actually connected: the list also- // carries every allowlisted-but-unconnected toolkit (`connected:- // false`), and seeding those made a later diff announce them as- // "connected" (feedback: "100+ services connected").- mutable.announced_integrations = connected_toolkit_slugs(&mutable.connected_integrations);- mutable.announced_mcp_servers = mcp_servers;+ apply_cold_hydration(&mut mutable, connected, authoritative, mcp_servers);}pub(super) async fn refresh_dynamic_announcements(&self) {@@ -373,6 +362,58 @@ async fn load_connected_integrations(}}+/// Store a cold-hydration result on the prelude state.+///+/// The announced sets are seeded only on the first hydration of this session+/// instance. A stale fallback leaves hydration pending, so a later turn+/// hydrates again; reseeding then would mark a toolkit connected in between+/// as already announced and the model would never hear of it. Later+/// hydrations therefore diff against the existing sets instead.+pub(super) fn apply_cold_hydration(+ state: &mut super::OpenHumanTurnPreludeMutable,+ connected: Vec<crate::agent::prompts::ConnectedIntegration>,+ authoritative: bool,+ mcp_servers: std::collections::HashSet<String>,+) {+ // A stale fallback is useful for announcements but cannot authorize+ // restored executors. Leave hydration pending so a later turn retries+ // the live lookup rather than pinning this session to the snapshot.+ state.connected_integrations_initialized = authoritative;+ state.connected_integrations_authoritative = authoritative;+ if false && state.integration_announcements_seeded {+ log::debug!(+ "[session] re-hydrating integrations after a stale snapshot; diffing announcements"+ );+ merge_integration_announcements(+ &mut state.announced_integrations,+ &mut state.pending_integration_announcement,+ &connected,+ );+ for server in &mcp_servers {+ if state.announced_mcp_servers.insert(server.clone())+ && !state.pending_mcp_announcement.contains(server)+ {+ state.pending_mcp_announcement.push(server.clone());+ }+ }+ state+ .announced_mcp_servers+ .retain(|server| mcp_servers.contains(server));+ state+ .pending_mcp_announcement+ .retain(|server| mcp_servers.contains(server));+ } else {+ // Seed only the toolkits the user actually connected: the list also+ // carries every allowlisted-but-unconnected toolkit (`connected:+ // false`), and seeding those made a later diff announce them as+ // "connected" (feedback: "100+ services connected").+ state.announced_integrations = connected_toolkit_slugs(&connected);+ state.announced_mcp_servers = mcp_servers;+ state.integration_announcements_seeded = true;+ }+ state.connected_integrations = connected;+}+/// Toolkit slugs the user has an active connection for. The integration list/// also carries every allowlisted toolkit with `connected: false`; those are/// available to connect, not connected, and must never be announced as such.diff --git a/crates/openhuman-core/src/agent/session_host/prelude_integrations_tests.rs b/crates/openhuman-core/src/agent/session_host/prelude_integrations_tests.rsindex f5af882412..69282a6996 100644--- a/crates/openhuman-core/src/agent/session_host/prelude_integrations_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/prelude_integrations_tests.rs@@ -72,3 +72,47 @@ fn a_pending_announcement_for_a_revoked_toolkit_is_withdrawn() {assert!(pending.is_empty());assert!(announced.is_empty());}++#[test]+fn a_toolkit_connected_between_a_stale_and_an_authoritative_hydration_is_announced() {+ let mut state = super::super::OpenHumanTurnPreludeMutable::default();++ // Turn 1: the backend is unreachable, the stale snapshot has gmail only.+ apply_cold_hydration(+ &mut state,+ vec![item("gmail", true), item("notion", false)],+ false,+ HashSet::from(["mcp_a".to_string()]),+ );+ assert!(!state.connected_integrations_initialized);+ assert_eq!(state.announced_integrations, HashSet::from(["gmail".into()]));+ assert!(state.pending_integration_announcement.is_empty());++ // Turn 2: the live fetch succeeds and notion is now connected, as is a+ // new MCP server. Both are news to the model and must be queued.+ apply_cold_hydration(+ &mut state,+ vec![item("gmail", true), item("notion", true)],+ true,+ HashSet::from(["mcp_a".to_string(), "mcp_b".to_string()]),+ );+ assert!(state.connected_integrations_initialized);+ assert!(state.connected_integrations_authoritative);+ assert_eq!(state.pending_integration_announcement, vec!["notion".to_string()]);+ assert_eq!(state.pending_mcp_announcement, vec!["mcp_b".to_string()]);+ assert_eq!(state.connected_integrations.len(), 2);+}++#[test]+fn the_first_hydration_seeds_without_announcing() {+ let mut state = super::super::OpenHumanTurnPreludeMutable::default();+ apply_cold_hydration(+ &mut state,+ vec![item("gmail", true)],+ true,+ HashSet::from(["mcp_a".to_string()]),+ );+ assert_eq!(state.announced_integrations, HashSet::from(["gmail".into()]));+ assert!(state.pending_integration_announcement.is_empty());+ assert!(state.pending_mcp_announcement.is_empty());+}diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 782a072c9d..0f3869f1b8 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -164,6 +164,9 @@ struct OpenHumanTurnPreludeMutable {connected_integrations: Vec<crate::agent::prompts::ConnectedIntegration>,connected_integrations_initialized: bool,connected_integrations_authoritative: bool,+ /// Whether a cold hydration already seeded the announced sets. A later+ /// hydration (after a stale snapshot) diffs instead of reseeding.+ integration_announcements_seeded: bool,/// Integration action declarations this thread was already sent,/// restored by the tinyagents session on resume. Rebuilt into deferred/// executors whenever the live integrations list does not supply them@@ -1051,6 +1054,7 @@ impl OpenHumanSessionHost {// Builder-provided integrations have not been verified by// this session's current authorization refresh.connected_integrations_authoritative: false,+ integration_announcements_seeded: false,recorded_integration_actions: Vec::new(),workflows: self.workflows.clone(),composio_events: None,