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(memory): keep a quoted auth code from signing the user out
Shanuf97078f40757
diff --git a/crates/openhuman-core/src/memory/ops/engine.rs b/crates/openhuman-core/src/memory/ops/engine.rsindex 96d116041a..a00664f95a 100644--- a/crates/openhuman-core/src/memory/ops/engine.rs+++ b/crates/openhuman-core/src/memory/ops/engine.rs@@ -295,21 +295,29 @@ pub fn classify_engine_message(message: &str) -> String {{return message.to_string();}+ // The backend's billing code is a verdict on this account wherever it is+ // quoted, and saying so signs no one out.if message.contains("USER_INSUFFICIENT_CREDITS") {return format!("{INSUFFICIENT_CREDITS_PREFIX} the memory engine is out of credits");}// Only the error's own class decides, never a class quoted in its detail.let class = memory_error_class(message);- let forbidden = match class {- Some((class, detail)) => class == "unauthorized: " && is_forbidden(detail),- // No class tag: a bare adapter message, whose first status is its own.- None => is_forbidden(message),+ // An auth refusal of the error's own: its class is `unauthorized: `, or it+ // has no class tag (a bare adapter message, whose first status is its own).+ let own_auth_detail = match class {+ Some(("unauthorized: ", detail)) => Some(detail),+ Some(_) => None,+ None => Some(message),};- if forbidden {+ if own_auth_detail.is_some_and(is_forbidden) {return format!("{MEMORY_FORBIDDEN_PREFIX} the memory engine refused this credential");}+ // A lapsed session signs the user out, so the hosted `[UNAUTHORIZED]`+ // code counts only as the error's own: quoted by an outage (the backend+ // relaying its upstream's 401 as a 503, say) it is not this user's+ // session. OpenHuman's own `SESSION_EXPIRED:` marker counts wherever it is.if message.contains(SESSION_EXPIRED_PREFIX)- || message.contains("[UNAUTHORIZED]")+ || (own_auth_detail.is_some() && message.contains("[UNAUTHORIZED]"))|| (message.starts_with("unauthorized:") && message.contains("re-authenticate")){return format!("{SESSION_EXPIRED_PREFIX} no TinyHumans session");diff --git a/crates/openhuman-core/src/memory/ops/engine_tests.rs b/crates/openhuman-core/src/memory/ops/engine_tests.rsindex 5a667671da..5063567026 100644--- a/crates/openhuman-core/src/memory/ops/engine_tests.rs+++ b/crates/openhuman-core/src/memory/ops/engine_tests.rs@@ -239,6 +239,36 @@ fn a_class_quoted_in_another_errors_detail_does_not_decide_it() {);}+#[test]+fn an_auth_code_quoted_by_another_class_does_not_sign_the_user_out() {+ // The backend relaying its own upstream's 401 as a 503 is an outage, not+ // this user's lapsed session.+ for outage in [+ "unavailable: upstream returned [UNAUTHORIZED]",+ "unavailable: [UNAUTHORIZED] memory API memory/recall on host (HTTP 503 Service \+ Unavailable): memory service token rejected",+ ] {+ let classified = classify_engine_message(outage);+ assert!(+ classified.starts_with(MEMORY_UNREACHABLE_PREFIX),+ "{outage} -> {classified}"+ );+ }+ let invalid = "invalid input: upstream said [UNAUTHORIZED]";+ assert_eq!(classify_engine_message(invalid), invalid);+ // Two markers count wherever they are quoted: OpenHuman's own+ // `SESSION_EXPIRED:` (the session is gone, whatever wrapped that) and the+ // backend's billing code (a verdict on this account).+ let session = classify_engine_message("backend failed: SESSION_EXPIRED: no TinyHumans session");+ assert!(session.starts_with(SESSION_EXPIRED_PREFIX), "{session}");+ let credits =+ classify_engine_message("backend failed: [USER_INSUFFICIENT_CREDITS] out of credits");+ assert!(+ credits.starts_with(INSUFFICIENT_CREDITS_PREFIX),+ "{credits}"+ );+}+#[test]fn an_engine_that_cannot_serve_now_is_unreachable() {for error in [