Skip to content

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

fix(session_store): fail boot when config cannot be read and install backend only after bridge start

Steven Enamakela501f672003f
diff --git a/crates/openhuman-app/Cargo.toml b/crates/openhuman-app/Cargo.toml
index abc70646cd..323e2458de 100644
--- a/crates/openhuman-app/Cargo.toml
+++ b/crates/openhuman-app/Cargo.toml
@@ -324,6 +324,13 @@ tinyinference-llm = { path = "../../vendor/tinyagents/vendor/tinyinference/crate
tinyinference-local = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-local" }
tinyinference-voice = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-voice" }
+[patch."https://github.com/tinyhumansai/tinystoragedrivers"]
+# tinyflows names the storage crates by git tag; redirect them to the copy
+# tinyagents vendors so this world links one `DocumentStore` trait and one
+# `libsqlite3-sys`. Mirrors the root Cargo.toml.
+tinystoragedrivers-core = { path = "../../vendor/tinyagents/vendor/tinystoragedrivers/crates/tinystoragedrivers-core" }
+tinystoragedrivers-sqlite = { path = "../../vendor/tinyagents/vendor/tinystoragedrivers/crates/tinystoragedrivers-sqlite" }
+
[patch.crates-io]
# Keep reqwest defaults disabled in this independent Cargo world too. Without
# this patch, the registry release reintroduces native-tls/OpenSSL on Linux.
diff --git a/crates/openhuman-rpc/src/session_store/mod.rs b/crates/openhuman-rpc/src/session_store/mod.rs
index e699c404f1..7adfde5d99 100644
--- a/crates/openhuman-rpc/src/session_store/mod.rs
+++ b/crates/openhuman-rpc/src/session_store/mod.rs
@@ -161,15 +161,14 @@ pub fn install() {
pub async fn install_for_host() -> anyhow::Result<()> {
let url = match std::env::var(openhuman_core::storage::STORAGE_URL_VAR) {
Ok(url) if !url.trim().is_empty() => Some(url.trim().to_string()),
- _ => match openhuman_core::config::rpc::load_config_with_timeout().await {
- Ok(config) => openhuman_core::storage::configured_url(&config),
- Err(error) => {
- tracing::warn!(
- "[session_store] config unavailable ({error}); keeping the on-disk layout"
- );
- None
- }
- },
+ // A config that cannot be loaded may be hiding a `[storage] url`:
+ // fail the boot rather than quietly choosing the classic layout.
+ _ => {
+ let config = openhuman_core::config::rpc::load_config_with_timeout()
+ .await
+ .map_err(|error| anyhow::anyhow!("loading the config to read [storage]: {error}"))?;
+ openhuman_core::storage::configured_url(&config)
+ }
};
install_for_url(url).await
}
@@ -185,17 +184,21 @@ pub async fn install_for_url(url: Option<String>) -> anyhow::Result<()> {
use anyhow::Context as _;
let Some(url) = url else {
+ // Drop a backend an earlier call installed, so storage operations do
+ // not keep writing to it while the classic layout is in force.
+ openhuman_core::storage::clear();
install();
return Ok(());
};
let backend = openhuman_core::storage::open(&url)
.await
.context("opening the configured storage backend")?;
- openhuman_core::storage::install(Arc::clone(&backend));
let single_process = backend.driver() != "mongodb";
- let provider = tinyagents_session::DriverSessionStores::new(backend)
+ let provider = tinyagents_session::DriverSessionStores::new(Arc::clone(&backend))
.context("starting the session store bridge")?
.recover_on_open(single_process);
+ // Only a fully working bridge makes the backend the process's storage.
+ openhuman_core::storage::install(backend);
tracing::info!(
target: "openhuman_rpc::session_store",
recover_on_open = single_process,
diff --git a/crates/openhuman-tui/src/runner.rs b/crates/openhuman-tui/src/runner.rs
index ac178d7ec9..8bfe6664a9 100644
--- a/crates/openhuman-tui/src/runner.rs
+++ b/crates/openhuman-tui/src/runner.rs
@@ -176,7 +176,8 @@ async fn async_main(
// In-process core: full domains (channel.web_chat needs DomainGroup::Channels,
// so harness() is not enough), no RPC transport, no background services.
- // Conversations in the classic on-disk layout, as the desktop keeps them.
+ // Conversations in the classic on-disk layout, as the desktop keeps them,
+ // unless a storage URL (`OPENHUMAN_STORAGE_URL` / `[storage] url`) is set.
openhuman_rpc::session_store::install_for_host().await?;
let runtime = Arc::new(
CoreBuilder::new(HostKind::detect_standalone())