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
fix(agent): handle missing Langfuse journal entries gracefully
Steven Enamakel7bcf3d6b03f4
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 ab6870dff1..30425e43df 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@@ -20,6 +20,21 @@ use crate::security::credentials::session_support::direct_backend_credential;use super::{environment_for_base, ingestion_url, skip_push, LOG_TARGET, PUSH_TIMEOUT};+/// Project the run-ledger aggregate onto the upstream run-total shape.+fn run_totals(telemetry: &RunTelemetry) -> RunTotals {+ RunTotals {+ run_id: telemetry.run_id.clone(),+ input_tokens: telemetry.input_tokens,+ output_tokens: telemetry.output_tokens,+ cached_input_tokens: telemetry.cached_input_tokens,+ cost_usd: telemetry.cost_usd,+ tool_count: telemetry.tool_count,+ model: telemetry.model.clone(),+ provider: telemetry.provider.clone(),+ error: telemetry.error.clone(),+ }+}+/// Push durable journal observations through the tinyagents crate Langfuse/// exporter. The journal is already redacted before persistence, and this/// exporter additionally strips model/tool payloads unless `capture_content`diff --git a/crates/openhuman-core/src/agent/session_host/turn/context.rs b/crates/openhuman-core/src/agent/session_host/turn/context.rsindex 0c0bfc011d..ccdf326be7 100644--- a/crates/openhuman-core/src/agent/session_host/turn/context.rs+++ b/crates/openhuman-core/src/agent/session_host/turn/context.rs@@ -9,6 +9,53 @@ use crate::tools::agent_policy::render_tool_policy_boundary;use anyhow::Result;+async fn collect_tree_root_summaries(+ per_namespace_cap: usize,+ total_cap: usize,+) -> Vec<crate::agent::prompts::NamespaceSummary> {+ use crate::memory::api::provider::MemoryProvider;++ let Ok(guard) = crate::memory::ops::guard::active_memory_guard().await else {+ return Vec::new();+ };+ let Some(tree) = guard.as_tree() else {+ return Vec::new();+ };+ match tree+ .root_summaries_with_caps(per_namespace_cap, total_cap)+ .await+ {+ Ok(rows) => rows+ .into_iter()+ .map(|row| crate::agent::prompts::NamespaceSummary {+ namespace: row.namespace,+ body: row.body,+ updated_at: row.updated_at,+ })+ .collect(),+ Err(error) => {+ log::warn!("[session-runtime] tree root summaries unavailable: {error}");+ Vec::new()+ }+ }+}++fn sanitize_learned_entry(content: &str) -> String {+ let trimmed = content.trim();+ if trimmed.is_empty() {+ return String::new();+ }+ let sanitized: String = trimmed.chars().take(200).collect();+ if sanitized.contains("Bearer ")+ || sanitized.contains("sk-")+ || sanitized.contains("ghp_")+ || sanitized.contains("-----BEGIN")+ {+ return "[redacted: potential secret]".to_string();+ }+ sanitized+}+impl OpenHumanSessionHost {/// Pre-fetches learned context data from memory (observations, patterns, user profile).///diff --git a/crates/openhuman-core/src/agent/tinyagents/model.rs b/crates/openhuman-core/src/agent/tinyagents/model.rsindex 8f8e1ed0de..f36da582c6 100644--- a/crates/openhuman-core/src/agent/tinyagents/model.rs+++ b/crates/openhuman-core/src/agent/tinyagents/model.rs@@ -16,6 +16,29 @@ pub(super) type TurnChatModel = Arc<dyn ChatModel<()>>;pub(super) type TierRoutes = Vec<(String, TurnChatModel)>;pub(super) type BuiltTurnModels = (TurnChatModel, TierRoutes, TurnChatModel);+/// Build a [`PFormatRegistry`](tinytools_agent::PFormatRegistry)+/// from the tool schemas advertised on a [`ModelRequest`] (issue #4465).+///+/// The text-mode fallback parse needs each tool's positional parameter layout+/// to reconstruct named JSON arguments from a P-Format `name[a|b]` body. The+/// harness populates `request.tools` when tools are available (schemas are+/// rendered into the prompt for prompt-guided providers, or advertised natively+/// otherwise), so the registry is available in both modes. Tool-less requests+/// skip fallback parsing entirely; this empty registry is therefore consulted+/// only alongside a non-empty advertised tool list.+fn pformat_registry_from_request(request: &ModelRequest) -> tinytools_agent::PFormatRegistry {+ request+ .tools+ .iter()+ .map(|t| {+ (+ t.name.clone(),+ tinytools_agent::PFormatToolParams::from_schema(&t.parameters),+ )+ })+ .collect()+}+/// Translate an openhuman [`ChatResponse`] into a harness [`ModelResponse`]/// (visible text + tool calls + token usage).///@@ -171,6 +194,21 @@ struct OpenhumanUsageMeta {context_window: u64,}+/// Build the `ModelResponse.raw` value carrying charged-USD + context-window+/// metadata, or `None` when the provider reported neither (so responses from+/// providers that don't surface billing stay `raw: None`).+fn openhuman_usage_meta_raw(usage: Option<&UsageInfo>) -> Option<serde_json::Value> {+ let u = usage?;+ if u.charged_amount_usd <= 0.0 && u.context_window == 0 {+ return None;+ }+ let meta = OpenhumanUsageMeta {+ charged_amount_usd: u.charged_amount_usd,+ context_window: u.context_window,+ };+ Some(serde_json::json!({ OPENHUMAN_USAGE_META_KEY: meta }))+}+/// Merge the host billing/context metadata the crate [`Usage`] cannot carry into/// a crate [`ModelResponse::raw`] under [`OPENHUMAN_USAGE_META_KEY`], so/// [`usage_info_from_response`] recovers the charged-USD + context window from a