Skip to content

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

feat(browser-task): add task report endpoint and live-test diagnostics

Steven Enamakel83b42403e3aa
diff --git a/crates/openhuman-core/src/modules/browser_task.rs b/crates/openhuman-core/src/modules/browser_task.rs
index 3a58410acc..206d9ea171 100644
--- a/crates/openhuman-core/src/modules/browser_task.rs
+++ b/crates/openhuman-core/src/modules/browser_task.rs
@@ -14,7 +14,8 @@ use std::time::{Duration, Instant};
use serde::{de::DeserializeOwned, Serialize};
use tinycomputer_bus::agent::{
names::methods, AgentResponse, AwaitTaskRequest, ContinueTaskRequest, PaymentMode,
- StartTaskRequest, SurfaceKind, TaskBudget, TaskConstraints, TaskId, TaskRef, TaskView,
+ StartTaskRequest, SurfaceKind, TaskBudget, TaskConstraints, TaskId, TaskRef, TaskReport,
+ TaskReportRequest, TaskView,
};
use crate::config::Config;
@@ -126,6 +127,23 @@ pub async fn cancel(config: &Config, id: TaskId) -> Result<TaskView, String> {
call(config, methods::CANCEL_TASK, TaskRef { id }, false).await
}
+/// The task's record: its steps, what it collected, and every rescue. Page
+/// data can appear in it, so it is fetched confidentially and without the Jev
+/// trace.
+///
+/// # Errors
+///
+/// Returns a module or transport error.
+pub async fn report(config: &Config, id: TaskId) -> Result<TaskReport, String> {
+ call(
+ config,
+ methods::TASK_REPORT,
+ TaskReportRequest { id, trace: false },
+ true,
+ )
+ .await
+}
+
async fn follow(config: &Config, mut view: TaskView) -> Result<TaskView, String> {
let deadline = Instant::now() + Duration::from_secs(config.browser.task_timeout_secs.max(1));
while matches!(view.status, tinycomputer_bus::agent::TaskStatus::Running) {
diff --git a/tests/computer_bali_live_e2e.rs b/tests/computer_bali_live_e2e.rs
index 3ca1f450e3..d2a083ea6f 100644
--- a/tests/computer_bali_live_e2e.rs
+++ b/tests/computer_bali_live_e2e.rs
@@ -62,6 +62,30 @@ fn config(workspace: &std::path::Path) -> Config {
config
}
+/// Print what the task did and every rescue, so a failed live run says why.
+async fn print_report(config: &Config, view: &TaskView) {
+ match browser_task::report(config, view.id.clone()).await {
+ Ok(report) => {
+ for (index, step) in report.steps.iter().enumerate() {
+ println!(
+ " step {index}: {}",
+ serde_json::to_string(step).unwrap_or_default()
+ );
+ }
+ for rescue in &report.rescues {
+ println!(
+ " rescue of step {}: {:?} — {} ({})",
+ rescue.step, rescue.outcome, rescue.reason, rescue.failure
+ );
+ }
+ if report.rescues.is_empty() {
+ println!(" no rescues");
+ }
+ }
+ Err(error) => println!(" report unavailable: {error}"),
+ }
+}
+
fn summarize(view: &TaskView) -> String {
let step = view
.step
@@ -194,6 +218,7 @@ async fn books_a_bali_flight_up_to_the_payment_page() {
..
} => {
println!("checkpoint at {location}: {reason}\n{summary}");
+ print_report(&config, &view).await;
assert!(
location.contains("goindigo") || reason.to_lowercase().contains("pay"),
"stopped at an unexpected checkpoint: {reason} ({location})"
@@ -209,7 +234,10 @@ async fn books_a_bali_flight_up_to_the_payment_page() {
panic!("task needs a person: {reason}");
}
TaskStatus::NeedsPlan { .. } => panic!("the planner is not configured"),
- TaskStatus::Failed { reason, hint, .. } => panic!("task failed: {reason} ({hint})"),
+ TaskStatus::Failed { reason, hint, .. } => {
+ print_report(&config, &view).await;
+ panic!("task failed: {reason} ({hint})")
+ }
TaskStatus::Cancelled => panic!("task was cancelled"),
}
}