Skip to content

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

Merge remote-tracking branch 'upstream/main' into tiny-dep-tinyagents-2

Steven Enamakel9f9518006af2
diff --cc crates/openhuman-core/src/agent/session_host/driver.rs
index 722a323751,7c6686db1a..c4630b8bb7
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@@ -268,20 -271,35 +268,35 @@@ impl SessionDriver<OpenHumanRunContext
// done by, so the turn commits before the backstop drops it.
let close_by = request.run_context.data.turn_deadline.map(|deadline| {
let now = Instant::now();
- now + deadline.close_budget(now)
+ now + crate::agent::turn_deadline::close_budget(&deadline, now)
});
- let close = grounded_close::close_if_needed(
- &self.turn_model_source,
- &self.model_name,
- self.temperature,
- request.run_context.data.thread_id.as_deref(),
- self.dispatcher.as_ref(),
- &request.history,
- &user_message,
- &outcome,
- close_by.map(|at| at.saturating_duration_since(Instant::now())),
- )
- .await;
+ // A Stop during the close or the repair after it hands back the
+ // accepted rounds like a Stop during the loop, instead of letting the
+ // runtime's grace expire and drop the turn (#7776).
+ let accepted_history = request.history.clone();
+ let stopped = || {
+ driver_cancelled_with_snapshot(
+ &snapshot,
+ &sidecar,
+ started.elapsed(),
+ accepted_history.clone(),
+ )
+ };
+ let close = tokio::select! {
+ biased;
+ _ = cancellation.cancelled() => return Err(stopped()),
+ close = grounded_close::close_if_needed(
+ &self.turn_model_source,
+ &self.model_name,
+ self.temperature,
+ request.run_context.data.thread_id.as_deref(),
+ self.dispatcher.as_ref(),
+ &request.history,
+ &user_message,
+ &outcome,
+ close_by.map(|at| at.saturating_duration_since(Instant::now())),
+ ) => close,
+ };
let mut output = close
.as_ref()
.map(|close| close.output.clone())