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
fix(session_host): return accepted rounds when stopped during close
Steven Enamakel566642519d05
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rsindex bbbc1ea9da..3c2d6ef5cc 100644--- a/crates/openhuman-core/src/agent/session_host/driver.rs+++ b/crates/openhuman-core/src/agent/session_host/driver.rs@@ -273,18 +273,32 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {let now = Instant::now();now + deadline.close_budget(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 stopped = || {+ driver_cancelled_with_snapshot(+ &snapshot,+ &sidecar,+ started.elapsed(),+ request.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())@@ -350,20 +364,25 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {outcome.model_calls.saturating_add(1) as u32,&mut repair_usage,);- match time_left {- Some(left) => {- // Bound to what is left so the turn still commits; on- // expiry fall back to the deterministic block.- let repaired = tokio::time::timeout(left, repair).await;- match repaired {- Ok(repaired) => repaired,- Err(_) => {- append_synthesized_block(&mut output, &mut history, contract);- None- }+ tokio::pin!(repair);+ let repaired = tokio::select! {+ biased;+ _ = cancellation.cancelled() => return Err(stopped()),+ repaired = async {+ match time_left {+ // Bound to what is left so the turn still commits;+ // on expiry fall back to the deterministic block.+ Some(left) => tokio::time::timeout(left, &mut repair).await.ok(),+ None => Some((&mut repair).await),}+ } => repaired,+ };+ match repaired {+ Some(repaired) => repaired,+ None => {+ append_synthesized_block(&mut output, &mut history, contract);+ None}- None => repair.await,}}None => None,