Skip to content

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

test(tinyagents): cover hosted dispatch refusal conversion

Steven Enamakel54d7f90d4317
diff --git a/crates/openhuman-core/src/agent/tinyagents/hosted_error_tests.rs b/crates/openhuman-core/src/agent/tinyagents/hosted_error_tests.rs
index 8e037a1b23..419484f336 100644
--- a/crates/openhuman-core/src/agent/tinyagents/hosted_error_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/hosted_error_tests.rs
@@ -5,6 +5,7 @@ fn hosted(kind: HostedErrorKind, bound: Option<TimeoutBound>) -> HostedError {
kind,
message: "hosted agent invocation timed out".to_string(),
timeout_bound: bound,
+ dispatch_refusal: None,
run: None,
}
}
@@ -52,3 +53,23 @@ fn a_non_timeout_failure_is_converted_as_before() {
assert!(matches!(err, TinyAgentsError::Model(_)));
assert_eq!(TurnTimeoutBound::from_message(&err.to_string()), None);
}
+
+#[test]
+fn a_hosted_physical_dispatch_refusal_keeps_its_typed_reason() {
+ let refusal = crate::agent::tinyagents::budget::DispatchRefusal::new(
+ crate::agent::tinyagents::budget::DispatchRefusalReason::CallLimit,
+ );
+ let error = HostedError {
+ kind: HostedErrorKind::LimitExceeded,
+ message: "hosted agent invocation exceeded a configured limit".to_string(),
+ timeout_bound: None,
+ dispatch_refusal: Some(refusal),
+ run: None,
+ };
+
+ assert!(matches!(
+ run_error_from_hosted(error),
+ TinyAgentsError::PhysicalDispatchAdmission(actual)
+ if actual.reason() == refusal.reason()
+ ));
+}
diff --git a/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs
index 05786a009b..c8928914b2 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs
@@ -659,6 +659,7 @@ fn hosted_timeout_bound_reaches_the_sentry_tag_and_keeps_the_user_class() {
kind: HostedErrorKind::Timeout,
message: "hosted agent invocation timed out".to_string(),
timeout_bound: Some(bound),
+ dispatch_refusal: None,
run: None,
};
let err = crate::agent::tinyagents::hosted_error::run_error_from_hosted(hosted);