Skip to content

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

refactor(progress-tracing): restructure progress tracing module into submodules

Steven Enamakele0c79ef258f5
diff --git a/crates/openhuman-core/src/agent/progress_tracing.rs b/crates/openhuman-core/src/agent/progress_tracing.rs
index 2665043ddf..770d420f1c 100644
--- a/crates/openhuman-core/src/agent/progress_tracing.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing.rs
@@ -61,18 +61,27 @@ mod otlp;
mod collector;
/// Handing finished spans to the local exporter and the Langfuse push.
mod export;
-/// Content truncation caps, JSON-value builders, and NDJSON serialization.
-mod serialize;
-/// Data model: [`RunType`], [`TraceContext`], [`SpanKind`], [`SpanStatus`],
-/// [`TraceSpan`].
-mod types;
-pub use collector::SpanCollector;
-#[cfg(test)]
-pub use types::SpanKind;
+// The data model (`RunType`, `TraceContext`, `SpanKind`, `SpanStatus`,
+// `TraceSpan`), content truncation, NDJSON serialization, OTLP conversion and
+// Langfuse batch chunking live upstream in
+// `tinyagents_harness::observability::trace_export`.
#[cfg(test)]
-pub use types::SpanStatus;
-pub use types::{trace_session_id, RunType, TraceContext, TraceSpan};
+use tinyagents_harness::observability::trace_export::{SpanKind, SpanStatus};
+use tinyagents_harness::observability::trace_export::{
+ ExportBrand, RunType, TraceContext, TraceSpan,
+};
+
+pub use collector::SpanCollector;
+
+/// Product identity stamped onto exported telemetry (OTLP service name, scope,
+/// Langfuse release/version and run-total labels).
+pub(crate) fn export_brand() -> ExportBrand<'static> {
+ ExportBrand {
+ product: "openhuman",
+ version: env!("CARGO_PKG_VERSION"),
+ }
+}
pub(crate) use export::export_subagent_journal_trace;
pub(crate) use export::{export_run_trace, export_run_trace_from_journal};
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs
index 7a14a3de4d..683961fa9e 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs
@@ -4,14 +4,14 @@
use std::collections::BTreeMap;
use crate::agent::progress::AgentProgress;
-use crate::agent::progress_tracing::serialize::{
+use tinyagents_harness::observability::trace_export::serialize::{
json_f64, json_str, json_u32, json_u64, json_usize, status_of, truncate_chars,
MAX_ERROR_MESSAGE_CHARS, MAX_MODEL_CONTENT_CHARS,
};
-use crate::agent::progress_tracing::types::SpanKind;
+use tinyagents_harness::observability::trace_export::SpanKind;
use super::state::{SpanCollector, SubagentState};
-use crate::agent::progress_tracing::types::SpanStatus;
+use tinyagents_harness::observability::trace_export::SpanStatus;
impl SpanCollector {
/// Fold a single progress event into the span tree, stamped at
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs
index 2efcc7973f..d698765a73 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/model_call.rs
@@ -3,10 +3,10 @@
use std::collections::BTreeMap;
-use crate::agent::progress_tracing::serialize::{
+use tinyagents_harness::observability::trace_export::serialize::{
capture_model_content, json_f64, json_str, json_u32, json_u64,
};
-use crate::agent::progress_tracing::types::{SpanKind, SpanStatus};
+use tinyagents_harness::observability::trace_export::{SpanKind, SpanStatus};
use super::state::SpanCollector;
@@ -20,7 +20,7 @@ impl SpanCollector {
/// (`gen_ai.provider`) and the pricing basis the local estimator uses;
/// 2. record the captured request messages (incl. the system prompt) and
/// completion as the generation's input/output, gated on
- /// `capture_content` and truncated to [`crate::agent::progress_tracing::serialize::MAX_MODEL_CONTENT_CHARS`];
+ /// `capture_content` and truncated to [`tinyagents_harness::observability::trace_export::serialize::MAX_MODEL_CONTENT_CHARS`];
/// 3. accumulate reasoning / cache-creation tokens onto the root turn
/// span, which `TurnCostUpdated` (cumulative rollup) does not carry —
/// and, for child calls, roll model + usage onto the subagent span so
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/span_lifecycle.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/span_lifecycle.rs
index e7842aeeb1..ddb9e7dc48 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/span_lifecycle.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/span_lifecycle.rs
@@ -3,8 +3,8 @@
use std::collections::BTreeMap;
-use crate::agent::progress_tracing::serialize::{truncate_capture_text, MAX_TOOL_CONTENT_CHARS};
-use crate::agent::progress_tracing::types::SpanKind;
+use tinyagents_harness::observability::trace_export::serialize::{truncate_capture_text, MAX_TOOL_CONTENT_CHARS};
+use tinyagents_harness::observability::trace_export::SpanKind;
use super::state::SpanCollector;
@@ -144,7 +144,7 @@ impl SpanCollector {
self.close_span(
index,
end_unix_ms,
- crate::agent::progress_tracing::types::SpanStatus::Ok,
+ tinyagents_harness::observability::trace_export::SpanStatus::Ok,
BTreeMap::new(),
);
}
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
index 5de4871a88..28a09c1a85 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
@@ -2,7 +2,7 @@
use std::collections::BTreeMap;
-use crate::agent::progress_tracing::types::{SpanStatus, TraceContext, TraceSpan};
+use tinyagents_harness::observability::trace_export::{SpanStatus, TraceContext, TraceSpan};
/// When the in-flight model call streamed its first delta, for
/// time-to-first-token. Reset when a new iteration (model call) starts and
@@ -125,7 +125,7 @@ impl SpanCollector {
pub(super) fn open_span(
&mut self,
- kind: crate::agent::progress_tracing::types::SpanKind,
+ kind: tinyagents_harness::observability::trace_export::SpanKind,
name: impl Into<String>,
parent_span_id: Option<String>,
start_unix_ms: u64,
diff --git a/crates/openhuman-core/src/agent/progress_tracing/export.rs b/crates/openhuman-core/src/agent/progress_tracing/export.rs
index 5fa2ad999d..2380b69b2f 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/export.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/export.rs
@@ -6,8 +6,17 @@ use crate::config::Config;
use super::langfuse;
use super::otlp;
-use super::serialize::spans_to_ndjson;
-use super::types::{TraceContext, TraceSpan};
+use tinyagents_harness::observability::trace_export::serialize::{spans_to_ndjson, SpanEnvelope};
+use tinyagents_harness::observability::trace_export::{RunType, TraceContext, TraceSpan};
+use crate::config::schema::AgentTracingBackend;
+
+/// Map the configured backend onto the upstream NDJSON envelope.
+pub(crate) fn envelope_for(backend: AgentTracingBackend) -> SpanEnvelope {
+ match backend {
+ AgentTracingBackend::Otel => SpanEnvelope::Otel,
+ AgentTracingBackend::Langfuse => SpanEnvelope::Langfuse,
+ }
+}
/// Export finished spans per the [`AgentTracingConfig`]: append NDJSON to the
/// configured file, or emit to the application log when no path is set.
@@ -17,7 +26,7 @@ pub(crate) fn export_spans(config: &AgentTracingConfig, spans: &[TraceSpan]) {
if !config.enabled || spans.is_empty() {
return;
}
- let payload = spans_to_ndjson(config.backend, spans);
+ let payload = spans_to_ndjson(envelope_for(config.backend), spans);
match &config.export_path {
Some(path) => {
use std::io::Write as _;
@@ -159,7 +168,7 @@ pub(crate) async fn export_subagent_journal_trace(
.with_session_group(thread_id.unwrap_or(task_id).to_string())
.with_agent_id(agent_id.to_string())
.with_channel_source("subagent".to_string())
- .with_run_type(super::types::RunType::Subagent)
+ .with_run_type(RunType::Subagent)
.with_capture_content(config.observability.agent_tracing.capture_content)
.with_run_lineage(
Some(first.run_id.as_str().to_string()),
diff --git a/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs b/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs
index 59756f9a87..92abd7568a 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/journal_projection.rs
@@ -58,7 +58,8 @@
use tinyagents_harness::events::AgentEvent;
use tinyagents_harness::observability::AgentObservation;
-use super::{SpanCollector, TraceContext, TraceSpan};
+use super::SpanCollector;
+use tinyagents_harness::observability::trace_export::{TraceContext, TraceSpan};
use crate::agent::progress::AgentProgress;
use crate::tools::status::classify;
diff --git a/crates/openhuman-core/src/agent/progress_tracing/journal_projection_cost_rollup_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/journal_projection_cost_rollup_tests.rs
index 0662043f5a..f2a5948613 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/journal_projection_cost_rollup_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/journal_projection_cost_rollup_tests.rs
@@ -2,7 +2,7 @@
//! unknown-tool call, and the exhaustive no-op arms (openhuman#6148).
use super::*;
-use crate::agent::progress_tracing::TraceSpan;
+use tinyagents_harness::observability::trace_export::TraceSpan;
/// A top-level model call that journals usage: `ModelStarted` → `UsageRecorded`
/// → `ModelCompleted`, the order the agent loop emits them in
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs
index 69ff658aa7..ad3176b585 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse.rs
@@ -19,14 +19,13 @@
use std::time::Duration;
mod environment;
-mod ingestion_batch;
mod journal_export;
pub(crate) use environment::{environment_for_base, ingestion_url, skip_push};
pub(crate) use journal_export::journal_push_ready;
#[cfg(test)]
pub(crate) use journal_export::push_observations;
-pub(crate) use journal_export::root_subagent_observations;
+pub(crate) use tinyagents_harness::observability::trace_export::journal_export::root_subagent_observations;
use super::TraceContext;
#[cfg(test)]
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 c5b6313495..d1f4945718 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,244 +1,40 @@
//! Journal export: pushes a run's durable tinyagents observations through the
-//! tinyagents Langfuse exporter, stamping run lineage and trace attribution,
-//! gating content on `capture_content`, and folding the run-ledger telemetry
-//! aggregate into the batch.
-
-use std::borrow::Cow;
-
-use serde_json::{json, Map, Value};
-use tinyagents_harness::events::AgentEvent;
-use tinyagents_harness::observability::{AgentObservation, LangfuseClient, LangfuseTraceConfig};
+//! 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;
use crate::config::Config;
use crate::security::credentials::session_support::direct_backend_credential;
-use super::ingestion_batch::{new_event_id, split_ingestion_batch, LANGFUSE_MAX_BATCH_EVENTS};
-use super::TraceContext;
use super::{environment_for_base, ingestion_url, skip_push, LOG_TARGET, PUSH_TIMEOUT};
-/// Enrich `trace_ctx` with the run lineage (`run_id` / `parent_run_id` /
-/// `root_run_id`) carried by the run's journalled `observations` (#4657).
-///
-/// A single export corresponds to one run's observation stream (the journal is
-/// read per run id), so every observation shares the same lineage and the first
-/// is representative. For a spawned sub-agent that lineage points back at the
-/// spawning turn, which is exactly what links the sub-agent's trace to its
-/// parent. Returns the context unchanged when there are no observations.
-pub(super) fn trace_ctx_with_run_lineage(
- trace_ctx: &TraceContext,
- observations: &[AgentObservation],
-) -> TraceContext {
- let Some(first) = observations.first() else {
- return trace_ctx.clone();
- };
- trace_ctx.clone().with_run_lineage(
- trace_ctx
- .run_id
- .clone()
- .or_else(|| Some(first.run_id.as_str().to_string())),
- trace_ctx.parent_run_id.clone().or_else(|| {
- first
- .parent_run_id
- .as_ref()
- .map(|id| id.as_str().to_string())
- }),
- trace_ctx
- .root_run_id
- .clone()
- .or_else(|| Some(first.root_run_id.as_str().to_string())),
- )
-}
-
-/// A child is a root observation within its own trace. Preserve its original
-/// run lineage on the trace metadata before calling this projection.
-pub(crate) fn root_subagent_observations(
- observations: &[AgentObservation],
-) -> Vec<AgentObservation> {
- observations
- .iter()
- .cloned()
- .map(|mut observation| {
- observation.parent_run_id = None;
- observation.root_run_id = observation.run_id.clone();
- observation
- })
- .collect()
-}
-
-pub(super) fn trace_config_from_context(
- trace_ctx: &TraceContext,
- environment: &str,
-) -> LangfuseTraceConfig {
- let mut metadata = Map::new();
- if let Some(client_id) = &trace_ctx.client_id {
- metadata.insert("client.id".into(), json!(client_id));
- }
- if let Some(agent_id) = &trace_ctx.agent_id {
- metadata.insert("agent.id".into(), json!(agent_id));
- }
- if let Some(source) = &trace_ctx.channel_source {
- metadata.insert("channel.source".into(), json!(source));
- }
- metadata.insert("run_type".into(), json!(trace_ctx.run_type.as_str()));
- metadata.insert("app.version".into(), json!(env!("CARGO_PKG_VERSION")));
- // Run lineage (#4657): stamp the run/parent/root ids so a spawned sub-agent's
- // trace is navigable from — and threadable under — its parent turn. Omitted
- // keys (e.g. `parent_run_id` for a top-level turn) simply stay absent.
- if let Some(run_id) = &trace_ctx.run_id {
- metadata.insert("run_id".into(), json!(run_id));
- }
- if let Some(parent_run_id) = &trace_ctx.parent_run_id {
- metadata.insert("parent_run_id".into(), json!(parent_run_id));
- }
- if let Some(root_run_id) = &trace_ctx.root_run_id {
- metadata.insert("root_run_id".into(), json!(root_run_id));
- }
-
- let mut tags = vec![format!("run:{}", trace_ctx.run_type.as_str())];
- if let Some(source) = &trace_ctx.channel_source {
- tags.push(format!("source:{source}"));
- }
-
- LangfuseTraceConfig {
- trace_id: Some(trace_ctx.session_id.clone()),
- name: Some(match &trace_ctx.agent_id {
- Some(agent_id) => format!("agent.turn:{agent_id}"),
- None => "agent.turn".to_string(),
- }),
- user_id: trace_ctx.user_id.clone(),
- session_id: trace_ctx
- .session_group
- .clone()
- .or_else(|| Some(trace_ctx.session_id.clone())),
- environment: Some(environment.to_string()),
- release: Some(env!("CARGO_PKG_VERSION").to_string()),
- version: Some(env!("CARGO_PKG_VERSION").to_string()),
- tags,
- metadata: Value::Object(metadata),
+/// 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(),
}
}
-pub(super) fn observations_for_export<'a>(
- trace_ctx: &TraceContext,
- observations: &'a [AgentObservation],
-) -> Cow<'a, [AgentObservation]> {
- if trace_ctx.capture_content {
- return Cow::Borrowed(observations);
- }
-
- Cow::Owned(
- observations
- .iter()
- .cloned()
- .map(strip_observation_content)
- .collect(),
- )
-}
-
-fn strip_observation_content(mut observation: AgentObservation) -> AgentObservation {
- match &mut observation.event {
- AgentEvent::ModelCompleted { input, output, .. }
- | AgentEvent::ToolCompleted { input, output, .. } => {
- *input = None;
- *output = None;
- }
- _ => {}
- }
- observation
-}
-
-pub(super) fn insert_run_telemetry_generation(
- payload: &mut Value,
- telemetry: Option<&RunTelemetry>,
-) -> bool {
- let Some(telemetry) = telemetry else {
- return false;
- };
- if telemetry.input_tokens == 0 && telemetry.output_tokens == 0 && telemetry.cost_usd == 0.0 {
- return false;
- }
-
- let Some(batch) = payload.get_mut("batch").and_then(Value::as_array_mut) else {
- return false;
- };
- // Native per-call charges are already counted by Langfuse. Adding the
- // run aggregate as another generation would double-count the same spend.
- if batch.iter().any(|event| {
- event["type"] == "generation-create"
- && event["body"]["costDetails"]["total"].as_f64().is_some()
- }) {
- return false;
- }
- let Some(trace_id) = batch
- .first()
- .and_then(|event| event.get("body"))
- .and_then(|body| body.get("id"))
- .and_then(Value::as_str)
- .map(str::to_string)
- else {
- return false;
- };
- let start_time = batch
- .first()
- .and_then(|event| event.get("timestamp"))
- .and_then(Value::as_str)
- .unwrap_or_default()
- .to_string();
- let end_time = batch
- .last()
- .and_then(|event| event.get("timestamp"))
- .and_then(Value::as_str)
- .unwrap_or(start_time.as_str())
- .to_string();
-
- let non_cached_input = telemetry
- .input_tokens
- .saturating_sub(telemetry.cached_input_tokens);
- let mut body = json!({
- "id": format!("{trace_id}:openhuman-run-telemetry"),
- "traceId": trace_id,
- "name": "run.total",
- "startTime": start_time,
- "endTime": end_time,
- "usageDetails": {
- "input": non_cached_input,
- "output": telemetry.output_tokens,
- "total": telemetry.input_tokens.saturating_add(telemetry.output_tokens),
- "cache_read_input_tokens": telemetry.cached_input_tokens,
- },
- "costDetails": {
- "total": telemetry.cost_usd,
- },
- "metadata": {
- "source": "openhuman.run_telemetry",
- "run_id": telemetry.run_id.as_str(),
- "tool_count": telemetry.tool_count,
- },
- });
- if let Some(model) = &telemetry.model {
- body["model"] = json!(model);
- }
- if let Some(provider) = &telemetry.provider {
- body["metadata"]["provider"] = json!(provider);
- }
- if let Some(error) = &telemetry.error {
- body["level"] = json!("ERROR");
- body["statusMessage"] = json!(error);
- }
-
- batch.insert(
- 1,
- json!({
- "id": new_event_id(),
- "type": "generation-create",
- "timestamp": body["startTime"].clone(),
- "body": body,
- }),
- );
- true
-}
-
/// 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`
@@ -290,8 +86,9 @@ pub(crate) async fn push_observations(
};
// Stamp the run lineage from the run's own observations so a spawned
// sub-agent's trace links back to its parent turn (#4657).
+ let brand = crate::agent::progress_tracing::export_brand();
let trace_ctx = trace_ctx_with_run_lineage(trace_ctx, observations);
- let trace = trace_config_from_context(&trace_ctx, environment);
+ let trace = trace_config_from_context(&trace_ctx, environment, &brand);
let observation_count = observations.len();
let observations = observations_for_export(&trace_ctx, observations);
@@ -305,7 +102,11 @@ pub(crate) async fn push_observations(
let mut payload = client
.build_ingestion_batch(trace, observations.as_ref())
.map_err(|err| format!("Langfuse journal batch build failed: {err}"))?;
- if insert_run_telemetry_generation(&mut payload, run_telemetry) {
+ if insert_run_telemetry_generation(
+ &mut payload,
+ run_telemetry.map(run_totals).as_ref(),
+ &brand,
+ ) {
tracing::debug!(
target: LOG_TARGET,
"[agent-tracing] added run telemetry aggregate to Langfuse journal batch"
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 6bceb23bc2..bd10bd5ed0 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use std::collections::BTreeMap;
-use crate::agent::progress_tracing::SpanKind;
+use tinyagents_harness::observability::trace_export::SpanKind;
use tinyagents_harness::ids::{CallId, EventId, RunId};
use tinyinference_llm::usage::Usage;
diff --git a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_attribution_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_attribution_tests.rs
index ed69bc87be..ba1b6ee5b3 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_attribution_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_attribution_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::agent::progress_tracing::types::SpanKind;
+use tinyagents_harness::observability::trace_export::SpanKind;
// ── identity / attribution / content capture ───────────────────────────────
#[test]
diff --git a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_content_gate_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_content_gate_tests.rs
index cabc7a40be..e18d45824d 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_content_gate_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_content_gate_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use crate::agent::progress_tracing::serialize::{capture_model_content, MAX_MODEL_CONTENT_CHARS};
+use tinyagents_harness::observability::trace_export::serialize::{capture_model_content, MAX_MODEL_CONTENT_CHARS};
#[test]
fn subagent_content_is_withheld_when_capture_off() {
diff --git a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_span_tree_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_span_tree_tests.rs
index 429be231ba..2db7586b49 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_span_tree_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_span_tree_tests.rs
@@ -1,8 +1,8 @@
use super::*;
use crate::agent::progress_tracing::export::export_spans;
-use crate::agent::progress_tracing::serialize::spans_to_ndjson;
-use crate::agent::progress_tracing::types::SpanKind;
+use tinyagents_harness::observability::trace_export::serialize::{spans_to_ndjson, SpanEnvelope};
+use tinyagents_harness::observability::trace_export::SpanKind;
// ── config ────────────────────────────────────────────────────────────────
#[test]
@@ -468,7 +468,7 @@ fn no_user_attribution_omits_user_id() {
#[test]
fn ndjson_otel_emits_one_line_per_span() {
let spans = one_turn_spans();
- let out = spans_to_ndjson(AgentTracingBackend::Otel, &spans);
+ let out = spans_to_ndjson(SpanEnvelope::Otel, &spans);
assert_eq!(out.lines().count(), spans.len());
// Bare OTel span body has the fields directly.
let first: serde_json::Value = serde_json::from_str(out.lines().next().unwrap()).unwrap();
@@ -479,7 +479,7 @@ fn ndjson_otel_emits_one_line_per_span() {
#[test]
fn ndjson_langfuse_wraps_each_span_in_an_observation_envelope() {
let spans = one_turn_spans();
- let out = spans_to_ndjson(AgentTracingBackend::Langfuse, &spans);
+ let out = spans_to_ndjson(SpanEnvelope::Langfuse, &spans);
let first: serde_json::Value = serde_json::from_str(out.lines().next().unwrap()).unwrap();
assert_eq!(first["type"], serde_json::json!("span-create"));
assert_eq!(first["body"]["trace_id"], serde_json::json!("sess-42"));
@@ -487,7 +487,7 @@ fn ndjson_langfuse_wraps_each_span_in_an_observation_envelope() {
#[test]
fn ndjson_empty_for_empty_slice() {
- assert!(spans_to_ndjson(AgentTracingBackend::Otel, &[]).is_empty());
+ assert!(spans_to_ndjson(SpanEnvelope::Otel, &[]).is_empty());
}
#[test]
diff --git a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_ttft_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_ttft_tests.rs
index 89ef55040d..6571ba4b2a 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_ttft_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_ttft_tests.rs
@@ -3,8 +3,8 @@
use super::*;
-use crate::agent::progress_tracing::otlp::otlp_requests;
-use crate::agent::progress_tracing::types::SpanKind;
+use tinyagents_harness::observability::trace_export::otlp::otlp_requests;
+use tinyagents_harness::observability::trace_export::SpanKind;
fn iteration(iteration: u32) -> AgentProgress {
AgentProgress::IterationStarted {
@@ -131,7 +131,7 @@ fn otlp_exports_completion_start_time_for_langfuse_ttft() {
(completed(1), 1_700_000_001_000),
]);
let spans = c.spans().to_vec();
- let payloads = otlp_requests(&spans, "production");
+ let payloads = otlp_requests(&spans, "production", &crate::agent::progress_tracing::export_brand());
let exported = payloads[0]["resourceSpans"][0]["scopeSpans"][0]["spans"]
.as_array()
.unwrap();
diff --git a/crates/openhuman-core/src/web_chat/journal_shadow.rs b/crates/openhuman-core/src/web_chat/journal_shadow.rs
index ea8341cac1..b5a01cfe6a 100644
--- a/crates/openhuman-core/src/web_chat/journal_shadow.rs
+++ b/crates/openhuman-core/src/web_chat/journal_shadow.rs
@@ -15,7 +15,7 @@
//! crate journals no sub-agent events at all, so every delegating turn loses
//! that subtree on replay.
-fn span_projection_signature(spans: &[crate::agent::progress_tracing::TraceSpan]) -> Vec<String> {
+fn span_projection_signature(spans: &[tinyagents_harness::observability::trace_export::TraceSpan]) -> Vec<String> {
spans
.iter()
.map(|span| {
@@ -99,9 +99,9 @@ fn describe_signature_divergence(live: &[String], projected: &[String]) -> Strin
pub(super) async fn shadow_compare_journal_projection(
request_id: &str,
- trace_ctx: crate::agent::progress_tracing::TraceContext,
+ trace_ctx: tinyagents_harness::observability::trace_export::TraceContext,
max_iterations: u32,
- live_spans: &[crate::agent::progress_tracing::TraceSpan],
+ live_spans: &[tinyagents_harness::observability::trace_export::TraceSpan],
) -> Option<Vec<tinyagents_harness::observability::AgentObservation>> {
let Some(journal_run_id) =
crate::agent::tinyagents::journal::take_request_journal_run(request_id)
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index fb4caa92cc..370791cf70 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -378,8 +378,9 @@ pub(crate) fn spawn_progress_bridge(
let mut span_collector = if config.observability.share_usage_data
|| config.observability.agent_tracing.enabled
{
- use crate::agent::progress_tracing::{
- trace_session_id, RunType, SpanCollector, TraceContext,
+ use crate::agent::progress_tracing::SpanCollector;
+ use tinyagents_harness::observability::trace_export::{
+ trace_session_id, RunType, TraceContext,
};
// One trace per turn: the trace id is unique per request, while the
// thread id rides along as the Langfuse `sessionId` so a