Skip to content

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

fix(tinyhumans): register config hooks before host config reads

Steven Enamakel46722b6efc28
diff --git a/crates/openhuman-rpc/src/host.rs b/crates/openhuman-rpc/src/host.rs
index 26e66d860a..18c6f347a4 100644
--- a/crates/openhuman-rpc/src/host.rs
+++ b/crates/openhuman-rpc/src/host.rs
@@ -81,6 +81,9 @@ fn embed_info(args: &[String]) -> anyhow::Result<Option<crate::embed::RuntimeInf
/// the dispatched command failed.
#[cfg(feature = "server")]
pub fn cli(args: &[String]) -> anyhow::Result<()> {
+ // Before any config read (`provider_for_host` loads one), so load-time
+ // migrations can recognise managed endpoints.
+ openhuman_tinyhumans::register_hooks();
// Introspection belongs above the core: never introduce a core -> embed dependency.
if let Some(info) = embed_info(args)? {
println!("{}", serde_json::to_string_pretty(&info)?);
@@ -264,6 +267,7 @@ pub async fn desktop(
shutdown_token: CancellationToken,
ready_tx: tokio::sync::oneshot::Sender<EmbeddedReadySignal>,
) -> anyhow::Result<()> {
+ openhuman_tinyhumans::register_hooks();
secret_storage::install();
log::debug!("[rpc:host] desktop options={options:?}");
serve_desktop(desktop_builder(&options), shutdown_token, ready_tx).await
@@ -312,6 +316,7 @@ pub fn tui_builder() -> RuntimeBuilder {
/// could not be built.
#[cfg(feature = "session-store")]
pub async fn tui() -> anyhow::Result<openhuman_tinyhumans::embed::Runtime> {
+ openhuman_tinyhumans::register_hooks();
secret_storage::install();
log::debug!("[rpc:host] tui: building connected runtime");
let session_store = crate::session_store::provider_for_host().await?;
diff --git a/crates/openhuman-tinyhumans/src/install.rs b/crates/openhuman-tinyhumans/src/install.rs
index 7a30cc2e0c..6dcc5b72ff 100644
--- a/crates/openhuman-tinyhumans/src/install.rs
+++ b/crates/openhuman-tinyhumans/src/install.rs
@@ -201,6 +201,19 @@ pub fn install(options: InstallOptions) -> Result<Arc<SdkBackendTransport>, Inst
connect_transport()
}
+/// Register the hooks a config *load* depends on, and nothing else.
+///
+/// A host that reads configuration before it connects (the CLI and TUI open
+/// their storage-backed session store first) must call this before any
+/// config read: the config enricher is what tells the load-time migrations
+/// which endpoints are managed, and with none registered a legacy managed
+/// config is mistaken for a custom one. Cheap and idempotent;
+/// [`install`] and the builder's connect register the same hook again.
+pub fn register_hooks() {
+ log::trace!("[tinyhumans] register_hooks: config enricher");
+ crate::client::register(&InstallOptions::default());
+}
+
/// Whether [`install`] (or the builder's connect) has run in this process.
pub fn is_installed() -> bool {
INSTALLED.load(Ordering::SeqCst)
diff --git a/crates/openhuman-tinyhumans/src/lib.rs b/crates/openhuman-tinyhumans/src/lib.rs
index ab32e6f844..a4656d634c 100644
--- a/crates/openhuman-tinyhumans/src/lib.rs
+++ b/crates/openhuman-tinyhumans/src/lib.rs
@@ -94,7 +94,7 @@ pub mod voice;
pub use backend::{product_identity, set_product_identity, ProductIdentity};
pub use hosted::extension as hosted_controllers;
-pub use install::{install, is_installed, InstallError, InstallOptions};
+pub use install::{install, is_installed, register_hooks, InstallError, InstallOptions};
pub use runtime::{RuntimeBuilder, RuntimeError};
pub use session::{
cache::{CachedUser, CurrentUserCache},
diff --git a/tests/support/tinyhumans_boot.rs b/tests/support/tinyhumans_boot.rs
index 57b61a5faf..0fd382ce15 100644
--- a/tests/support/tinyhumans_boot.rs
+++ b/tests/support/tinyhumans_boot.rs
@@ -20,6 +20,7 @@ static BOOT: Once = Once::new();
/// Install the SDK-backed backend transport once per test process.
pub fn boot() {
BOOT.call_once(|| {
+ openhuman_tinyhumans::register_hooks();
openhuman_tinyhumans::install(openhuman_tinyhumans::InstallOptions::default())
.expect("install the TinyHumans backend transport for tests");
});