Skip to content

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

feat(transport): add typed error variants for 401 and 404 responses

Steven Enamakelac49ba9f285d
diff --git a/crates/openhuman-core/src/backend/transport/error.rs b/crates/openhuman-core/src/backend/transport/error.rs
index a36a913087..ac20f6a65d 100644
--- a/crates/openhuman-core/src/backend/transport/error.rs
+++ b/crates/openhuman-core/src/backend/transport/error.rs
@@ -29,6 +29,32 @@ pub enum BackendTransportError {
/// body when it parsed, otherwise the raw text as a JSON string.
#[error("http {status}: {body}")]
Status { status: u16, body: Value },
+ /// The backend rejected the request's credential (`401`). The transport
+ /// reports it as its own variant so the core never inspects status codes
+ /// to decide on session recovery; which recovery applies (session expiry
+ /// vs. a rejected API key) stays the caller's decision.
+ #[error("http 401: credential rejected")]
+ Unauthorized,
+ /// `404` on a channel-message route answered by a backend handler: that
+ /// message no longer exists (deleted provider-side or garbage-collected).
+ #[error("http 404: channel message {provider}/{message_id} not found")]
+ ChannelMessageNotFound {
+ /// Channel provider path segment (`telegram`, `discord`, …).
+ provider: String,
+ /// Provider message id from the path.
+ message_id: String,
+ },
+ /// `404` on a channel-message route because the backend has **no such
+ /// route** (no handler matched), not because the message is gone. Today
+ /// this is every `PATCH` edit (#5230): the message still exists and the
+ /// caller must keep its id.
+ #[error("http 404: backend implements no route for channel message {provider}/{message_id}")]
+ ChannelMessageRouteMissing {
+ /// Channel provider path segment.
+ provider: String,
+ /// Provider message id from the path.
+ message_id: String,
+ },
/// The response carried a `{success:false, ...}` envelope on a 2xx status.
#[error("backend reported failure: {error}")]
Envelope {
@@ -56,6 +82,10 @@ impl BackendTransportError {
pub fn status(&self) -> Option<u16> {
match self {
Self::Status { status, .. } => Some(*status),
+ Self::Unauthorized => Some(401),
+ Self::ChannelMessageNotFound { .. } | Self::ChannelMessageRouteMissing { .. } => {
+ Some(404)
+ }
_ => None,
}
}
diff --git a/vendor/tinyhumans-sdk b/vendor/tinyhumans-sdk
index e7f38bf439..4a8363237f 160000
--- a/vendor/tinyhumans-sdk
+++ b/vendor/tinyhumans-sdk
@@ -1 +1 @@
-Subproject commit e7f38bf43938679212f2b4b1df5897878a9e4cfd
+Subproject commit 4a8363237f5089b5119f4b9b8615dc7ca885ec26