Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(core): update error handling and logging

Steven Enamakelc193809a236d
diff --git a/crates/openhuman-core/src/config/workspace/state.rs b/crates/openhuman-core/src/config/workspace/state.rs
index 15daa7923f..32755bf4ec 100644
--- a/crates/openhuman-core/src/config/workspace/state.rs
+++ b/crates/openhuman-core/src/config/workspace/state.rs
@@ -8,7 +8,7 @@
use std::path::{Path, PathBuf};
use std::sync::Arc;
-use anyhow::{Context, Result, anyhow};
+use anyhow::{anyhow, Context, Result};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sha2::{Digest, Sha256};
@@ -100,7 +100,7 @@ impl WatcherStateStore {
Err(error) if error.kind() == tinystoragedrivers_types::ErrorKind::Conflict => {
continue;
}
- Err(error) => return Err(error),
+ Err(error) => return Err(error.into()),
}
}
})
diff --git a/crates/openhuman-core/src/storage/layout/legacy.rs b/crates/openhuman-core/src/storage/layout/legacy.rs
index 9b9b5c941d..e03b9d7852 100644
--- a/crates/openhuman-core/src/storage/layout/legacy.rs
+++ b/crates/openhuman-core/src/storage/layout/legacy.rs
@@ -28,8 +28,8 @@
use std::path::Path;
use std::sync::Arc;
-use super::Target;
use super::state::LayoutError;
+use super::Target;
use crate::config::Config;
use crate::storage::{self, StorageBackend};
@@ -140,9 +140,9 @@ pub async fn migrate(target: &Target) -> Result<(), LayoutError> {
.map_err(|e| LayoutError::Other(anyhow::anyhow!("schema migration: {e}")))?;
drop(backend);
log::debug!(
- scopes = report.scopes,
- collections = report.collections,
- "[storage::layout] owner collections prepared"
+ "[storage::layout] owner collections prepared: scopes={}, collections={}",
+ report.scopes,
+ report.collections
);
if db.is_file() {
super::db::checkpoint(&db)?;
diff --git a/crates/openhuman-core/src/storage/sessions/tenant_router.rs b/crates/openhuman-core/src/storage/sessions/tenant_router.rs
index 3ac6c1b0fe..da26d0b1ca 100644
--- a/crates/openhuman-core/src/storage/sessions/tenant_router.rs
+++ b/crates/openhuman-core/src/storage/sessions/tenant_router.rs
@@ -13,8 +13,8 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex, PoisonError};
use tinyagents_harness::store::SchemaAdmission;
-use tinyagents_session::DriverSessionStores;
use tinyagents_session::port::{AgentStorageFactory, AgentStores, SessionStoreProvider};
+use tinyagents_session::DriverSessionStores;
use tinyagents_storage_kit::{Blocking, Scope as PortScope, ScopedStorage};
use tinystoragedrivers::{StorageBackend, StorageError};
@@ -94,14 +94,15 @@ impl TenantSessionStores {
return (Arc::clone(provider), agent);
}
let backend = Arc::clone(&self.backend);
+ let tenant_for_factory = tenant.clone();
let factory: AgentStorageFactory = Arc::new(move |agent_id| {
let owner_scope =
- crate::storage::scope::Scope::new(tenant.as_str())?.agent(agent_id)?;
+ crate::storage::scope::Scope::new(tenant_for_factory.as_str())?.agent(agent_id)?;
let scope = PortScope::new(owner_scope.as_str())?;
let storage = backend.for_scope(&owner_scope)?;
- super::super::block_on(async {
- crate::storage::boot::prepare_scope(&storage).await?;
- Ok(())
+ let prepare_storage = storage.clone();
+ super::super::block_on(async move {
+ crate::storage::boot::prepare_scope(&prepare_storage).await
})?;
Ok(ScopedStorage::new(storage, scope))
});