Skip to content

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

fix(web_chat): use structured error class in chat error event

Steven Enamakel43b5f2c831ac
diff --git a/crates/openhuman-core/src/web_chat/turn_events.rs b/crates/openhuman-core/src/web_chat/turn_events.rs
index 17c3d1bda5..450e9b9fa8 100644
--- a/crates/openhuman-core/src/web_chat/turn_events.rs
+++ b/crates/openhuman-core/src/web_chat/turn_events.rs
@@ -420,7 +420,12 @@ fn chat_error_event(
.map(|failure| failure.message.clone())
.unwrap_or(classified.message),
),
- error_type: Some(classified.error_type.to_owned()),
+ error_type: Some(
+ structured
+ .map(|failure| failure.class.as_str())
+ .unwrap_or(classified.error_type)
+ .to_owned(),
+ ),
error_source: Some(classified.source.to_owned()),
error_retryable: Some(classified.retryable),
error_retry_after_ms: classified.retry_after_ms,
diff --git a/crates/openhuman-core/src/web_chat/turn_events_tests.rs b/crates/openhuman-core/src/web_chat/turn_events_tests.rs
index f94b2cff49..d58669a72c 100644
--- a/crates/openhuman-core/src/web_chat/turn_events_tests.rs
+++ b/crates/openhuman-core/src/web_chat/turn_events_tests.rs
@@ -177,8 +177,9 @@ async fn classified_failure_event_preserves_runner_copy_and_queued_prefix() {
let error = events_for(&mut rx, &req.request_id, 1).await.remove(0);
assert!(matches!(error.wire_event(), WebChannelEvent::ChatError {
- message: Some(message), copy_key: Some(copy_key), copy_params: Some(params), ..
+ message: Some(message), error_type: Some(error_type), copy_key: Some(copy_key), copy_params: Some(params), ..
} if message == "queued turn was not run: localized by the runner"
+ && error_type == "auth_error"
&& copy_key == "chat_error.auth_error"
&& params["detail"] == "sanitized detail"));
}