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(threads): guard conversation schema setup with a migration lease
Steven Enamakel8c00e319d152
diff --git a/crates/openhuman-core/src/threads/store/backend.rs b/crates/openhuman-core/src/threads/store/backend.rsindex 74d56f9da3..e17d0ceb5f 100644--- a/crates/openhuman-core/src/threads/store/backend.rs+++ b/crates/openhuman-core/src/threads/store/backend.rs@@ -154,18 +154,40 @@ impl ConversationStore {.map_err(|e| format!("{LOG_PREFIX} open the storage scope: {e}"))?;let repo = Repo::on(&backend, &scope, DOMAIN, super::legacy_import::collections).map_err(|e| format!("{LOG_PREFIX} {e:#}"))?;- let store = DriverConversationStore::new(ScopedStorage::new(+ let owner_storage = ScopedStorage::new(scoped.clone(),AgentScope::new(scope.as_str()).map_err(|e| format!("{LOG_PREFIX} invalid scope: {e}"))?,- ));+ );+ let store = DriverConversationStore::new(owner_storage.clone());repo.once_per_backend("schema", || {- let docs = Arc::clone(scoped.documents());+ let leased_storage = owner_storage.clone();storage::block_on(async move {- DriverConversationStore::prepare_schema(docs.as_ref()).await?;- DriverConversationStore::prepare_append_schema(docs.as_ref()).await+ tinyagents_storage_kit::with_migration_lease(+ &leased_storage,+ "conversations",+ move |_| async move {+ let docs = Arc::clone(leased_storage.documents());+ DriverConversationStore::prepare_schema(docs.as_ref()).await?;+ DriverConversationStore::prepare_append_schema(docs.as_ref()).await?;+ for spec in tinyagents_storage_kit::primitives::collection_specs() {+ docs.ensure_collection(&spec).await?;+ }+ let registry = tinyagents_storage_kit::Registry::compose([+ tinyagents_session::threads::conversations_storage_schema(),+ ])?;+ registry+ .migrate(+ &leased_storage,+ &tinyagents_storage_kit::MigrateOptions::new(),+ )+ .await?;+ Ok(())+ },+ )+ .await})- .map_err(|e| anyhow::anyhow!("declare the conversation schema: {e}"))+ .map_err(|e| anyhow::anyhow!("prepare the conversation schema: {e}"))}).map_err(|e| format!("{LOG_PREFIX} {e:#}"))?;super::legacy_import::import_once(&self.workspace_dir, &repo)