Skip to content

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

feat(runtime): add observability availability to runtime context

Steven Enamakelb0b52129169c
diff --git a/crates/openhuman-core/src/core/observability_availability.rs b/crates/openhuman-core/src/core/observability_availability.rs
index 5c9b5a3691..05331fc477 100644
--- a/crates/openhuman-core/src/core/observability_availability.rs
+++ b/crates/openhuman-core/src/core/observability_availability.rs
@@ -7,14 +7,13 @@
//! signal, so [`super::expected_error_kind`] demotes all of them.
/// Sentinel prefix on the error string a backend-touching call returns when
-/// the core has no [`BackendTransport`](crate::backend::transport::BackendTransport)
-/// installed. `backend::client::flatten_authed_error` and the integrations client
-/// build their message from this constant; [`is_backend_unavailable_message`]
+/// no backend connection is
+/// installed. The hosted layer builds its message from this constant; [`is_backend_unavailable_message`]
/// classifies it as [`super::ExpectedErrorKind::BackendUnavailable`].
pub const BACKEND_UNAVAILABLE_PREFIX: &str = "BACKEND_UNAVAILABLE:";
/// Sentinel prefix on the error string a backend call returns when the backend
-/// rejects the stored TinyHumans API key (`backend::client::flatten_authed_error`).
+/// rejects the stored TinyHumans API key.
/// [`super::expected_error_kind`] demotes it: the fix is a new key, not a code
/// change.
pub const API_KEY_REJECTED_PREFIX: &str = "API_KEY_REJECTED:";
diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rs
index 0ad9fdfbd1..dc8be6a1d4 100644
--- a/crates/openhuman-core/src/core/runtime/builder.rs
+++ b/crates/openhuman-core/src/core/runtime/builder.rs
@@ -169,7 +169,6 @@ pub struct CoreBuilder {
host: Option<String>,
port: Option<u16>,
config: Option<crate::config::Config>,
- backend_transport: Option<std::sync::Arc<dyn crate::backend::transport::BackendTransport>>,
extensions: crate::core::slots::Extensions,
}
@@ -186,7 +185,6 @@ impl CoreBuilder {
host: None,
port: None,
config: None,
- backend_transport: None,
extensions: crate::core::slots::Extensions::new(),
}
}
@@ -201,25 +199,6 @@ impl CoreBuilder {
self
}
- /// Bind the transport this core's handlers reach the hosted TinyHumans
- /// backend through (see [`crate::backend::transport`]).
- ///
- /// Optional: without it the core resolves the process-global transport
- /// installed with
- /// [`install_backend_transport`](crate::backend::transport::install_backend_transport),
- /// and with neither every backend-touching call degrades to a typed
- /// "backend unavailable" error while agents, memory, tools and RPC keep
- /// working. Library hosts that build one runtime per process prefer this
- /// builder form; the desktop shell and CLI, which boot the core through
- /// `openhuman_rpc::host`, install the global.
- pub fn backend_transport(
- mut self,
- transport: std::sync::Arc<dyn crate::backend::transport::BackendTransport>,
- ) -> Self {
- self.backend_transport = Some(transport);
- self
- }
-
/// Choose which background services and transports this runtime runs.
pub fn services(mut self, services: ServiceSet) -> Self {
self.services = services;
@@ -361,7 +340,6 @@ impl CoreBuilder {
self.domains,
self.tool_groups.clone(),
self.config,
- self.backend_transport,
)
.await?;
ctx.extensions().merge_from(&self.extensions);
diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rs
index 1a31da59b5..80442e7858 100644
--- a/crates/openhuman-core/src/core/runtime/context.rs
+++ b/crates/openhuman-core/src/core/runtime/context.rs
@@ -98,14 +98,6 @@ pub struct CoreContext {
/// [`CoreContext::derive_with`] can turn it off so an embedded agent sees
/// only the skills its host installed for it, never the operator's.
user_skill_roots: bool,
- /// The backend transport this context's handlers reach the hosted
- /// TinyHumans backend through, when the host supplied one via
- /// [`CoreBuilder::backend_transport`](crate::core::runtime::CoreBuilder::backend_transport).
- /// `None` means "fall back to the process-global transport" — see
- /// [`crate::backend::transport::resolve_backend_transport`] for the order.
- /// Inherited unchanged by every context derived through
- /// [`CoreContext::derive_with`].
- backend_transport: Option<Arc<dyn crate::backend::transport::BackendTransport>>,
/// Hook registrations bound to this context (see [`crate::core::slots`]).
/// Empty unless the host supplied some through
/// [`CoreBuilder::extensions`](crate::core::runtime::CoreBuilder::extensions);
@@ -174,15 +166,10 @@ impl CoreContext {
mut domains: crate::core::runtime::DomainSet,
mut tool_groups: crate::tools::toolpacks::ToolGroups,
preloaded_config: Option<crate::config::Config>,
- backend_transport: Option<Arc<dyn crate::backend::transport::BackendTransport>>,
) -> anyhow::Result<(Arc<CoreContext>, bool, Option<crate::config::Config>)> {
log::debug!(
"[core-context] init: host_kind={host_kind:?} domains={domains:?} \
- tool_groups={tool_groups:?} backend_transport={}",
- backend_transport
- .as_ref()
- .map(|t| t.name())
- .unwrap_or("<process-global>")
+ tool_groups={tool_groups:?}"
);
crate::core::runtime::mode::admit_core(host_kind, DEFAULT_CONTEXT.get().is_some())
.map_err(|e| anyhow::anyhow!("[core-context] {e}"))?;
@@ -294,7 +281,6 @@ impl CoreContext {
components,
embedder_config,
user_skill_roots: true,
- backend_transport,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
@@ -427,7 +413,6 @@ impl CoreContext {
components: self.components,
embedder_config: Some(overlay.config),
user_skill_roots: overlay.user_skill_roots,
- backend_transport: self.backend_transport.clone(),
extensions: self.extensions.clone(),
turn_origin: self.turn_origin.clone(),
channel_thread: self.channel_thread.clone(),
@@ -465,13 +450,6 @@ impl CoreContext {
ctx.map(|ctx| ctx.extensions.clone())
}
- /// The backend transport bound to this context, if the host supplied one.
- pub fn backend_transport(
- &self,
- ) -> Option<Arc<dyn crate::backend::transport::BackendTransport>> {
- self.backend_transport.clone()
- }
-
/// The resolved per-user workspace directory this context is bound to.
pub fn workspace_dir(&self) -> Result<std::path::PathBuf, String> {
self.workspace_binding
diff --git a/crates/openhuman-core/src/core/runtime/context_for_agent.rs b/crates/openhuman-core/src/core/runtime/context_for_agent.rs
index 4b0b7bd8f4..1f75957f8b 100644
--- a/crates/openhuman-core/src/core/runtime/context_for_agent.rs
+++ b/crates/openhuman-core/src/core/runtime/context_for_agent.rs
@@ -33,7 +33,6 @@ impl CoreContext {
components: self.components,
embedder_config: self.embedder_config.clone(),
user_skill_roots: self.user_skill_roots,
- backend_transport: self.backend_transport.clone(),
extensions: self.extensions.clone(),
turn_origin: self.turn_origin.clone(),
channel_thread: self.channel_thread.clone(),
diff --git a/crates/openhuman-core/src/core/runtime/context_test_support.rs b/crates/openhuman-core/src/core/runtime/context_test_support.rs
index 0c78688e49..7a92ed9ee1 100644
--- a/crates/openhuman-core/src/core/runtime/context_test_support.rs
+++ b/crates/openhuman-core/src/core/runtime/context_test_support.rs
@@ -23,7 +23,6 @@ impl CoreContext {
components: Default::default(),
embedder_config: None,
user_skill_roots: true,
- backend_transport: None,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
@@ -70,7 +69,6 @@ impl CoreContext {
components: Default::default(),
embedder_config: Some(config),
user_skill_roots: true,
- backend_transport: None,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
diff --git a/crates/openhuman-core/src/core/runtime/context_tests.rs b/crates/openhuman-core/src/core/runtime/context_tests.rs
index e7d2c0cf8a..be235bb8a2 100644
--- a/crates/openhuman-core/src/core/runtime/context_tests.rs
+++ b/crates/openhuman-core/src/core/runtime/context_tests.rs
@@ -12,7 +12,6 @@ fn ctx(dir: &str) -> Arc<CoreContext> {
components: Default::default(),
embedder_config: None,
user_skill_roots: true,
- backend_transport: None,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
@@ -49,7 +48,6 @@ fn ctx_with_config(config: crate::config::Config) -> Arc<CoreContext> {
components: Default::default(),
embedder_config: Some(config),
user_skill_roots: true,
- backend_transport: None,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
@@ -391,7 +389,6 @@ fn degraded_context_rejects_workspace_bound_stores() {
components: Default::default(),
embedder_config: None,
user_skill_roots: true,
- backend_transport: None,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
diff --git a/crates/openhuman-core/src/core/runtime/context_turn_origin.rs b/crates/openhuman-core/src/core/runtime/context_turn_origin.rs
index c8f0ed0a8c..85390b1746 100644
--- a/crates/openhuman-core/src/core/runtime/context_turn_origin.rs
+++ b/crates/openhuman-core/src/core/runtime/context_turn_origin.rs
@@ -42,7 +42,6 @@ impl CoreContext {
components: Default::default(),
embedder_config: None,
user_skill_roots: true,
- backend_transport: None,
extensions: Default::default(),
turn_origin: None,
channel_thread: None,
@@ -105,7 +104,6 @@ impl CoreContext {
components: ctx.components,
embedder_config: ctx.embedder_config.clone(),
user_skill_roots: ctx.user_skill_roots,
- backend_transport: ctx.backend_transport.clone(),
extensions: ctx.extensions.clone(),
turn_origin: origin.or_else(|| ctx.turn_origin.clone()),
channel_thread: thread.or_else(|| ctx.channel_thread.clone()),
diff --git a/crates/openhuman-core/src/core/session_expiry_tests.rs b/crates/openhuman-core/src/core/session_expiry_tests.rs
index 1aa44f1f25..8f4a2afaaa 100644
--- a/crates/openhuman-core/src/core/session_expiry_tests.rs
+++ b/crates/openhuman-core/src/core/session_expiry_tests.rs
@@ -18,12 +18,12 @@ fn is_session_expired_error_matches_backend_path_401() {
#[test]
fn is_session_expired_error_matches_flattened_backend_unauthorized() {
// #3297: after #2781 the backend 401 is a typed `BackendApiError::Unauthorized`
- // that team/billing ops flatten via `backend::flatten_authed_error`. The dispatcher
+ // that team/billing ops flatten via `the hosted layer's flatten step`. The dispatcher
// classifier MUST recognise that flattened string as session expiry, so the
// 401 is suppressed from Sentry (TAURI-RUST-8WY on `/teams/me/usage`,
// TAURI-RUST-8WZ on `/payments/stripe/currentPlan`) AND triggers the
// `SessionExpired` publish. End-to-end: build the typed error → flatten → classify.
- let flat = crate::backend::flatten_authed_error(anyhow::Error::new(
+ let flat = crate::the hosted layer's flatten step(anyhow::Error::new(
crate::backend::BackendApiError::Unauthorized {
method: "GET".to_string(),
path: "/teams/me/usage".to_string(),