Skip to content

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

refactor(tinyagents): simplify hosted timeout error conversion

Steven Enamakelc47c4da73c19
diff --git a/crates/openhuman-core/src/agent/tinyagents/hosted_error.rs b/crates/openhuman-core/src/agent/tinyagents/hosted_error.rs
index cda08f21b9..2eacb6fe6a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/hosted_error.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/hosted_error.rs
@@ -17,32 +17,24 @@ use tinyagents_harness::agent_error::TurnTimeoutBound;
pub(super) fn turn_timeout_bound(bound: TimeoutBound) -> TurnTimeoutBound {
match bound {
TimeoutBound::PerModelCall => TurnTimeoutBound::PerModelCall,
- // `TimeoutBound` is non-exhaustive; any other bound is a run-level one.
_ => TurnTimeoutBound::RunRemaining,
}
}
/// Convert a hosted failure into the run error the turn pipeline maps.
///
-/// Identical to `TinyAgentsError::from(error)` except that a timeout names the
-/// bound that fired. It stays a terminal `Timeout`, as before.
+/// Preserve OpenHuman's timeout tag while using the owner conversion for all
+/// other hosted error kinds.
pub(crate) fn run_error_from_hosted(error: HostedError) -> TinyAgentsError {
- let bound = match (error.kind, error.timeout_bound) {
- (HostedErrorKind::Timeout, Some(bound)) => Some(turn_timeout_bound(bound)),
- _ => None,
- };
- match bound {
- Some(bound) => {
- tracing::debug!(
- timeout_bound = bound.tag(),
- "[tinyagents] hosted turn timed out; carrying the typed bound"
- );
- TinyAgentsError::Timeout(format!(
- "hosted agent invocation exceeded its {}",
- bound.phrase()
- ))
- }
- None => TinyAgentsError::from(error),
+ if matches!(error.kind, HostedErrorKind::Timeout) {
+ let bound = error
+ .timeout_bound
+ .map(turn_timeout_bound)
+ .unwrap_or(TurnTimeoutBound::RunRemaining);
+ tracing::debug!(timeout_bound = bound.tag(), "[tinyagents] hosted turn timed out; carrying the typed bound");
+ TinyAgentsError::Timeout(format!("hosted agent invocation exceeded its {}", bound.phrase()))
+ } else {
+ TinyAgentsError::from(error)
}
}