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): record first-delta timestamps for time-to-first-token
Steven Enamakel016fd2df9458
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/events.rsindex 13ea7e5612..c1088a8e26 100644--- a/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs@@ -27,6 +27,7 @@ impl SpanCollector {max_iterations,} => {self.close_current_iteration(now_unix_ms);+ self.first_deltas = Default::default();let parent = self.ensure_turn_span(now_unix_ms);let mut attrs = BTreeMap::new();attrs.insert("agent.iteration".to_string(), json_u32(*iteration));@@ -195,6 +196,7 @@ impl SpanCollector {span_index: index,current_iteration_span_id: None,open_tools: BTreeMap::new(),+ first_deltas: Default::default(),},);}@@ -459,12 +461,23 @@ impl SpanCollector {// Content-bearing / streaming events carry prompt text, tool// arguments, or model output — never exported (privacy rule).- AgentProgress::TextDelta { .. }- | AgentProgress::ThinkingDelta { .. }- | AgentProgress::ToolCallArgsDelta { .. }- | AgentProgress::SubagentTextDelta { .. }- | AgentProgress::SubagentThinkingDelta { .. }- | AgentProgress::SubagentAwaitingUser { .. } => {}+ // Only *when* the first one arrived is kept, for time to first+ // token on the generation span.+ AgentProgress::TextDelta { .. } => self.first_deltas.observe(now_unix_ms, true),+ AgentProgress::ThinkingDelta { .. } | AgentProgress::ToolCallArgsDelta { .. } => {+ self.first_deltas.observe(now_unix_ms, false)+ }+ AgentProgress::SubagentTextDelta { task_id, .. } => {+ if let Some(state) = self.subagents.get_mut(task_id) {+ state.first_deltas.observe(now_unix_ms, true);+ }+ }+ AgentProgress::SubagentThinkingDelta { task_id, .. } => {+ if let Some(state) = self.subagents.get_mut(task_id) {+ state.first_deltas.observe(now_unix_ms, false);+ }+ }+ AgentProgress::SubagentAwaitingUser { .. } => {}}}diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rsindex 94d442a7f1..5de4871a88 100644--- a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs@@ -4,6 +4,28 @@ use std::collections::BTreeMap;use crate::agent::progress_tracing::types::{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+/// consumed when that call's usage is recorded.+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]+pub(super) struct FirstDeltas {+ /// First delta of any kind: reasoning, text or tool-call arguments.+ pub(super) any_unix_ms: Option<u64>,+ /// First visible text delta.+ pub(super) text_unix_ms: Option<u64>,+}++impl FirstDeltas {+ /// Stamp `now_unix_ms` as the first delta (and first text, when `is_text`)+ /// unless an earlier one is already recorded.+ pub(super) fn observe(&mut self, now_unix_ms: u64, is_text: bool) {+ self.any_unix_ms.get_or_insert(now_unix_ms);+ if is_text {+ self.text_unix_ms.get_or_insert(now_unix_ms);+ }+ }+}+/// Per-subagent bookkeeping so child iterations / tool calls nest correctly.#[derive(Debug)]pub(super) struct SubagentState {@@ -13,6 +35,8 @@ pub(super) struct SubagentState {pub(super) current_iteration_span_id: Option<String>,/// Open child tool spans keyed by `call_id` → span index.pub(super) open_tools: BTreeMap<String, usize>,+ /// First streamed delta of the child's in-flight model call.+ pub(super) first_deltas: FirstDeltas,}/// Pure state machine that folds an [`crate::agent::progress::AgentProgress`]@@ -42,6 +66,8 @@ pub struct SpanCollector {pub(super) open_tools: BTreeMap<String, usize>,/// Live subagents keyed by `task_id`.pub(super) subagents: BTreeMap<String, SubagentState>,+ /// First streamed delta of the parent turn's in-flight model call.+ pub(super) first_deltas: FirstDeltas,}impl SpanCollector {@@ -57,6 +83,7 @@ impl SpanCollector {current_iteration_index: None,open_tools: BTreeMap::new(),subagents: BTreeMap::new(),+ first_deltas: FirstDeltas::default(),}}