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(integrations): handle missing thread in purge operation
Steven Enamakel497353f0baf0
diff --git a/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rs b/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rsindex 24a451d6a5..eda75a2f1a 100644--- a/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rs+++ b/crates/openhuman-core/src/integrations/composio/connected_integrations/fetch_uncached.rs@@ -11,7 +11,17 @@ use crate::config::Config;use super::fetch::{connectable_toolkit_slugs, resolve_toolkit_description};-+/// The actual backend fetch, called on cache miss.+///+/// Returns `Some(vec)` when the backend was reachable. The returned+/// vector is the merged **integration overview** — every toolkit in+/// the backend allowlist appears as one entry, with a `connected`+/// flag indicating whether the user has an active OAuth connection.+/// Connected entries also carry the per-action tool catalogue+/// (fetched in a single batched call).+///+/// Returns `None` when we couldn't even build a client (no auth),+/// signalling the caller should NOT cache this result.async fn fetch_connected_integrations_uncached(config: &Config,) -> Option<Vec<ConnectedIntegration>> {diff --git a/crates/openhuman-core/src/threads/ops/purge.rs b/crates/openhuman-core/src/threads/ops/purge.rsnew file mode 100644index 0000000000..650857bb82--- /dev/null+++ b/crates/openhuman-core/src/threads/ops/purge.rs@@ -0,0 +1,62 @@+//! Workspace-wide conversation purge.++use super::support::{envelope, run_to_completion, workspace_dir};+use crate::memory::conversations;+use crate::memory::{ApiEnvelope, EmptyRequest, PurgeConversationThreadsResponse};+use crate::rpc::RpcOutcome;+use crate::threads::turn_state;+use std::path::PathBuf;++/// Purges all conversation threads and messages.+///+/// Same cancellation contract as `thread_delete`: the purge and its sub-agent+/// / turn-snapshot cleanup are one [`run_to_completion`] unit, so a dropped+/// caller cannot leave every thread wiped while their sub-agents keep running.+pub async fn threads_purge(+ _request: EmptyRequest,+) -> Result<RpcOutcome<ApiEnvelope<PurgeConversationThreadsResponse>>, String> {+ let dir = workspace_dir().await?;+ run_to_completion("threads_purge", threads_purge_inner(dir)).await+}++async fn threads_purge_inner(+ dir: PathBuf,+) -> Result<RpcOutcome<ApiEnvelope<PurgeConversationThreadsResponse>>, String> {+ let stats = conversations::blocking::purge_threads(dir.clone()).await?;+ // No parent thread survives a purge, so cancel every detached sub-agent and+ // wipe every queued result. Same ordering as `thread_delete`: abort the+ // in-flight runs first, then clear the delivery queue. Tombstone each+ // cancelled sub-agent's thread BEFORE the final wipe so a straggler that+ // wins the cooperative-abort race (records after the wipe) is still dropped+ // by `record_completion` rather than delivered into a purged thread.+ use crate::agent::orchestration::{background_completions, running_subagents};+ let cancelled_threads = running_subagents::cancel_all();+ let mut discarded = 0;+ for thread_id in &cancelled_threads {+ discarded += background_completions::discard_for_thread(thread_id);+ }+ discarded += background_completions::clear_all();+ log::debug!(+ "[threads] threads_purge cancelled_threads={} discarded_completions={}",+ cancelled_threads.len(),+ discarded+ );+ // Threads are gone, so any orphan turn snapshots can never be+ // reattached to a live thread. Wipe them in the same call so+ // `turn_state_list` returns an empty set after a purge. Use the+ // parse-independent `clear_all` so corrupted / half-written+ // snapshot files (which `list()` would warn-and-skip) are also+ // removed — a destructive cleanup must not leave behind anything+ // it failed to deserialize. Failures surface as RPC errors.+ turn_state::store::clear_all(dir.clone())+ .map_err(|err| format!("threads purged but turn-snapshot cleanup failed: {err}"))?;+ Ok(envelope(+ PurgeConversationThreadsResponse {+ messages_deleted: stats.message_count,+ agent_threads_deleted: stats.thread_count,+ agent_messages_deleted: stats.message_count,+ },+ None,+ None,+ ))+}