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): a plan without memory no longer signs the user out
M3gA-Mind8f39c4ea2e9c
diff --git a/app/src/components/memory/MemoryEraseAllCard.test.tsx b/app/src/components/memory/MemoryEraseAllCard.test.tsxindex e7c4591c20..3c3590b3ab 100644--- a/app/src/components/memory/MemoryEraseAllCard.test.tsx+++ b/app/src/components/memory/MemoryEraseAllCard.test.tsx@@ -179,6 +179,7 @@ describe('MemoryEraseAllCard', () => {expect(eraseErrorKey(coded('UNAUTHORIZED'))).toBe('memoryPage.settings.eraseError.unauthorized');+ expect(eraseErrorKey(coded('PLAN_REQUIRED'))).toBe('memory.error.planRequired');expect(eraseErrorKey(coded('ENGINE'))).toBe('memoryPage.settings.eraseError.generic');expect(eraseErrorKey('nope')).toBe('memoryPage.settings.eraseError.generic');});diff --git a/app/src/components/memory/MemoryEraseAllCard.tsx b/app/src/components/memory/MemoryEraseAllCard.tsxindex 22de9446f5..ef7e62d901 100644--- a/app/src/components/memory/MemoryEraseAllCard.tsx+++ b/app/src/components/memory/MemoryEraseAllCard.tsx@@ -45,6 +45,8 @@ export function eraseErrorKey(err: unknown): string {return 'memoryPage.settings.eraseError.unsupported';case 'INSUFFICIENT_CREDITS':return 'memoryPage.settings.eraseError.insufficientCredits';+ case 'PLAN_REQUIRED':+ return 'memory.error.planRequired';case 'MEMORY_OFF':return 'memoryPage.settings.eraseError.memoryOff';case 'UNAVAILABLE':diff --git a/app/src/components/memory/MemoryErrorAlert.test.tsx b/app/src/components/memory/MemoryErrorAlert.test.tsxindex 899bac4082..c46242ac57 100644--- a/app/src/components/memory/MemoryErrorAlert.test.tsx+++ b/app/src/components/memory/MemoryErrorAlert.test.tsx@@ -46,6 +46,24 @@ describe('MemoryErrorAlert', () => {expect(screen.getByTestId('billing-page')).toBeInTheDocument();});+ it('turns PLAN_REQUIRED into an upgrade prompt to billing (#8081)', () => {+ renderAt(+ coded(+ 'PLAN_REQUIRED',+ 'plan required: [MEMORY_PLAN_REQUIRED] memory API memory/scopes (HTTP 403 Forbidden)'+ )+ );+ const alert = screen.getByTestId('alert');+ expect(alert).toHaveAttribute('data-kind', 'plan-required');+ expect(alert).toHaveAttribute('data-variant', 'warning');+ expect(alert).toHaveTextContent('Not in your plan');+ expect(alert).toHaveTextContent("Memory isn't included in your plan");+ expect(alert).not.toHaveTextContent('HTTP 403');+ expect(screen.queryByTestId('memory-top-up')).not.toBeInTheDocument();+ fireEvent.click(screen.getByTestId('memory-upgrade'));+ expect(screen.getByTestId('billing-page')).toBeInTheDocument();+ });+it.each([['UNAVAILABLE', "Memory can't be reached right now"],['ENGINE', 'engine detail'],diff --git a/app/src/components/memory/MemoryErrorAlert.tsx b/app/src/components/memory/MemoryErrorAlert.tsxindex fef0ec9b1a..702d2ab46c 100644--- a/app/src/components/memory/MemoryErrorAlert.tsx+++ b/app/src/components/memory/MemoryErrorAlert.tsx@@ -1,13 +1,14 @@/*** How a failed memory action is shown. An exhausted credit balance- * (`INSUFFICIENT_CREDITS`) is a prompt to top up, not an error: it explains- * that nothing stored was lost and links to billing. Every other failure keeps- * the destructive alert.+ * (`INSUFFICIENT_CREDITS`) is a prompt to top up, and memory missing from the+ * account's plan (`PLAN_REQUIRED`, #8081) a prompt to upgrade, not errors: each+ * explains itself and links to billing. Every other failure keeps the+ * destructive alert.*/import { useNavigate } from 'react-router-dom';import { useT } from '../../lib/i18n/I18nContext';-import { isOutOfCreditsMessage } from '../../services/api/memoryApi';+import { isOutOfCreditsMessage, isPlanRequiredMessage } from '../../services/api/memoryApi';import { Alert, AlertDescription, AlertTitle, Button } from '../ui';/** Where the app sends every "top up" action (`open_billing` in useAppNotices). */@@ -22,27 +23,43 @@ interface MemoryCreditsPromptProps {'data-testid'?: string;}-/** "Out of credits: top up", with a button to billing. */-export function MemoryCreditsPrompt({+/** A billing refusal and how to lift it. */+const BILLING_PROMPTS = {+ 'out-of-credits': {+ title: 'memory.outOfCredits.title',+ action: 'memory.outOfCredits.action',+ actionTestId: 'memory-top-up',+ },+ 'plan-required': {+ title: 'memory.planRequired.title',+ action: 'memory.planRequired.action',+ actionTestId: 'memory-upgrade',+ },+} as const;++/** A billing refusal's explanation, with a button to billing. */+function MemoryBillingPrompt({+ kind,message,onRetry,className,'data-testid': testId,-}: MemoryCreditsPromptProps) {+}: MemoryCreditsPromptProps & { kind: keyof typeof BILLING_PROMPTS }) {const { t } = useT();const navigate = useNavigate();+ const prompt = BILLING_PROMPTS[kind];return (- <Alert variant="warning" className={className} data-testid={testId} data-kind="out-of-credits">- <AlertTitle>{t('memory.outOfCredits.title')}</AlertTitle>+ <Alert variant="warning" className={className} data-testid={testId} data-kind={kind}>+ <AlertTitle>{t(prompt.title)}</AlertTitle><AlertDescription className="flex flex-wrap items-center gap-2"><span>{message}</span><Buttontype="button"size="xs"variant="primary"- data-testid="memory-top-up"+ data-testid={prompt.actionTestId}onClick={() => navigate(BILLING_ROUTE)}>- {t('memory.outOfCredits.action')}+ {t(prompt.action)}</Button>{onRetry && <RetryButton onRetry={onRetry} />}</AlertDescription>@@ -50,6 +67,11 @@ export function MemoryCreditsPrompt({);}+/** "Out of credits: top up", with a button to billing. */+export function MemoryCreditsPrompt(props: MemoryCreditsPromptProps) {+ return <MemoryBillingPrompt kind="out-of-credits" {...props} />;+}+interface MemoryErrorAlertProps {/** The message `memoryErrorMessage(err, t)` produced. */message: string;@@ -68,7 +90,8 @@ function RetryButton({ onRetry }: { onRetry: () => void }) {);}-/** The credits prompt for an exhausted balance, else the error alert. */+/** The billing prompt for an exhausted balance or a plan without memory, else+ * the error alert. */export default function MemoryErrorAlert({message,className,@@ -76,9 +99,15 @@ export default function MemoryErrorAlert({onRetry,}: MemoryErrorAlertProps) {const { t } = useT();- if (isOutOfCreditsMessage(message, t)) {+ const billing = isOutOfCreditsMessage(message, t)+ ? 'out-of-credits'+ : isPlanRequiredMessage(message, t)+ ? 'plan-required'+ : null;+ if (billing) {return (- <MemoryCreditsPrompt+ <MemoryBillingPrompt+ kind={billing}message={message}onRetry={onRetry}className={className}diff --git a/app/src/lib/i18n/ar.ts b/app/src/lib/i18n/ar.tsindex 8549308d28..aeef07282d 100644--- a/app/src/lib/i18n/ar.ts+++ b/app/src/lib/i18n/ar.ts@@ -589,6 +589,9 @@ const messages: TranslationMap = {'تعذّر الوصول إلى الذاكرة حاليًا. لم يُفقد أي شيء مخزّن؛ حاول مرة أخرى بعد قليل.','memory.outOfCredits.title': 'نفد الرصيد','memory.outOfCredits.action': 'اشحن الرصيد',+ 'memory.error.planRequired': 'الذاكرة غير مضمّنة في خطتك. قم بترقية خطتك لاستخدامها.',+ 'memory.planRequired.title': 'غير مضمّنة في خطتك',+ 'memory.planRequired.action': 'ترقية','alerts.title': 'التنبيهات','alerts.empty': 'لا توجد تنبيهات بعد','alerts.markAllRead': 'تحديد الكل كمقروء',diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.tsindex 78ffb3864f..4aa8e249f7 100644--- a/app/src/lib/i18n/bn.ts+++ b/app/src/lib/i18n/bn.ts@@ -597,6 +597,10 @@ const messages: TranslationMap = {'এই মুহূর্তে মেমরিতে পৌঁছানো যাচ্ছে না। সংরক্ষিত কিছুই হারায়নি; একটু পরে আবার চেষ্টা করুন।','memory.outOfCredits.title': 'ক্রেডিট শেষ','memory.outOfCredits.action': 'টপ আপ করুন',+ 'memory.error.planRequired':+ 'আপনার প্ল্যানে মেমোরি অন্তর্ভুক্ত নেই। এটি ব্যবহার করতে আপনার প্ল্যান আপগ্রেড করুন।',+ 'memory.planRequired.title': 'আপনার প্ল্যানে নেই',+ 'memory.planRequired.action': 'আপগ্রেড করুন','alerts.title': 'সতর্কতা','alerts.empty': 'এখনো কোনো সতর্কতা নেই','alerts.markAllRead': 'সব পঠিত চিহ্নিত করুন',diff --git a/app/src/lib/i18n/de.ts b/app/src/lib/i18n/de.tsindex 9a141f6cf6..fb3912a174 100644--- a/app/src/lib/i18n/de.ts+++ b/app/src/lib/i18n/de.ts@@ -620,6 +620,10 @@ const messages: TranslationMap = {'Das Gedächtnis ist gerade nicht erreichbar. Nichts Gespeichertes ist verloren; versuche es gleich noch einmal.','memory.outOfCredits.title': 'Kein Guthaben mehr','memory.outOfCredits.action': 'Aufladen',+ 'memory.error.planRequired':+ 'Memory ist in deinem Tarif nicht enthalten. Wechsle zu einem höheren Tarif, um es zu nutzen.',+ 'memory.planRequired.title': 'Nicht in deinem Tarif',+ 'memory.planRequired.action': 'Upgrade','alerts.title': 'Warnungen','alerts.empty': 'Noch keine Benachrichtigungen','alerts.markAllRead': 'Alle als gelesen markieren',diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.tsindex b81a6277bf..f7f7e7328f 100644--- a/app/src/lib/i18n/en.ts+++ b/app/src/lib/i18n/en.ts@@ -595,6 +595,9 @@ const en: TranslationMap = {"Memory can't be reached right now. Nothing stored has been lost; try again in a moment.",'memory.outOfCredits.title': 'Out of credits','memory.outOfCredits.action': 'Top up',+ 'memory.error.planRequired': "Memory isn't included in your plan. Upgrade your plan to use it.",+ 'memory.planRequired.title': 'Not in your plan',+ 'memory.planRequired.action': 'Upgrade',// Activity surface: Phase 3 renamed tabs'activity.tabs.automations': 'Automations',diff --git a/app/src/lib/i18n/es.ts b/app/src/lib/i18n/es.tsindex c372445bf8..76bbd3f40a 100644--- a/app/src/lib/i18n/es.ts+++ b/app/src/lib/i18n/es.ts@@ -616,6 +616,10 @@ const messages: TranslationMap = {'No se puede acceder a la memoria ahora mismo. No se ha perdido nada guardado; inténtalo de nuevo en un momento.','memory.outOfCredits.title': 'Sin créditos','memory.outOfCredits.action': 'Recargar',+ 'memory.error.planRequired':+ 'La memoria no está incluida en tu plan. Mejora tu plan para usarla.',+ 'memory.planRequired.title': 'No incluida en tu plan',+ 'memory.planRequired.action': 'Mejorar plan','alerts.title': 'Alertas','alerts.empty': 'Sin alertas aún','alerts.markAllRead': 'Marcar todo como leído',diff --git a/app/src/lib/i18n/fr.ts b/app/src/lib/i18n/fr.tsindex 5c45f53b73..b8ae452355 100644--- a/app/src/lib/i18n/fr.ts+++ b/app/src/lib/i18n/fr.ts@@ -620,6 +620,10 @@ const messages: TranslationMap = {"La mémoire est injoignable pour le moment. Rien de ce qui est stocké n'a été perdu ; réessayez dans un instant.",'memory.outOfCredits.title': 'Crédits épuisés','memory.outOfCredits.action': 'Recharger',+ 'memory.error.planRequired':+ "La mémoire n'est pas incluse dans votre forfait. Passez à un forfait supérieur pour l'utiliser.",+ 'memory.planRequired.title': 'Non incluse dans votre forfait',+ 'memory.planRequired.action': 'Mettre à niveau','alerts.title': 'Alertes','alerts.empty': "Aucune alerte pour l'instant",'alerts.markAllRead': 'Tout marquer comme lu',diff --git a/app/src/lib/i18n/hi.ts b/app/src/lib/i18n/hi.tsindex 3c2dcd73cc..c763332051 100644--- a/app/src/lib/i18n/hi.ts+++ b/app/src/lib/i18n/hi.ts@@ -602,6 +602,10 @@ const messages: TranslationMap = {'अभी मेमोरी तक नहीं पहुँचा जा सकता। संग्रहीत कुछ भी खोया नहीं है; थोड़ी देर में फिर से कोशिश करें।','memory.outOfCredits.title': 'क्रेडिट खत्म हो गए','memory.outOfCredits.action': 'टॉप अप करें',+ 'memory.error.planRequired':+ 'मेमोरी आपके प्लान में शामिल नहीं है। इसका उपयोग करने के लिए अपना प्लान अपग्रेड करें।',+ 'memory.planRequired.title': 'आपके प्लान में नहीं',+ 'memory.planRequired.action': 'अपग्रेड करें','alerts.title': 'अलर्ट','alerts.empty': 'अभी कोई अलर्ट नहीं','alerts.markAllRead': 'सभी पढ़ा हुआ मार्क करें',diff --git a/app/src/lib/i18n/id.ts b/app/src/lib/i18n/id.tsindex 678c7cfb8f..6f13407e8b 100644--- a/app/src/lib/i18n/id.ts+++ b/app/src/lib/i18n/id.ts@@ -609,6 +609,10 @@ const messages: TranslationMap = {'Memori tidak dapat dijangkau saat ini. Tidak ada data tersimpan yang hilang; coba lagi sebentar lagi.','memory.outOfCredits.title': 'Kredit habis','memory.outOfCredits.action': 'Isi ulang',+ 'memory.error.planRequired':+ 'Memori tidak termasuk dalam paket Anda. Tingkatkan paket Anda untuk menggunakannya.',+ 'memory.planRequired.title': 'Tidak termasuk dalam paket Anda',+ 'memory.planRequired.action': 'Tingkatkan','alerts.title': 'Peringatan','alerts.empty': 'Belum ada peringatan','alerts.markAllRead': 'Tandai semua sudah dibaca',diff --git a/app/src/lib/i18n/it.ts b/app/src/lib/i18n/it.tsindex 7d1471d799..7517519bcc 100644--- a/app/src/lib/i18n/it.ts+++ b/app/src/lib/i18n/it.ts@@ -616,6 +616,10 @@ const messages: TranslationMap = {'Al momento la memoria non è raggiungibile. Nulla di quanto salvato è andato perso; riprova tra poco.','memory.outOfCredits.title': 'Crediti esauriti','memory.outOfCredits.action': 'Ricarica',+ 'memory.error.planRequired':+ 'La memoria non è inclusa nel tuo piano. Passa a un piano superiore per usarla.',+ 'memory.planRequired.title': 'Non inclusa nel tuo piano',+ 'memory.planRequired.action': 'Aggiorna piano','alerts.title': 'Avvisi','alerts.empty': 'Nessun avviso','alerts.markAllRead': 'Segna tutti come letti',diff --git a/app/src/lib/i18n/ja.ts b/app/src/lib/i18n/ja.tsindex 6035e46464..d4362edadd 100644--- a/app/src/lib/i18n/ja.ts+++ b/app/src/lib/i18n/ja.ts@@ -4771,6 +4771,10 @@ const messages: TranslationMap = {'現在、メモリーに接続できません。保存済みの内容は失われていません。少し待ってから再試行してください。','memory.outOfCredits.title': 'クレジット不足','memory.outOfCredits.action': 'チャージする',+ 'memory.error.planRequired':+ 'メモリーはご利用のプランに含まれていません。利用するにはプランをアップグレードしてください。',+ 'memory.planRequired.title': 'プランに含まれていません',+ 'memory.planRequired.action': 'アップグレード','onboarding.custom.search.skipForNow': '今はスキップ','onboarding.custom.search.ready': 'Web検索の準備ができました。','onboarding.custom.search.notReady':diff --git a/app/src/lib/i18n/ko.ts b/app/src/lib/i18n/ko.tsindex 749849bbce..2100459a64 100644--- a/app/src/lib/i18n/ko.ts+++ b/app/src/lib/i18n/ko.ts@@ -593,6 +593,10 @@ const messages: TranslationMap = {'지금은 메모리에 연결할 수 없습니다. 저장된 내용은 사라지지 않았습니다. 잠시 후 다시 시도하세요.','memory.outOfCredits.title': '크레딧 소진','memory.outOfCredits.action': '충전하기',+ 'memory.error.planRequired':+ '메모리는 현재 요금제에 포함되어 있지 않습니다. 사용하려면 요금제를 업그레이드하세요.',+ 'memory.planRequired.title': '요금제에 포함되지 않음',+ 'memory.planRequired.action': '업그레이드','alerts.title': '알림','alerts.empty': '아직 알림이 없습니다','alerts.markAllRead': '모두 읽음으로 표시',diff --git a/app/src/lib/i18n/pl.ts b/app/src/lib/i18n/pl.tsindex 758115c36b..b9f05ee818 100644--- a/app/src/lib/i18n/pl.ts+++ b/app/src/lib/i18n/pl.ts@@ -610,6 +610,10 @@ const messages: TranslationMap = {'Nie można teraz połączyć się z pamięcią. Nic z zapisanych danych nie zostało utracone; spróbuj ponownie za chwilę.','memory.outOfCredits.title': 'Brak kredytów','memory.outOfCredits.action': 'Doładuj',+ 'memory.error.planRequired':+ 'Pamięć nie jest uwzględniona w Twoim planie. Ulepsz plan, aby z niej korzystać.',+ 'memory.planRequired.title': 'Poza Twoim planem',+ 'memory.planRequired.action': 'Ulepsz plan','alerts.title': 'Alerty','alerts.empty': 'Brak alertów','alerts.markAllRead': 'Oznacz wszystkie jako przeczytane',diff --git a/app/src/lib/i18n/pt.ts b/app/src/lib/i18n/pt.tsindex 5561223724..429ca776ff 100644--- a/app/src/lib/i18n/pt.ts+++ b/app/src/lib/i18n/pt.ts@@ -610,6 +610,10 @@ const messages: TranslationMap = {'Não é possível acessar a memória agora. Nada do que foi guardado se perdeu; tente novamente em instantes.','memory.outOfCredits.title': 'Sem créditos','memory.outOfCredits.action': 'Recarregar',+ 'memory.error.planRequired':+ 'A memória não está incluída no seu plano. Faça upgrade do seu plano para usá-la.',+ 'memory.planRequired.title': 'Não incluída no seu plano',+ 'memory.planRequired.action': 'Fazer upgrade','alerts.title': 'Alertas','alerts.empty': 'Nenhum alerta ainda','alerts.markAllRead': 'Marcar tudo como lido',diff --git a/app/src/lib/i18n/ru.ts b/app/src/lib/i18n/ru.tsindex a2b0c4876b..72363edde4 100644--- a/app/src/lib/i18n/ru.ts+++ b/app/src/lib/i18n/ru.ts@@ -606,6 +606,10 @@ const messages: TranslationMap = {'Сейчас не удаётся связаться с памятью. Ничего из сохранённого не потеряно; повторите попытку чуть позже.','memory.outOfCredits.title': 'Кредиты закончились','memory.outOfCredits.action': 'Пополнить',+ 'memory.error.planRequired':+ 'Память не входит в ваш тариф. Перейдите на более высокий тариф, чтобы пользоваться ею.',+ 'memory.planRequired.title': 'Не входит в ваш тариф',+ 'memory.planRequired.action': 'Улучшить тариф','alerts.title': 'Оповещения','alerts.empty': 'Оповещений пока нет','alerts.markAllRead': 'Отметить всё прочитанным',diff --git a/app/src/lib/i18n/tr.ts b/app/src/lib/i18n/tr.tsindex 5345ab4e44..7c3f0cec92 100644--- a/app/src/lib/i18n/tr.ts+++ b/app/src/lib/i18n/tr.ts@@ -4425,6 +4425,9 @@ const messages: TranslationMap = {'Belleğe şu anda ulaşılamıyor. Kayıtlı hiçbir şey kaybolmadı; biraz sonra yeniden deneyin.','memory.outOfCredits.title': 'Krediniz tükendi','memory.outOfCredits.action': 'Kredi yükle',+ 'memory.error.planRequired': 'Bellek planınıza dahil değil. Kullanmak için planınızı yükseltin.',+ 'memory.planRequired.title': 'Planınıza dahil değil',+ 'memory.planRequired.action': 'Yükselt','memoryPage.engine.badgeDegraded': 'Kısıtlı çalışıyor','memoryPage.engine.badgeDown': 'Ulaşılamıyor','memoryPage.engine.connecting': 'Bağlanıyor…',diff --git a/app/src/lib/i18n/zh-CN.ts b/app/src/lib/i18n/zh-CN.tsindex 3f26156888..e7296754ab 100644--- a/app/src/lib/i18n/zh-CN.ts+++ b/app/src/lib/i18n/zh-CN.ts@@ -563,6 +563,9 @@ const messages: TranslationMap = {'memory.error.unavailable': '暂时无法连接记忆服务。已存储的内容不会丢失,请稍后重试。','memory.outOfCredits.title': '额度已用完','memory.outOfCredits.action': '充值',+ 'memory.error.planRequired': '你的套餐不包含记忆功能。升级套餐即可使用。',+ 'memory.planRequired.title': '不在你的套餐中',+ 'memory.planRequired.action': '升级','alerts.title': '通知','alerts.empty': '暂无通知','alerts.markAllRead': '全部标记为已读',diff --git a/app/src/services/__tests__/coreRpcClient.test.ts b/app/src/services/__tests__/coreRpcClient.test.tsindex e97c080c1f..f4b806b270 100644--- a/app/src/services/__tests__/coreRpcClient.test.ts+++ b/app/src/services/__tests__/coreRpcClient.test.ts@@ -860,6 +860,24 @@ describe('classifyRpcError', () => {expect(classifyRpcError('GET /teams/me/usage failed (401 Unauthorized)')).toBe('auth_expired');});+ // #8081: TinyMemory words a hosted 403 (memory not in the plan) as "the+ // session expired or the API key was rejected (HTTP 403 …)". Matching it as+ // auth_expired signed a valid user out on opening a Memory tab.+ test('a memory plan refusal or 403 is never auth_expired', () => {+ for (const message of [+ "unauthorized: [MEMORY_PLAN_REQUIRED] memory API memory/scopes on api.tinyhumans.ai: the session expired or the API key was rejected (HTTP 403 Forbidden); re-authenticate — memory is not included in this account's plan",+ "plan required: [MEMORY_PLAN_REQUIRED] memory API memory/scopes on api.tinyhumans.ai: memory is not included in this account's plan (HTTP 403 Forbidden)",+ 'unauthorized: [FORBIDDEN] memory API memory/scopes on api.tinyhumans.ai: the session expired or the API key was rejected (HTTP 403 Forbidden); re-authenticate',+ ]) {+ expect(classifyRpcError(message)).not.toBe('auth_expired');+ }+ expect(+ classifyRpcError(+ 'unauthorized: [UNAUTHORIZED] memory API memory/scopes on api.tinyhumans.ai: the session expired or the API key was rejected (HTTP 401 Unauthorized); re-authenticate'+ )+ ).toBe('auth_expired');+ });+test('http status 429 wins over message text', () => {expect(classifyRpcError('anything', 429)).toBe('rate_limited');});diff --git a/app/src/services/api/memoryApi.test.ts b/app/src/services/api/memoryApi.test.tsindex ce94344248..f8ea25a885 100644--- a/app/src/services/api/memoryApi.test.ts+++ b/app/src/services/api/memoryApi.test.ts@@ -192,6 +192,7 @@ describe('memoryErrorCode', () => {'INSUFFICIENT_CREDITS');expect(memoryErrorCode(new Error('UNAVAILABLE: timed out'))).toBe('UNAVAILABLE');+ expect(memoryErrorCode(new Error('PLAN_REQUIRED: not in the plan'))).toBe('PLAN_REQUIRED');});it('returns null for an unrelated error', () => {@@ -218,6 +219,9 @@ describe('helpers', () => {expect(memoryErrorMessage({ message: 'x', data: { code: 'UNAVAILABLE' } }, t)).toBe('t:memory.error.unavailable');+ expect(memoryErrorMessage({ message: 'x', data: { code: 'PLAN_REQUIRED' } }, t)).toBe(+ 't:memory.error.planRequired'+ );// A rejected key and an engine fault keep their own message, and without// `t` nothing changes.expect(memoryErrorMessage(new Error('UNAUTHORIZED: bad key'), t)).toBe('UNAUTHORIZED: bad key');diff --git a/app/src/services/api/memoryApi.ts b/app/src/services/api/memoryApi.tsindex 06625e91c1..bb5d5de774 100644--- a/app/src/services/api/memoryApi.ts+++ b/app/src/services/api/memoryApi.ts@@ -554,6 +554,7 @@ export type MemoryErrorCode =| 'INVALID_REQUEST'| 'UNAUTHORIZED'| 'INSUFFICIENT_CREDITS'+ | 'PLAN_REQUIRED'| 'UNAVAILABLE'| 'ENGINE';@@ -563,6 +564,7 @@ const MEMORY_ERROR_CODES: readonly MemoryErrorCode[] = ['INVALID_REQUEST','UNAUTHORIZED','INSUFFICIENT_CREDITS',+ 'PLAN_REQUIRED','UNAVAILABLE','ENGINE',];@@ -623,7 +625,7 @@ export function memoryErrorCode(err: unknown): MemoryErrorCode | null {const message = (err as { message?: unknown }).message;if (typeof message === 'string') {const match =- /^\s*(MEMORY_OFF|UNSUPPORTED|INVALID_REQUEST|UNAUTHORIZED|INSUFFICIENT_CREDITS|UNAVAILABLE|ENGINE)\b/.exec(+ /^\s*(MEMORY_OFF|UNSUPPORTED|INVALID_REQUEST|UNAUTHORIZED|INSUFFICIENT_CREDITS|PLAN_REQUIRED|UNAVAILABLE|ENGINE)\b/.exec(message);if (match) return match[1] as MemoryErrorCode;@@ -634,11 +636,12 @@ export function memoryErrorCode(err: unknown): MemoryErrorCode | null {/*** The account-wide refusals whose raw message is engine detail, each told* apart from an engine fault and from an empty memory: out of credits means- * "top up", unreachable means "try again". `UNAUTHORIZED` keeps its own+ * "top up", not in the plan means "upgrade", unreachable means "try again". `UNAUTHORIZED` keeps its own* message, which names the rejected key or session.*/const REFUSAL_KEYS: Partial<Record<MemoryErrorCode, string>> = {INSUFFICIENT_CREDITS: 'memory.error.insufficientCredits',+ PLAN_REQUIRED: 'memory.error.planRequired',UNAVAILABLE: 'memory.error.unavailable',};@@ -676,6 +679,19 @@ export function isOutOfCreditsMessage(return message !== null && key !== undefined && message === t(key);}+/**+ * True when `message` is the "memory is not in your plan" explanation+ * `memoryErrorMessage` produced (with `t`) for `PLAN_REQUIRED` (#8081). Same+ * contract and language edge as {@link isOutOfCreditsMessage}.+ */+export function isPlanRequiredMessage(+ message: string | null,+ t: (key: string, fallback?: string) => string+): boolean {+ const key = REFUSAL_KEYS.PLAN_REQUIRED;+ return message !== null && key !== undefined && message === t(key);+}+/** True when the engine state means memory is usable (an engine is set and not off). *//** Engine id that turns memory off completely (`memory_engine_set`). */export const MEMORY_DISABLED_ENGINE = 'none';diff --git a/app/src/services/coreRpcClient.ts b/app/src/services/coreRpcClient.tsindex 9cebe0463b..215aefc671 100644--- a/app/src/services/coreRpcClient.ts+++ b/app/src/services/coreRpcClient.ts@@ -175,6 +175,12 @@ export function classifyRpcError(// feature build), never a transient fault. Classified before the generic// arms so polling callers can stop instead of retrying forever (#5157).if (message.startsWith(UNKNOWN_METHOD_PREFIX)) return 'method_not_found';+ // #8081: TinyMemory words a hosted 403, including `[MEMORY_PLAN_REQUIRED]`+ // (memory not in the account's plan), as "the session expired or the API+ // key was rejected (HTTP 403 …)". A refusal is never an expired session;+ // matching it below signed a valid user out on opening a Memory tab.+ // Mirrors Rust `is_session_expired_message`.+ if (/_PLAN_REQUIRED\]|\(HTTP 403/.test(message)) return 'unknown';// Confirmed OpenHuman session expiry — explicit markers from the backend/core.if (/Session expired|SESSION_EXPIRED/i.test(message)) return 'auth_expired';// Core-side "no backend session token" → the auth profile is gone but thediff --git a/crates/openhuman-core/src/core/invoke_tests.rs b/crates/openhuman-core/src/core/invoke_tests.rsindex ff4c3d4a27..35de6443fe 100644--- a/crates/openhuman-core/src/core/invoke_tests.rs+++ b/crates/openhuman-core/src/core/invoke_tests.rs@@ -212,6 +212,37 @@ fn local_offline_credential_does_not_publish_backend_session_expiry() {}}+/// #8081: a Memory tab on a plan without memory got `403 MEMORY_PLAN_REQUIRED`+/// from the hosted engine, whose message said "the session expired", and the+/// user was signed out. Neither that nor a plain memory 403 may publish+/// `SessionExpired`; a hosted memory 401 still does.+#[test]+fn memory_plan_refusal_and_403_do_not_publish_session_expiry() {+ for signed_in in [false, true] {+ for error in [+ // As pinned tinymemory words it today (wire capture, 2026-10-19).+ "unauthorized: [MEMORY_PLAN_REQUIRED] memory API memory/scopes on api.tinyhumans.ai: \+ the session expired or the API key was rejected (HTTP 403 Forbidden); \+ re-authenticate — memory is not included in this account's plan; nothing was processed",+ // As tinymemory words it once its fix is pinned.+ "engine error: [MEMORY_PLAN_REQUIRED] memory API memory/scopes on api.tinyhumans.ai: \+ memory is not included in this account's plan (HTTP 403 Forbidden)",+ "unauthorized: [FORBIDDEN] memory API memory/scopes on api.tinyhumans.ai: the session \+ expired or the API key was rejected (HTTP 403 Forbidden); re-authenticate",+ ] {+ assert!(!is_session_expired_error(error), "{error}");+ assert!(+ !should_publish_session_expired(error, !signed_in),+ "{error}"+ );+ }+ }+ let expired = "unauthorized: [UNAUTHORIZED] memory API memory/scopes on api.tinyhumans.ai: \+ the session expired or the API key was rejected (HTTP 401 Unauthorized); \+ re-authenticate";+ assert!(should_publish_session_expired(expired, false));+}+#[tokio::test]async fn invoke_method_rejects_array_params_for_registered_method() {// Registered controllers expect named-argument style (JSON object).diff --git a/crates/openhuman-core/src/core/observability.rs b/crates/openhuman-core/src/core/observability.rsindex 66bf9e7edb..5afdcaba2c 100644--- a/crates/openhuman-core/src/core/observability.rs+++ b/crates/openhuman-core/src/core/observability.rs@@ -542,7 +542,7 @@ pub fn expected_error_kind(message: &str) -> Option<ExpectedErrorKind> {if tinyinference_llm::failure::is_ollama_cloud_internal_500_message(message) {return Some(ExpectedErrorKind::TransientUpstreamHttp);}- if is_backend_user_error_message(&lower) {+ if is_backend_user_error_message(&lower) || is_plan_required_message(message) {return Some(ExpectedErrorKind::BackendUserError);}// Check `is_session_expired_message` BEFORE `is_embedding_backend_auth_failure`:@@ -900,6 +900,13 @@ fn is_embedding_model_rejected(lower: &str) -> bool {tinyinference_embeddings::probe::is_embedding_model_rejected(lower)}+/// Whether `msg` is the hosted backend refusing a feature the account's plan+/// does not include: a `[…_PLAN_REQUIRED]` code (`MEMORY_PLAN_REQUIRED`) as+/// tinymemory prefixes it. User state, never an expired session (#8081).+pub fn is_plan_required_message(msg: &str) -> bool {+ msg.contains("_PLAN_REQUIRED]")+}+/// Detect **app-session-expired** boundary errors that bubble up from any/// backend-touching call site (agent, web channel, cron, integrations).///@@ -953,6 +960,14 @@ fn is_embedding_model_rejected(lower: &str) -> bool {/// `DomainEvent::SessionExpired` publication, so downstream/provider 401s stay/// recoverable and do not clear the stored app session.pub fn is_session_expired_message(msg: &str) -> bool {+ // #8081: tinymemory's hosted mapping words every 403, including+ // `[MEMORY_PLAN_REQUIRED]` (memory not in the account's plan), as "the+ // session expired or the API key was rejected (HTTP 403 …)". A 403 or a+ // plan refusal never means the session expired, and signing out on one+ // logged a valid user out on opening a Memory tab.+ if is_plan_required_message(msg) || msg.contains("(HTTP 403") {+ return false;+ }let lower = msg.to_ascii_lowercase();lower.contains("session expired")|| lower.contains("no backend session token")diff --git a/crates/openhuman-core/src/core/observability_error_classification_session_tests.rs b/crates/openhuman-core/src/core/observability_error_classification_session_tests.rsindex 03786d30c0..2992d649ae 100644--- a/crates/openhuman-core/src/core/observability_error_classification_session_tests.rs+++ b/crates/openhuman-core/src/core/observability_error_classification_session_tests.rs@@ -742,3 +742,22 @@ fn classifies_offline_local_session_refusal_as_backend_unavailable() {));assert!(!is_session_expired_message(msg));}++#[test]+fn memory_plan_refusal_is_backend_user_state_not_session_expiry() {+ // #8081: memory not in the account's plan is user state for Sentry, and+ // must not read as an expired session (which signs the user out).+ let plan =+ "unauthorized: [MEMORY_PLAN_REQUIRED] memory API memory/scopes on api.tinyhumans.ai: \+ the session expired or the API key was rejected (HTTP 403 Forbidden); \+ re-authenticate — memory is not included in this account's plan";+ assert!(is_plan_required_message(plan));+ assert!(!is_session_expired_message(plan));+ assert_eq!(+ expected_error_kind(plan),+ Some(ExpectedErrorKind::BackendUserError)+ );+ assert!(!is_plan_required_message(+ "[USER_INSUFFICIENT_CREDITS] top up"+ ));+}diff --git a/crates/openhuman-core/src/memory/README.md b/crates/openhuman-core/src/memory/README.mdindex 2f5ad1069b..5f86cf9d22 100644--- a/crates/openhuman-core/src/memory/README.md+++ b/crates/openhuman-core/src/memory/README.md@@ -357,9 +357,10 @@ The agent `memory` tool applies the same confinement and overwrites anydisconnect.- `MemoryError` ([`error.rs`](./error.rs)): every RPC failure carries one of `MEMORY_OFF`,`UNSUPPORTED`, `INVALID_REQUEST`, `UNAUTHORIZED`, `INSUFFICIENT_CREDITS`,- `UNAVAILABLE` or `ENGINE` in `data.code`. The two account-wide refusals are- split out so a caller can tell "top up" and "try later" apart from an- engine fault.+ `PLAN_REQUIRED`, `UNAVAILABLE` or `ENGINE` in `data.code`. The account-wide+ refusals are split out so a caller can tell "top up", "upgrade" and "try+ later" apart from an engine fault. `PLAN_REQUIRED` (memory not in the+ account's plan, a hosted 403) never signs the user out (#8081).## RPC / CLI surfacediff --git a/crates/openhuman-core/src/memory/error.rs b/crates/openhuman-core/src/memory/error.rsindex c9311d9bcf..51093ae3ed 100644--- a/crates/openhuman-core/src/memory/error.rs+++ b/crates/openhuman-core/src/memory/error.rs@@ -3,9 +3,10 @@//! Every `openhuman.memory_*` failure carries a stable code in its//! structured error `data.code` (and `data.kind`): `MEMORY_OFF`,//! `UNSUPPORTED`, `INVALID_REQUEST`, `UNAUTHORIZED`, `INSUFFICIENT_CREDITS`,-//! `UNAVAILABLE`, `ENGINE` or `CONFIG_CONFLICT`. The two account-wide refusals are split out of-//! `ENGINE` so a caller can tell "top up" and "try again later" apart from an-//! engine fault, and neither from an empty memory (#6718). Messages never+//! `PLAN_REQUIRED`, `UNAVAILABLE`, `ENGINE` or `CONFIG_CONFLICT`. The+//! account-wide refusals are split out of `ENGINE` so a caller can tell "top+//! up", "upgrade" and "try again later" apart from an engine fault, and none+//! of them from an empty memory (#6718). Messages never//! carry a credential: engine errors are already sanitised by TinyMemory, and//! the host adds only ids and reasons.@@ -23,6 +24,9 @@ pub const INVALID_REQUEST: &str = "INVALID_REQUEST";pub const UNAUTHORIZED: &str = "UNAUTHORIZED";/// `data.code` when the hosted engine refused for an exhausted credit balance.pub const INSUFFICIENT_CREDITS: &str = "INSUFFICIENT_CREDITS";+/// `data.code` when the hosted engine refused because memory is not in the+/// account's plan (#8081). Not a credential fault: the session stays.+pub const PLAN_REQUIRED: &str = "PLAN_REQUIRED";/// `data.code` when the engine could not be reached or is overloaded.pub const UNAVAILABLE: &str = "UNAVAILABLE";/// `data.code` for the engine's own failure.@@ -48,6 +52,9 @@ pub enum MemoryError {/// The hosted engine refused: the account is out of credits.#[error("insufficient credits: {0}")]InsufficientCredits(String),+ /// The hosted engine refused: memory is not in the account's plan.+ #[error("plan required: {0}")]+ PlanRequired(String),/// The engine could not be reached, timed out or is overloaded.#[error("unavailable: {0}")]Unavailable(String),@@ -69,6 +76,7 @@ impl MemoryError {Self::InvalidRequest(_) => INVALID_REQUEST,Self::Unauthorized(_) => UNAUTHORIZED,Self::InsufficientCredits(_) => INSUFFICIENT_CREDITS,+ Self::PlanRequired(_) => PLAN_REQUIRED,Self::Unavailable(_) => UNAVAILABLE,Self::Engine(_) => ENGINE,Self::ConfigConflict(_) => CONFIG_CONFLICT,@@ -81,7 +89,8 @@ impl MemoryError {}/// Whether this refuses every request on the account, not just this one:- /// memory off, a rejected credential, no credits, or no engine to reach.+ /// memory off, a rejected credential, no credits, memory not in the plan,+ /// or no engine to reach./// A loop over items stops on these instead of skipping every item, and/// a queued job is not charged an attempt for them.#[must_use]@@ -91,6 +100,7 @@ impl MemoryError {Self::Off(_)| Self::Unauthorized(_)| Self::InsufficientCredits(_)+ | Self::PlanRequired(_)| Self::Unavailable(_))}@@ -115,7 +125,12 @@ impl From<tinymemory_api::Error> for MemoryError {use tinymemory_api::Error as E;// A 402 arrives as `Engine` with the backend's code on its message.let credits = tinymemory_integrations::cortex::is_insufficient_credits(&error);+ // A plan refusal (403 `[MEMORY_PLAN_REQUIRED]`) arrives as+ // `Unauthorized` from older TinyMemory and as `Engine` from newer, with+ // the code on its message either way (#8081).+ let plan = crate::core::observability::is_plan_required_message(&error.to_string());match error {+ E::Unauthorized(message) | E::Engine(message) if plan => Self::PlanRequired(message),E::Unsupported(message) => Self::Unsupported(message),E::InvalidRequest(message) | E::NotFound(message) => Self::InvalidRequest(message),E::Unauthorized(message) => Self::Unauthorized(message),diff --git a/crates/openhuman-core/src/memory/error_tests.rs b/crates/openhuman-core/src/memory/error_tests.rsindex d436759d26..9aa67bc31c 100644--- a/crates/openhuman-core/src/memory/error_tests.rs+++ b/crates/openhuman-core/src/memory/error_tests.rs@@ -74,6 +74,49 @@ fn account_wide_refusals_get_their_own_codes() {assert!(!MemoryError::invalid("bad").is_account_wide());}+/// #8081: memory not in the plan is its own account-wide user state, from+/// both TinyMemory wordings, and its RPC error never reads as an expired+/// session (which signs the user out).+#[test]+fn a_plan_refusal_is_plan_required_not_unauthorized() {+ use tinymemory_api::Error as E;+ for error in [+ E::Unauthorized(+ "[MEMORY_PLAN_REQUIRED] memory API memory/scopes on h: the session expired or the \+ API key was rejected (HTTP 403 Forbidden); re-authenticate — memory is not \+ included in this account's plan"+ .into(),+ ),+ E::Engine(+ "[MEMORY_PLAN_REQUIRED] memory API memory/scopes on h: memory is not included in \+ this account's plan (HTTP 403 Forbidden)"+ .into(),+ ),+ ] {+ let plan = MemoryError::from(error);+ assert_eq!(plan.code(), PLAN_REQUIRED);+ assert!(plan.is_account_wide());+ let structured = plan.to_structured();+ assert!(structured.expected_user_state);+ assert!(+ !crate::core::session_expiry::is_session_expired_error(&String::from(plan)),+ "{}",+ structured.message+ );+ }+ let expired = MemoryError::from(E::Unauthorized(+ "[UNAUTHORIZED] memory API memory/scopes on h: the session expired (HTTP 401)".into(),+ ));+ assert_eq!(expired.code(), UNAUTHORIZED);+ assert_eq!(+ MemoryError::refusal_from_skip_reason(+ "unauthorized: [MEMORY_PLAN_REQUIRED] memory API memory/scopes (HTTP 403 Forbidden)"+ )+ .map(|e| e.code()),+ Some(PLAN_REQUIRED)+ );+}+#[test]fn a_skip_reason_reads_back_only_account_wide_refusals() {let code = |reason: &str| MemoryError::refusal_from_skip_reason(reason).map(|e| e.code());diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host.rs b/crates/openhuman-core/src/memory/layout_migration/app_host.rsindex 765365c1c7..6031df6ff5 100644--- a/crates/openhuman-core/src/memory/layout_migration/app_host.rs+++ b/crates/openhuman-core/src/memory/layout_migration/app_host.rs@@ -42,7 +42,11 @@ pub(super) fn to_module(error: MemoryError) -> lm::Error {MemoryError::Off(message) => lm::Error::Off(message),MemoryError::InvalidRequest(message) => lm::Error::InvalidRequest(message),MemoryError::Unsupported(message) => EngineError::Unsupported(message).into(),- MemoryError::Unauthorized(message) => EngineError::Unauthorized(message).into(),+ // A plan refusal stops the migration as account-wide, as it did when+ // it arrived as `Unauthorized`; its `[CODE] ` stays on the message.+ MemoryError::Unauthorized(message) | MemoryError::PlanRequired(message) => {+ EngineError::Unauthorized(message).into()+ }MemoryError::Unavailable(message) => EngineError::Unavailable(message).into(),// The backend's `[CODE] ` prefix stays on the message, which is how// the module tells an exhausted balance.diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks.rs b/crates/openhuman-core/src/memory/lifecycle/hooks.rsindex 395266741f..e0756a4021 100644--- a/crates/openhuman-core/src/memory/lifecycle/hooks.rs+++ b/crates/openhuman-core/src/memory/lifecycle/hooks.rs@@ -111,6 +111,7 @@ impl TurnPack {MemoryError::InsufficientCredits(_) => {"the account is out of credits; topping up restores it"}+ MemoryError::PlanRequired(_) => "memory is not included in the account's plan",MemoryError::Unauthorized(_) => "the memory engine rejected the sign-in or API key",MemoryError::Unavailable(_) => "the memory engine could not be reached",_ => return None,