Skip to content

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

refactor(agent): extract run loop helpers into dedicated functions

Steven Enamakel7fa67782dc94
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs
index 7108e99bbc..7a437b0721 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/run_loop.rs
@@ -75,6 +75,11 @@ impl OpenHumanSessionHost {
}
let history_snapshot = self.history();
+ // Busy state for background-result delivery is marked here, in the
+ // turn's own (profile) scope; the bus subscriber runs off-task.
+ crate::agent::orchestration::background_delivery::note_turn_started(
+ self.event_session_id(),
+ );
BUS.publish(DomainEvent::AgentTurnStarted {
session_id: self.event_session_id().to_string(),
channel: self.event_channel().to_string(),
@@ -84,6 +89,9 @@ impl OpenHumanSessionHost {
Ok(response) => {
let history = self.history();
let new_entries = Self::new_entries_for_turn(&history_snapshot, &history);
+ crate::agent::orchestration::background_delivery::note_turn_ended(
+ self.event_session_id(),
+ );
BUS.publish(DomainEvent::AgentTurnCompleted {
session_id: self.event_session_id().to_string(),
text_chars: response.chars().count(),