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
feat(progress_tracing): add langfuse environment and journal export
Steven Enamakel706a7bd03758
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse.rsindex 8338c423e5..68f9916837 100644--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs@@ -23,7 +23,7 @@mod environment;mod journal_export;-pub(crate) use environment::{environment_for_base, ingestion_url, skip_push};+pub(crate) use environment::{environment_for_base, ingestion_url, otlp_url, skip_push};pub(crate) use journal_export::journal_push_ready;#[cfg(test)]diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rsindex 426305ef0f..7928f56f0e 100644--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse/environment.rs@@ -19,47 +19,44 @@ pub(crate) fn ingestion_url(config: &Config) -> String {.unwrap_or_default()}-/// The domain the deployed backends live under. A host outside it cannot be-/// one of ours, so it cannot be staging however it is spelled.-const DEPLOYMENT_DOMAIN: &str = "tinyhumans.ai";+/// The OTLP/HTTP traces URL the host resolved+/// (`config.resolved_endpoints.tracing_otlp_url`). Empty when no host resolved+/// one; callers treat a non-`http` URL as "proxy unavailable".+pub(crate) fn otlp_url(config: &Config) -> String {+ config+ .resolved_endpoints+ .tracing_otlp_url+ .clone()+ .unwrap_or_default()+}-/// Derive the Langfuse `environment` for a backend base URL. Chosen signal:+/// Derive the Langfuse `environment` for a tracing base URL. Chosen signal:/// the resolved backend host is the single existing config-driven fact that/// distinguishes deployments (there is no NODE_ENV-style flag in the core-/// config) — loopback/local → development, a staging host under-/// [`DEPLOYMENT_DOMAIN`] → staging, the canonical API host → production,-/// anything else → external.+/// config) — loopback/local → development; a non-local HTTPS host takes the+/// bucket the installed host resolved for its control plane+/// (`config.resolved_endpoints.deployment_environment`: production, staging);+/// anything else → external. With no host registered nothing is resolved, so+/// every non-local host is external and does not push.////// # Why the host is parsed rather than substring-matched///-/// This used to test `base.contains("staging")` and-/// `base.contains("localhost" | "127.0.0.1" | "0.0.0.0")` against the whole-/// URL, which was tolerable while the answer only labelled a payload. It is-/// not tolerable now that [`skip_push`] decides whether to push at all, so-/// both directions of the sloppiness became load-bearing:-///-/// - **Too broad on staging.** `https://staging-attacker.invalid` contains-/// `staging`, so it classified as staging and passed the push gate — a host-/// nothing in this tree owns, reached with a live session token. Anchoring-/// to [`DEPLOYMENT_DOMAIN`] is what makes the classifier fail *closed*: a-/// host that is not ours is external, and external does not push.-/// - **Too narrow on local.** An IPv6 loopback backend (`http://[::1]:7788`)-/// or a private LAN address matched none of the three literals and-/// classified as external, so a working development setup would have-/// silently stopped exporting the moment the gate landed.-///-/// Host classification is delegated to [`crate::util::url::host_is_local`],-/// which already parses the URL and handles IPv4 loopback/unspecified/private,-/// IPv6 loopback/unspecified, and `localhost` / `*.localhost`. Keeping one-/// definition matters more than the few lines it saves: two local-host-/// predicates that disagree is how a gate lets through exactly the case the-/// other one blocks.+/// The answer decides whether a push happens at all ([`skip_push`]), so a+/// sloppy match is load-bearing in both directions. A substring test on+/// `staging` let `https://staging-attacker.invalid` through, and missed an+/// IPv6 loopback backend (`http://[::1]:7788`). Local classification is+/// delegated to [`crate::util::url::host_is_local`], which parses the URL and+/// handles IPv4 loopback/unspecified/private, IPv6 loopback/unspecified and+/// `localhost` / `*.localhost`; one local-host predicate keeps the gates in+/// agreement. The hosted bucket is classified by the host that owns the+/// domain, anchored to its own deployment domain so the classifier fails+/// *closed*.////// An unparseable URL is external — the fail-closed default. `ingestion_url`/// can return a non-URL placeholder when no backend host resolves, and the/// caller checks `starts_with("http")` separately; classifying that as/// anything pushable would defeat the gate.-pub(crate) fn environment_for_base(base: &str) -> &'static str {+pub(crate) fn environment_for_base(config: &Config, base: &str) -> &'static str {let Ok(parsed) = url::Url::parse(base) else {return "external";};@@ -69,26 +66,13 @@ pub(crate) fn environment_for_base(base: &str) -> &'static str {if parsed.scheme() != "https" {return "external";}- let Some(url::Host::Domain(host)) = parsed.host() else {- // A public IP literal is not a deployment of ours.- return "external";- };- let host = host.to_ascii_lowercase();- let under_deployment_domain =- host == DEPLOYMENT_DOMAIN || host.ends_with(&format!(".{DEPLOYMENT_DOMAIN}"));- // The label test is on the leftmost label only, so `staging-api…` and- // `staging…` match while `api-staging-mirror…` does not sneak in on a- // substring.- let leftmost_is_staging = host- .split('.')- .next()- .is_some_and(|label| label == "staging" || label.starts_with("staging-"));- if host == "api.tinyhumans.ai" {- "production"- } else if under_deployment_domain && leftmost_is_staging {- "staging"- } else {- "external"+ // Only the known buckets are honoured, so a host cannot invent a+ // pushable one; the allowlist in [`push_allowed`] still has the final say.+ match config.resolved_endpoints.deployment_environment.as_deref() {+ Some("production") => "production",+ Some("staging") => "staging",+ Some("development") => "development",+ _ => "external",}}diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse/journal_export.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse/journal_export.rsindex 67e7b880f8..96b5832fd9 100644--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse/journal_export.rs+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse/journal_export.rs@@ -13,7 +13,7 @@ use super::{environment_for_base, ingestion_url, skip_push};/// discarded anyway, and reading a whole child journal is not free.pub(crate) fn journal_push_ready(config: &Config) -> bool {let url = ingestion_url(config);- !skip_push(environment_for_base(&url))+ !skip_push(environment_for_base(config, &url))&& url.starts_with("http")&& matches!(direct_backend_credential(config, "langfuse journal push"),diff --git a/crates/openhuman-core/src/agent/progress_tracing/otlp.rs b/crates/openhuman-core/src/agent/progress_tracing/otlp.rsindex 5a3ecf816e..836523c008 100644--- a/crates/openhuman-core/src/agent/progress_tracing/otlp.rs+++ b/crates/openhuman-core/src/agent/progress_tracing/otlp.rs@@ -8,7 +8,7 @@ use serde_json::Value;use tinyagents_harness::observability::trace_export::otlp::otlp_requests;use tinyagents_harness::observability::trace_export::TraceSpan;-use super::langfuse::{environment_for_base, ingestion_url, skip_push};+use super::langfuse::{environment_for_base, otlp_url, skip_push};use crate::config::Config;use crate::security::credentials::jwt::bearer_authorization_value;use crate::security::credentials::session_support::direct_backend_credential;@@ -17,9 +17,8 @@ pub(super) async fn push_spans(config: &Config, spans: &[TraceSpan]) -> Result<(if spans.is_empty() {return Ok(());}- let legacy_url = ingestion_url(config);- let url = legacy_url.replace("/langfuse/ingestion", "/langfuse/otel/v1/traces");- let environment = environment_for_base(&url);+ let url = otlp_url(config);+ let environment = environment_for_base(config, &url);if skip_push(environment) {return Ok(());}diff --git a/crates/openhuman-embed/src/runtime/README.md b/crates/openhuman-embed/src/runtime/README.mdindex 9ae80dc04e..0a500ca94b 100644--- a/crates/openhuman-embed/src/runtime/README.md+++ b/crates/openhuman-embed/src/runtime/README.md@@ -34,7 +34,7 @@ in order:| a host credential becomes Cli|- install the session store provider (before boot: recovery runs)|- CoreBuilder::new(host_kind).domains.tool_groups.services- | .token(EnvOrFile).config(..)[.backend_transport(..)].build()+ | .token(EnvOrFile).config(..).build()|- store the Session through auth, if givenvRuntime { guard: Arc<CoreGuard>, base_config, domains, tool_groups, ... }@@ -79,7 +79,7 @@ every later `Runtime::builder().build()` would fail with `AlreadyRunning`.- `RuntimeBuilder` ([`builder.rs`](builder.rs)): `workspace`, `workspace_dir`,`action_dir`, `config_source`, `api_key`, `backend_url`,- `backend_transport`, `memory_engine`, `session_store`, `provider`,+ `memory_engine`, `session_store`, `provider`,`access`, `services`, `domains`, `tool_groups`, `host_kind`, `token`,`listen` (`listen_host`, `listen_port`), `session`, `config`, the seamoptions ([`seams.rs`](seams.rs)), then `build` or `run_from_args`. Presetsdiff --git a/crates/openhuman-embed/src/runtime/run.rs b/crates/openhuman-embed/src/runtime/run.rsindex 6032f9b816..0e4c9fbaca 100644--- a/crates/openhuman-embed/src/runtime/run.rs+++ b/crates/openhuman-embed/src/runtime/run.rs@@ -6,7 +6,7 @@//! [`server_launcher`](RuntimeBuilder::server_launcher). So the entry is two//! steps://!-//! 1. the builder's process-global pieces (backend transport, memory engine,+//! 1. the builder's process-global pieces (memory engine,//! session store, controller extensions, launcher, hooks) are installed for//! the life of the process, which every subcommand needs;//! 2. what is left of the builder (host kind, domains, services, token,@@ -29,7 +29,6 @@ use super::{RuntimeBuilder, RuntimeError};/// The pieces of a builder that are installed process-wide before the CLI/// dispatches, split from the rest, which becomes the [`HostBoot`].pub(super) struct CliGlobals {- pub(super) transport: Option<Arc<dyn BackendTransport>>,pub(super) memory_engine: Option<Arc<dyn tinymemory_api::MemoryEngine>>,pub(super) session_store: Option<Arc<dyn SessionStoreProvider>>,pub(super) seams: HostSeams,@@ -39,9 +38,7 @@ impl RuntimeBuilder {/// Install this builder's process-global pieces, then run the core's/// command-line dispatcher on `args` (without the binary name).///- /// Installed for the rest of the process, never restored: the backend- /// transport (as the process global; the builder keeps it too so the- /// server's runtime binds it), the memory engine, the session store,+ /// Installed for the rest of the process, never restored: the memory engine, the session store,/// controller extensions, the server launcher, the tool ranker and the/// embedder hooks.///@@ -104,9 +101,8 @@ impl RuntimeBuilder {}/// Separate the process-global pieces from the builder that boots the- /// server. The transport, memory engine and session store stay on the- /// builder as well: the server's runtime binds the transport, and- /// `build()` validates a `Workspace::Stateless` workspace against the+ /// server. The memory engine and session store stay on the+ /// builder as well: `build()` validates a `Workspace::Stateless` workspace against the/// session store and installs the custom engine/store over the/// launcher's defaults.pub(super) fn split_for_cli(mut self) -> (RuntimeBuilder, CliGlobals) {@@ -164,8 +160,8 @@ impl CliGlobals {}/// Run the core's command-line dispatcher with the [`RuntimeBuilder::cli`]-/// preset — no backend transport, extensions or launcher. Hosts that need-/// those (the TinyHumans transport, the JSON-RPC server) configure a builder+/// preset — no extensions or launcher. Hosts that need+/// those (the TinyHumans layer, the JSON-RPC server) configure a builder/// and call [`RuntimeBuilder::run_from_args`] instead.pub fn run_from_args(args: &[String]) -> anyhow::Result<()> {RuntimeBuilder::cli().run_from_args(args)