Skip to content

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

feat(agent): classify delegated task failures with a dedicated retry policy

Steven Enamakelacd43dd41b9e
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/failure_policy.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/failure_policy.rs
index fcd8c628bf..49d899e032 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/failure_policy.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/failure_policy.rs
@@ -197,6 +197,23 @@ pub(super) fn classified_recovery_policy(
if is_command_exit_report(error) {
return None;
}
+ // A delegated task (a TinyComputer browser task) that ended without
+ // finishing. The call itself is not uncertain: the task reports what it
+ // did and what to change, and its prose (a page's `403`, a planner's
+ // `timed out`) is that report, not the call's verdict, so keyword
+ // sniffing must not turn it into a zero-retry credential or uncertain
+ // class. One changed attempt; a model gateway failing under the task
+ // (5xx, connection) is transient like any other.
+ if error
+ .trim_start()
+ .starts_with(crate::tools::status::TASK_FAILED_MARKER)
+ {
+ let class = crate::tools::status::classify(error, false).class;
+ return Some(match class {
+ Class::ServiceUnavailable | Class::ModelConnection => ("transient", 2),
+ _ => ("task_failed", 1),
+ });
+ }
// A module the host could not load stays unloaded until the app restarts,
// so retrying the same tool cannot help. Steer the model off it once
// rather than halting the run on the first call or spending a transient
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
index 255fcd2d44..bacfeb7a85 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -435,6 +435,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
"site_refused",
"policy",
"blocked_by_policy",
+ "task_failed",
"unsupported",
"missing_window",
"missing_app",
@@ -481,6 +482,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
| "unavailable"
| "service_refused"
| "blocked_by_policy"
+ | "task_failed"
) {
let instruction = match class {
"service_refused" => format!(
@@ -491,6 +493,10 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
"The `{tool_name}` call was blocked by policy and did not run ({}). Try one narrower, permitted alternative (a scoped path, a bounded command, a read instead of a write) or continue with other tools; do not resend it unchanged. Another refusal of this operation ends the turn.",
first_error_line(&failure_text)
),
+ "task_failed" => format!(
+ "The `{tool_name}` task ended without finishing ({}). Follow its hint once: change the goal, inputs or starting point it names, or continue with other tools. Do not rerun it unchanged.",
+ first_error_line(&failure_text)
+ ),
"validation" => "The last call failed validation. Correct its schema or arguments once before trying again.".to_owned(),
"invalid_arguments" => format!(
"The `{tool_name}` call was rejected before it ran: its arguments did not match the tool's schema ({}). Read the tool's parameters and correct the call; do not resend it unchanged.",