Skip to content

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

feat(session): record how a turn stopped on the session sidecar

Steven Enamakelea67d9b9f776
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 11a151b3a4..35861472b5 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -400,6 +400,20 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
observed.tool_outcomes = outcome.tool_outcomes.clone();
observed.hit_cap = outcome.hit_cap;
observed.wrap_up_injected = outcome.wrap_up_injected;
+ // How the harness stopped the turn, if it did. The wind-down
+ // middleware marked the sidecar during the run.
+ observed.stop = crate::agent::turn_stop::TurnStop::classify(
+ outcome.breaker_halt.as_deref(),
+ observed.wind_down,
+ outcome.hit_cap,
+ );
+ if let Some(stop) = &observed.stop {
+ tracing::debug!(
+ model = %self.model_name,
+ "[session-driver] turn stopped early; recording on the sidecar {}",
+ stop.status_message()
+ );
+ }
observed.resolved_route = outcome.resolved_route.clone();
}
// The turn compacted its context: persist the compacted history, so the
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs
index e1594b003b..ca7e01a0fa 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_failure_policy_class_tests.rs
@@ -244,3 +244,55 @@ fn production_read_tools_time_out_as_transient() {
);
}
}
+
+// ── a browser task that ended without finishing ─────────────────────────────
+
+#[test]
+fn a_failed_browser_task_gets_one_changed_attempt_not_a_credential_halt() {
+ // The task's own prose (a page's 403, a planner's timeout) is the task's
+ // report, not the tool call's verdict: nothing about the call is
+ // uncertain, the task says what it did and what to change.
+ for reason in [
+ "Planning failed: the planner returned no steps",
+ "the site answered 403 Forbidden on the login page",
+ "the planner timed out choosing the next step",
+ ] {
+ let error = format!(
+ "{} Browser task failed at step 1: {reason} Hint: narrow the goal",
+ crate::tools::status::TASK_FAILED_MARKER
+ );
+ assert_eq!(
+ recovery_policy("browser", &error, false),
+ Some(("task_failed", 1)),
+ "{reason}"
+ );
+ }
+ // A model gateway failing under the rescuer is transient.
+ let error = format!(
+ "{} Browser task failed at step 3: the rescuer gave up: rescue model returned HTTP 504",
+ crate::tools::status::TASK_FAILED_MARKER
+ );
+ assert_eq!(
+ recovery_policy("browser", &error, false),
+ Some(("transient", 2))
+ );
+}
+
+#[tokio::test]
+async fn a_failed_browser_task_nudges_toward_its_hint_then_stops_on_a_repeat() {
+ let (mw, handle, slot) = breaker();
+ let error = format!(
+ "{} Browser task failed at step 1: Planning failed Hint: name the exact button",
+ crate::tools::status::TASK_FAILED_MARKER
+ );
+ let args = serde_json::json!({"action": "task", "goal": "book it", "url": "https://shop.test/"});
+ run_call(&mw, "task-1", "browser", args.clone(), Err(&error)).await;
+ assert_eq!(drain_pause_count(&handle), 0);
+ let nudges = drain_nudge_messages(&mw);
+ assert_eq!(nudges.len(), 1, "{nudges:?}");
+ assert!(nudges[0].contains("hint"), "{nudges:?}");
+ run_call(&mw, "task-2", "browser", args, Err(&error)).await;
+ assert_eq!(drain_pause_count(&handle), 1);
+ let summary = slot.lock().unwrap().clone().unwrap();
+ assert!(summary.contains("task_failed"), "{summary}");
+}