The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(auth): read the 401 from the failure header, not the body
M3gA-Mind647f82e71d81
diff --git a/app/src/services/__tests__/coreRpcClient.test.ts b/app/src/services/__tests__/coreRpcClient.test.tsindex f6997824fb..b3a2294165 100644--- a/app/src/services/__tests__/coreRpcClient.test.ts+++ b/app/src/services/__tests__/coreRpcClient.test.ts@@ -787,6 +787,11 @@ describe('classifyRpcError', () => {undefined,'provider_auth',],+ [+ 'GET /teams failed (500 Internal Server Error): {"error":"upstream failed (401 Unauthorized)"}',+ undefined,+ 'provider_auth',+ ],['Session expired. Please log in again.', undefined, 'auth_expired'],['some prefix Session expired suffix', undefined, 'auth_expired'],[diff --git a/app/src/services/coreRpcClient.ts b/app/src/services/coreRpcClient.tsindex 3693f2b427..40a9a7be3e 100644--- a/app/src/services/coreRpcClient.ts+++ b/app/src/services/coreRpcClient.ts@@ -197,10 +197,10 @@ export function classifyRpcError(// Fix for issue #2286: only match when the message starts with an HTTP verb// followed by a path — this excludes "Discord API error:", "OpenAI API error:", etc.// HEAD and OPTIONS intentionally excluded — authed_json only uses these five verbs.- // Aligned with Rust is_session_expired_error: anchored on the status itself,- // so a 500 whose body carries `"status":401` is not an expired session.- if (/^(GET|POST|PUT|DELETE|PATCH) \//.test(message) && message.includes(' failed (401'))- return 'auth_expired';+ // Aligned with Rust is_session_expired_error: anchored on the status in the+ // `{METHOD} /path failed ({status}` header, so a 500 whose body mentions a 401+ // is not an expired session.+ if (/^(GET|POST|PUT|DELETE|PATCH) \/\S* failed \(401/.test(message)) return 'auth_expired';// Everything above matched an explicit backend marker in the message. What// is left, if the transport gave us a 401, is the LOCAL core's bearer gate// (`crates/openhuman-core/src/core/auth.rs` — "Missing or invalid Authorization header"), never thediff --git a/crates/openhuman-core/src/core/session_expiry.rs b/crates/openhuman-core/src/core/session_expiry.rsindex 3e4352d2f9..8110317759 100644--- a/crates/openhuman-core/src/core/session_expiry.rs+++ b/crates/openhuman-core/src/core/session_expiry.rs@@ -53,12 +53,16 @@ pub fn is_session_expired_error(msg: &str) -> bool {// The HTTP-method prefix distinguishes these from provider-prefixed errors.// HEAD and OPTIONS are intentionally excluded — `authed_json` only issues// the five listed verbs (GET/POST/PUT/DELETE/PATCH) for REST JSON endpoints.- // Anchored on the status itself: a 500 whose body happens to contain- // `"status":401` and the word "unauthorized" is not an expired session.+ // Anchored on the status in the `{METHOD} /path failed ({status} …)`+ // header itself — the first ` failed (` — so a 500 whose body mentions a+ // 401 (`"status":401`, `upstream failed (401 …)`) is not an expired session.+ const HEADER: &str = " failed (";["GET /", "POST /", "PUT /", "DELETE /", "PATCH /"].iter().any(|verb| msg.starts_with(verb))- && msg.contains(" failed (401")+ && msg+ .find(HEADER)+ .is_some_and(|at| msg[at + HEADER.len()..].starts_with("401"))}/// The one status rule for the OpenHuman backend: only a 401 on a requestdiff --git a/crates/openhuman-core/src/core/session_expiry_tests.rs b/crates/openhuman-core/src/core/session_expiry_tests.rsindex 7bd47fd31c..23a91a24b5 100644--- a/crates/openhuman-core/src/core/session_expiry_tests.rs+++ b/crates/openhuman-core/src/core/session_expiry_tests.rs@@ -238,6 +238,9 @@ fn is_session_expired_error_does_not_match_a_non_401_with_401_in_its_body() {assert!(!is_session_expired_error("POST /auth/me failed (403 Forbidden): 401 unauthorized upstream"));+ assert!(!is_session_expired_error(+ "GET /teams failed (500 Internal Server Error): {\"error\":\"upstream failed (401 Unauthorized)\"}"+ ));}#[test]diff --git a/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs b/crates/openhuman-tinyhumans/src/inference/managed_catalog.rsindex 364a8ba5f3..a5df946cea 100644--- a/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs+++ b/crates/openhuman-tinyhumans/src/inference/managed_catalog.rs@@ -177,7 +177,10 @@ fn catalog_url(config: &Config) -> String {/// that actually carried the app session token. A 401 without one describes the/// request, not the session.pub(super) fn managed_401_means_signed_out(status: u16, session_attached: bool) -> bool {- status == 401 && session_attached+ openhuman_embed::__host::core::session_expiry::backend_status_means_session_expired(+ status,+ !session_attached,+ )}/// What authenticates a listing request: the live session token, or the