Skip to content

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

feat(agent): trace progress through tinyagents harness

Steven Enamakele542f21bec8b
diff --git a/crates/openhuman-core/src/agent/progress_tracing.rs b/crates/openhuman-core/src/agent/progress_tracing.rs
index 3e5b32b13e..e06c7ec766 100644
--- a/crates/openhuman-core/src/agent/progress_tracing.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing.rs
@@ -72,7 +72,7 @@ use tinyagents_harness::observability::trace_export::{RunType, TraceContext, Tra
#[cfg(test)]
use tinyagents_harness::observability::trace_export::{SpanKind, SpanStatus};
-pub use collector::SpanCollector;
+pub use collector::{SpanCollector, TurnOutcome};
/// Product identity stamped onto exported telemetry (OTLP service name, scope,
/// Langfuse release/version and run-total labels).
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
index 3434924b2c..dd1943b305 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
@@ -47,16 +47,13 @@ impl SpanCollector {
self.apply_turn_outcome(outcome.unwrap_or(TurnOutcome::Incomplete), end);
}
}
- // Children before parents: spans are appended in open order, so a
- // reverse sweep closes a tool before the iteration/subagent above it
- // and the parent's end is final by the time a child reads it... except
- // that a parent still open here has no end yet; it is bounded by the
- // last activity, as is the child.
+ // A span still open is bounded by its parent's end when the parent
+ // already closed (a tool under a finished iteration ran no later than
+ // the next model call), else by the last event seen.
let open: Vec<usize> = (0..self.spans.len())
- .rev()
.filter(|&idx| self.spans[idx].end_unix_ms.is_none())
.collect();
- let fallback_end = self.last_activity_unix_ms.min(end).max(1);
+ let fallback_end = self.last_activity_unix_ms.min(end);
for idx in open {
self.force_close(idx, fallback_end);
}
@@ -170,7 +167,6 @@ impl SpanCollector {
};
let end = parent_end
.filter(|end| *end >= start)
- .map(|end| end.min(fallback_end.max(start)))
.unwrap_or(fallback_end);
let mut extra = BTreeMap::new();
if matches!(kind, SpanKind::Tool | SpanKind::Subagent) {
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/mod.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/mod.rs
index f00d0c0830..e18a78d859 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/mod.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/mod.rs
@@ -1,11 +1,14 @@
//! The [`SpanCollector`] state machine: data shape and construction
//! ([`state`]), turn/parent bootstrap and content capture ([`span_lifecycle`]),
-//! generation-span folding ([`model_call`]), and the public event-fold +
-//! finish API ([`events`]).
+//! generation-span folding ([`model_call`], attribute shaping in
+//! [`generation`]), the public event fold ([`events`]), and sealing the tree
+//! with the turn's outcome ([`finish`]).
mod events;
+mod finish;
+mod generation;
mod model_call;
mod span_lifecycle;
mod state;
-pub use state::SpanCollector;
+pub use state::{SpanCollector, TurnOutcome};
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
index a39334613e..7480c2382a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
@@ -194,6 +194,9 @@ pub(super) fn assemble_turn_harness(
"[models] assembling turn harness with SDK retry/fallback policy"
);
harness.with_policy(policy);
+ // Per-tool deadlines (`ToolTimeout` policies) are enforced only when the
+ // host installs the shared settings; see `install_harness_tool_timeouts`.
+ crate::tools::timeout::install_harness_tool_timeouts(&mut harness);
// Deterministic internal runs (summarizer/triage/memory-scoring style) may
// reuse a prior identical model response; attach an in-memory response cache
// so the agent loop can short-circuit a recurring provider call and emit
diff --git a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
index b9939f016a..79e2cfd1d4 100644
--- a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
@@ -65,6 +65,7 @@ pub(crate) fn assemble_live_tool_harness(
} = surface;
let mut harness: AgentHarness<(), OpenHumanRunContext> = AgentHarness::new();
harness.with_policy(run_policy_for(LIVE_MAX_TOOL_CALLS, false));
+ crate::tools::timeout::install_harness_tool_timeouts(&mut harness);
let mut capability_registry: CapabilityRegistry<()> = CapabilityRegistry::new();
let (tool_count, names, diagnostics, _snapshot) = register_turn_tools_and_agents(
diff --git a/crates/openhuman-core/src/tools/timeout/mod.rs b/crates/openhuman-core/src/tools/timeout/mod.rs
index d5727a125a..fa9b9e13e7 100644
--- a/crates/openhuman-core/src/tools/timeout/mod.rs
+++ b/crates/openhuman-core/src/tools/timeout/mod.rs
@@ -62,6 +62,39 @@ fn settings() -> &'static ToolTimeoutSettings {
})
}
+/// Install the process-global per-tool timeout settings on `harness`.
+///
+/// The harness enforces a tool's [`ToolTimeout`] policy only when settings are
+/// installed (`AgentHarness::with_tool_timeout_settings`); without them every
+/// `Inherit` tool — MCP calls, `use_skill` dispatches, integration actions —
+/// ran until the run's wall-clock budget, so a hung call blocked the turn for
+/// ~600s instead of failing at the configured 120s (regressed when the host's
+/// own adapter deadline was removed in f33a398faa). The installed value is a
+/// clone of the shared settings, so later [`set_tool_timeout_secs`] pushes
+/// reach already-assembled harnesses on their next tool call.
+///
+/// Long-running tools opt out through their own policy rather than here:
+/// scripting tools (`shell`, `node_exec`, …) are `Unbounded` unless the call
+/// passes `timeout_secs`, media generation carries its own budget, and
+/// `composio_connect` / `browser` size theirs to the approval park they wait
+/// on inside `execute`.
+pub fn install_harness_tool_timeouts<State: Send + Sync, Ctx: Send + Sync>(
+ harness: &mut tinyagents_harness::runtime::AgentHarness<State, Ctx>,
+) {
+ install_with(harness, settings().clone());
+}
+
+fn install_with<State: Send + Sync, Ctx: Send + Sync>(
+ harness: &mut tinyagents_harness::runtime::AgentHarness<State, Ctx>,
+ settings: ToolTimeoutSettings,
+) {
+ tracing::debug!(
+ inherited_secs = settings.inherited_timeout().map_or(0, |d| d.as_secs()),
+ "[tool_timeout] installing per-tool timeout settings on the harness"
+ );
+ harness.with_tool_timeout_settings(settings);
+}
+
/// Parse a raw env-var value into a bounded timeout.
///
/// Testable split from the global resolution: this function is pure and never