Skip to content

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

fix(langfuse): handle missing journal entries gracefully

Steven Enamakelfd9717b590dc
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs
index c64483a1d2..d873354f1a 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs
@@ -24,9 +24,6 @@ mod journal_export;
pub(crate) use environment::{environment_for_base, ingestion_url, skip_push};
pub(crate) use journal_export::journal_push_ready;
-#[cfg(test)]
-use tinyagents_harness::observability::trace_export::TraceContext;
-
#[cfg(test)]
use crate::config::Config;
#[cfg(test)]
@@ -41,8 +38,6 @@ use tinyagents_harness::observability::trace_export::{SpanStatus, TraceSpan};
use tinyagents_harness::observability::AgentObservation;
const LOG_TARGET: &str = "agent-tracing::langfuse";
-/// Cap the push so a slow/hung Langfuse never stalls run teardown.
-const PUSH_TIMEOUT: Duration = Duration::from_secs(10);
#[cfg(test)]
#[path = "langfuse_tests.rs"]
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.rs
index f79a91ebe0..67e7b880f8 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
@@ -1,49 +1,16 @@
-//! Journal export: pushes a run's durable tinyagents observations through the
-//! tinyagents Langfuse exporter. Lineage stamping, trace attribution, content
-//! gating and the run-total fold are upstream
-//! (`tinyagents_harness::observability::trace_export::journal_export`); this
-//! module resolves the backend URL and credential and sends the chunks.
-
-use tinyagents_harness::observability::trace_export::ingestion_batch::{
- split_ingestion_batch, LANGFUSE_MAX_BATCH_EVENTS,
-};
-use tinyagents_harness::observability::trace_export::journal_export::{
- insert_run_telemetry_generation, observations_for_export, trace_config_from_context,
- trace_ctx_with_run_lineage, RunTotals,
-};
-use tinyagents_harness::observability::trace_export::TraceContext;
-use tinyagents_harness::observability::{AgentObservation, LangfuseClient};
-use tinyagents_session::run_ledger::RunTelemetry;
+//! Journal export readiness: whether a run's durable tinyagents observations
+//! would actually be sent to the backend's Langfuse proxy for a given config.
use crate::config::Config;
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(),
- }
-}
+use super::{environment_for_base, ingestion_url, skip_push};
-/// 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`
-/// is explicitly enabled.
-/// Whether [`push_observations`] would actually send for `config`: the same
-/// gates it checks, for a caller that must read a journal and build
-/// observations first. Without a live session (unit tests, a signed-out or
-/// embedder host) or on a skipped environment, that work is discarded
-/// anyway — and reading a whole child journal is not free.
+/// Whether a journal push would actually send for `config`: the URL gate, the
+/// environment gate and a live session credential. Callers must read a journal
+/// and build observations first, so without a live session (unit tests, a
+/// signed-out or embedder host) or on a skipped environment that work is
+/// 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))
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse_tests.rs
index eb9ef0ca21..cdd4f4b90e 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse_tests.rs
@@ -1,9 +1,8 @@
use super::*;
use std::collections::BTreeMap;
-use tinyagents_harness::ids::{CallId, EventId, RunId};
+use tinyagents_harness::ids::{EventId, RunId};
use tinyagents_harness::observability::trace_export::SpanKind;
-use tinyinference_llm::usage::Usage;
fn span(
trace: &str,