Skip to content

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

fix(chat): stop telling a local offline profile its session expired

obchain12814036ff41
diff --git a/crates/openhuman-core/src/inference/failure_copy/table.rs b/crates/openhuman-core/src/inference/failure_copy/table.rs
index 69a818a4c5..4b2754e151 100644
--- a/crates/openhuman-core/src/inference/failure_copy/table.rs
+++ b/crates/openhuman-core/src/inference/failure_copy/table.rs
@@ -32,6 +32,7 @@ pub(crate) struct FailureCopy {
pub(crate) enum FailureClass {
CodexSessionExpired,
SessionExpired,
+ LocalSessionManagedUnavailable,
ActionBudget,
MaxIterations,
TurnTimeout,
@@ -92,6 +93,21 @@ pub(crate) fn failure_copy(class: FailureClass) -> &'static FailureCopy {
"Your OpenHuman session has expired. \
Please sign in again to continue."
),
+ // The offline local profile is a working sign-in with no TinyHumans
+ // account behind it, so the managed model cannot run for it — but
+ // nothing about it has expired (#6932). `auth_error`/`config` because
+ // the fix is a setting the user owns; emphatically NOT
+ // `session_expired`, whose wire token signs the user out.
+ LocalSessionManagedUnavailable => row!(
+ "chat_error.local_session_managed_unavailable",
+ "auth_error",
+ "config",
+ false,
+ "You're on the local offline profile, which has no OpenHuman account behind \
+ it, so the managed (cloud) model can't run. Sign in to use managed models, \
+ or switch routing to \"Use Your Own Models\" in Connections → API keys → LLM \
+ and add your own provider."
+ ),
ActionBudget => row!(
"chat_error.action_budget",
"action_budget_exceeded",
diff --git a/crates/openhuman-core/src/web_chat/web_errors/classify.rs b/crates/openhuman-core/src/web_chat/web_errors/classify.rs
index 7b77af7aeb..cfc1bccfe2 100644
--- a/crates/openhuman-core/src/web_chat/web_errors/classify.rs
+++ b/crates/openhuman-core/src/web_chat/web_errors/classify.rs
@@ -184,7 +184,17 @@ pub(crate) fn classify_inference_error(err: &str) -> ClassifiedError {
// "iteration", so they MUST be checked before the generic provider-429
// branch — otherwise users see a confusing "your AI provider is
// rate-limiting you" message for limits OpenHuman itself enforced (#2364).
- let classified = if is_codex_token_expired_text(&err.to_ascii_lowercase()) {
+ let classified = if err.contains(
+ crate::security::credentials::session_support::LOCAL_SESSION_MANAGED_INFERENCE_UNAVAILABLE,
+ ) {
+ // #6932: the offline local profile cannot run the managed model, and
+ // `resolve_bearer` now refuses before the request instead of letting
+ // the backend's `401 "Invalid token"` come back — that envelope is
+ // claimed by `is_session_expired_message` below, which told a locally
+ // signed-in user their session had expired. An exact-sentinel match,
+ // so it leads the ladder.
+ classified_plain(C::LocalSessionManagedUnavailable, None, None)
+ } else if is_codex_token_expired_text(&err.to_ascii_lowercase()) {
// Codex OAuth refresh failed (#5869): the user must reconnect Codex in
// Settings → Integrations, NOT sign into OpenHuman. Checked before
// `is_session_expired_message` because the sentinel contains
diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs
index f2a61707d5..31b83cb19b 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_error_code_classification_tests.rs
@@ -585,3 +585,28 @@ fn classify_inference_error_in_stream_tool_history_rejection_uses_malformed_hist
classified.message
);
}
+
+#[test]
+fn classify_inference_error_local_offline_profile_is_not_an_expired_session() {
+ // #6932: the refusal travels wrapped in the turn driver's context, so the
+ // arm matches the sentinel anywhere in the chain.
+ let raw = format!(
+ "run_chat_task failed client_id=abc thread_id=t-1 error={}",
+ crate::security::credentials::session_support::LOCAL_SESSION_MANAGED_INFERENCE_UNAVAILABLE
+ );
+ let classified = classify_inference_error(&raw);
+
+ assert_eq!(classified.error_type, "auth_error");
+ assert_eq!(classified.source, "config");
+ assert!(!classified.retryable);
+ assert!(
+ classified.message.contains("Use Your Own Models"),
+ "must route the user to the setting that fixes it: {}",
+ classified.message
+ );
+ assert!(
+ !classified.message.contains("session has expired"),
+ "must not claim an expired session: {}",
+ classified.message
+ );
+}
diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
index 64d9068e89..5582ad38f5 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
@@ -28,6 +28,7 @@ const EXPECTED: &[(
)] = &[
("codex_expired", "Codex authentication token is expired; sign in again", "provider_error", "auth", false, None, Some("openai_codex"), None, "Your Codex session has expired. Please reconnect it in Settings → Integrations."),
("session_expired", "SESSION_EXPIRED", "session_expired", "auth", false, None, None, None, "Your OpenHuman session has expired. Please sign in again to continue."),
+ ("local_session_managed", "BACKEND_UNAVAILABLE: managed inference is unavailable for the offline local session", "auth_error", "config", false, None, None, None, "You're on the local offline profile, which has no OpenHuman account behind it, so the managed (cloud) model can't run. Sign in to use managed models, or switch routing to \"Use Your Own Models\" in Connections → API keys → LLM and add your own provider."),
("action_budget", "Action blocked: rate limit exceeded for tool curl", "action_budget_exceeded", "openhuman_budget", true, None, None, None, "You've hit OpenHuman's per-hour action budget — this is a local safety cap, not your AI provider. The window decays gradually; you can keep chatting in this thread and tool-heavy steps will resume as the budget refills."),
("max_iterations", "Agent exceeded maximum tool iterations (10)", "max_iterations", "agent_loop", true, None, None, None, "The agent ran the maximum number of tool steps for one turn without finishing. This usually means a tool kept failing (often a rate limit on a web fetch). You can retry the same question in this thread once the underlying limit clears."),
("turn_timeout_marker", "openhuman_turn_wall_clock_timeout: agent turn exceeded its 600s wall-clock budget", "turn_timeout", "agent_loop", true, None, None, None, "This turn ran past its time budget without finishing and was stopped so it wouldn't hang. This usually means a tool call or a delegated sub-agent stalled. You can retry your question in this thread."),
@@ -67,7 +68,7 @@ const EXPECTED: &[(
#[test]
fn every_failure_class_keeps_its_exact_copy_and_wire_values() {
- assert_eq!(EXPECTED.len(), 37, "fixture row count drifted");
+ assert_eq!(EXPECTED.len(), 38, "fixture row count drifted");
for (case, input, error_type, source, retryable, retry_after_ms, provider, fallback, message) in
EXPECTED
{
@@ -316,6 +317,11 @@ const EXPECTED_COPY_KEYS: &[(&str, &str, &str)] = &[
r#"{"provider":"openai_codex"}"#,
),
("session_expired", "chat_error.session_expired", "null"),
+ (
+ "local_session_managed",
+ "chat_error.local_session_managed_unavailable",
+ "null",
+ ),
("action_budget", "chat_error.action_budget", "null"),
("max_iterations", "chat_error.max_iterations", "null"),
("turn_timeout_marker", "chat_error.turn_timeout", "null"),