Skip to content

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

fix(agent): handle missing context in agent prepare context tool

Steven Enamakel185e33b6f2d4
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs b/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs
index e3c57834a8..5f12633034 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context/tool.rs
@@ -305,6 +305,7 @@ impl AgentPrepareContextTool {
.map(str::to_owned),
run_context,
live_parent,
+ crate::tools::host_extensions::tool_call_id(tool_context),
)
.await
}
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index 0b7b76ca56..e8c86b2b23 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -52,6 +52,11 @@ pub(crate) const BRIDGE_DRAIN_TIMEOUT: std::time::Duration = std::time::Duration
#[derive(Clone)]
pub(crate) struct ProgressBridgeHandle {
drained: tokio::sync::watch::Receiver<bool>,
+ /// Set once, from inside the bridge task, when the turn's
+ /// `AgentProgress::TurnCompleted` arrives (`TurnTiming::snapshot()`).
+ /// Read by the caller after `wait_drained` so the same numbers the
+ /// `time-to-first-visible` log line reports reach `chat_done.timing`.
+ timing: std::sync::Arc<std::sync::Mutex<Option<super::turn_timing::TurnTimingSnapshot>>>,
}
impl ProgressBridgeHandle {
@@ -64,6 +69,13 @@ impl ProgressBridgeHandle {
// A dropped sender means the bridge task ended, which is drained too.
matches!(result, Ok(Ok(_)) | Ok(Err(_)))
}
+
+ /// The turn's timing snapshot, if the bridge saw a `TurnCompleted` before
+ /// its channel closed. `None` for a turn that errored/was interrupted
+ /// before completing a round, or was never polled after completion.
+ pub(crate) fn timing_snapshot(&self) -> Option<super::turn_timing::TurnTimingSnapshot> {
+ self.timing.lock().ok().and_then(|guard| *guard)
+ }
}
/// Flush the parent agent's accumulated leading narration (streamed before a