Skip to content

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

refactor(web_chat): drop live span collector from progress bridge

Steven Enamakel73fa1fe529b6
diff --git a/crates/openhuman-core/src/agent/tinyagents/journal.rs b/crates/openhuman-core/src/agent/tinyagents/journal.rs
index e8c3c512ae..a3c95dcb07 100644
--- a/crates/openhuman-core/src/agent/tinyagents/journal.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/journal.rs
@@ -338,7 +338,7 @@ fn cross_run_event_order(event: &tinyagents_harness::events::AgentEvent) -> u8 {
AgentEvent::SubAgentRunStarted { .. } => 0,
AgentEvent::RunCompleted { .. } => 4,
AgentEvent::SubAgentRunCompleted { .. } => 3,
- AgentEvent::RunFailed { .. } | AgentEvent::RunCancelled { .. } => 2,
+ AgentEvent::RunFailed { .. } => 2,
_ => 1,
}
}
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index ce3671d9d1..af0be1c670 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -280,8 +280,8 @@ pub(crate) fn spawn_progress_bridge(
TurnStateMirror::new(turn_state_store, thread_id.clone(), request_id.clone());
// #3886: structured tracing export (`progress_bridge_trace.rs`).
- let (mut span_collector, mut journal_trace_ctx) =
- trace::span_collector(&config, &metadata, &client_id, &thread_id, &request_id).unzip();
+ let mut journal_trace_ctx =
+ trace::trace_context(&config, &metadata, &client_id, &thread_id, &request_id);
// #4270: emit a periodic liveness beat for the whole in-flight turn so
// the frontend silence timer never false-fires during a long prefill or
@@ -329,9 +329,6 @@ pub(crate) fn spawn_progress_bridge(
};
events_seen += 1;
turn_state.observe(&event);
- if let Some(collector) = span_collector.as_mut() {
- collector.record(&event, unix_epoch_ms());
- }
match &event {
AgentProgress::TextDelta { delta, iteration } => {
log::trace!(
@@ -1066,35 +1063,16 @@ pub(crate) fn spawn_progress_bridge(
// publishing an error. Trace export is best-effort I/O and must not
// hold up terminal delivery after the progress stream closed.
let _ = drained_tx.send(true);
- if let Some(mut collector) = span_collector.take() {
- collector.finish(unix_epoch_ms());
- let live_spans = collector.spans().to_vec();
- let journal_export = if let Some(trace_ctx) = journal_trace_ctx.take() {
- super::journal_shadow::shadow_compare_journal_projection(
- &dispatch_ctx,
- &request_id,
- trace_ctx.clone(),
- parent_max_iterations,
- &live_spans,
- )
- .await
- .map(|observations| (trace_ctx, observations))
- } else {
- None
- };
- if let Some((trace_ctx, observations)) = journal_export {
- let run_telemetry = ledger_get_telemetry(&config, &request_id);
- crate::core::observability::progress_tracing::export_run_trace_from_journal(
- &config,
- &trace_ctx,
- &observations,
- run_telemetry.as_ref(),
- &live_spans,
- )
- .await;
- } else {
- crate::core::observability::progress_tracing::export_run_trace(&config, &live_spans).await;
- }
+ if let Some(trace_ctx) = journal_trace_ctx.take() {
+ let run_telemetry = ledger_get_telemetry(&config, &request_id);
+ crate::core::observability::progress_tracing::export_run_trace_from_journal(
+ &dispatch_ctx,
+ &config,
+ &request_id,
+ trace_ctx,
+ run_telemetry.as_ref(),
+ )
+ .await;
}
log::debug!(
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge_trace.rs b/crates/openhuman-core/src/web_chat/progress_bridge_trace.rs
index 79dacccfb0..197aec8b6d 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge_trace.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge_trace.rs
@@ -5,20 +5,19 @@
//! thread id for headless/autonomous runs). Disabled (both the remote and the
//! local exporter off), it costs nothing.
-use crate::core::observability::progress_tracing::SpanCollector;
use tinyagents_harness::observability::trace_export as te;
use super::super::types::ChatRequestMetadata;
/// The span collector for the turn, and the trace context the journal export
/// reuses after the turn ends. `None` when tracing is disabled.
-pub(super) fn span_collector(
+pub(super) fn trace_context(
config: &crate::config::Config,
metadata: &ChatRequestMetadata,
client_id: &str,
thread_id: &str,
request_id: &str,
-) -> Option<(SpanCollector, te::TraceContext)> {
+) -> Option<te::TraceContext> {
if !(config.observability.share_usage_data || config.observability.agent_tracing.enabled) {
return None;
}
@@ -70,5 +69,5 @@ pub(super) fn span_collector(
if let Some(agent_id) = metadata.agent_id.clone() {
trace_ctx = trace_ctx.with_agent_id(agent_id);
}
- Some((SpanCollector::new(trace_ctx.clone()), trace_ctx))
+ Some(trace_ctx)
}