Skip to content

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

fix(triage): reset failover attempt on success and shorten in-flight delay

Steven Enamakel34396fa3aa82
diff --git a/crates/openhuman-core/src/triage/decision.rs b/crates/openhuman-core/src/triage/decision.rs
index a2c7fb4c95..0434842eb4 100644
--- a/crates/openhuman-core/src/triage/decision.rs
+++ b/crates/openhuman-core/src/triage/decision.rs
@@ -106,8 +106,7 @@ pub enum ParseError {
/// keeps the triage-specific casing normalization and action-field validation:
/// React / Escalate must include a non-empty target and prompt.
pub fn parse_triage_decision(llm_text: &str) -> Result<TriageDecision, ParseError> {
- let fenced = llm_text.split("```").nth(1).and_then(|block| block.split_once('\n').map(|(_, body)| body.split("```").next().unwrap_or(body)));
- let (value, _) = parse_lenient_last_object(fenced.unwrap_or(llm_text)).ok_or(ParseError::NoJsonObject)?;
+ let (value, _) = parse_lenient_last_object(llm_text).ok_or(ParseError::NoJsonObject)?;
let normalized = lowercase_action_value(&value.to_string());
let decision: TriageDecision =
serde_json::from_str(&normalized).map_err(ParseError::InvalidJson)?;
diff --git a/crates/openhuman-core/src/triage/evaluator/chain.rs b/crates/openhuman-core/src/triage/evaluator/chain.rs
index 0051dc11d3..b5d49bea0b 100644
--- a/crates/openhuman-core/src/triage/evaluator/chain.rs
+++ b/crates/openhuman-core/src/triage/evaluator/chain.rs
@@ -381,9 +381,13 @@ fn now_ms() -> i64 {
chrono::Utc::now().timestamp_millis()
}
-fn clear_outage(state: Option<&RetryState>, key: &str, _attempt: Option<&mut PersistentFailoverAttempt<String>>) {
- if let Some(state) = state {
- state.reset(&key.to_string());
+fn clear_outage(
+ _state: Option<&RetryState>,
+ _key: &str,
+ attempt: Option<&mut PersistentFailoverAttempt<String>>,
+) {
+ if let Some(attempt) = attempt {
+ attempt.record_success();
}
}
@@ -392,7 +396,7 @@ fn rejection_delay_ms(rejection: BreakerRejection, now_ms: u64) -> u64 {
BreakerRejection::Backoff {
next_attempt_ms, ..
} => next_attempt_ms.saturating_sub(now_ms),
- BreakerRejection::InFlight => 30_000,
+ BreakerRejection::InFlight => 1_000,
}
}
@@ -410,7 +414,10 @@ pub(crate) fn record_outage(
let attempt = attempt?;
let recorded_at_ms = monotonic_ms();
let Some(failure) = attempt.record_failure(recorded_at_ms) else {
- return None;
+ return Some(TriageOutcome::Deferred {
+ defer_until_ms: now_ms().saturating_add(OUTAGE_BACKOFF_BASE_MS),
+ reason: "managed backend recovered during another attempt".to_string(),
+ });
};
let delay_ms = failure
.next_attempt_ms