Skip to content

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

test(agent): pin how a generic run failure maps onto its provider error

M3gA-Mind6899a87ccb1f
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs
index a3fe304635..df3bd4ad67 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_error_tests.rs
@@ -74,3 +74,34 @@ async fn physical_dispatch_refusal_keeps_its_typed_reason_ahead_of_stale_provide
);
assert!(slot.lock().unwrap().is_none());
}
+
+#[tokio::test]
+async fn any_other_run_failure_re_surfaces_the_typed_provider_error_from_the_slot() {
+ // A run that failed for any other reason re-surfaces the provider error
+ // the model adapter recorded, typed, so callers keep their downcasts and
+ // the user sees the real cause; the slot is consumed.
+ let slot: ModelErrorSlot = std::sync::Arc::new(std::sync::Mutex::new(Some(
+ tinyinference_llm::Error::Model("OpenHuman returned HTTP 402: insufficient credits".into()),
+ )));
+ let other = || tinyagents_harness::TinyAgentsError::MissingNode("agent".into());
+
+ let mapped = map_turn_run_error(other(), "m", 10, &slot, None).await;
+ assert!(
+ matches!(
+ mapped.downcast_ref::<tinyinference_llm::Error>(),
+ Some(tinyinference_llm::Error::Model(message)) if message.contains("402")
+ ),
+ "expected the typed provider error, got: {mapped}"
+ );
+ assert!(slot.lock().unwrap().is_none(), "the slot must be consumed");
+
+ // With nothing recorded, the harness's own error is reported.
+ let mapped = map_turn_run_error(other(), "m", 10, &slot, None).await;
+ assert!(mapped.downcast_ref::<tinyinference_llm::Error>().is_none());
+ assert!(
+ mapped
+ .to_string()
+ .starts_with("tinyagents harness run failed:"),
+ "{mapped}"
+ );
+}