Skip to content

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

fix(memory): say beliefs are still building instead of showing an empty memory (#6718)

Ghost Scriptera981a766a74b
diff --git a/app/src/components/memory/MemoryLearningsTab.test.tsx b/app/src/components/memory/MemoryLearningsTab.test.tsx
index bfe7f8ce60..e6e312f02b 100644
--- a/app/src/components/memory/MemoryLearningsTab.test.tsx
+++ b/app/src/components/memory/MemoryLearningsTab.test.tsx
@@ -5,15 +5,31 @@ import type { Hit } from '../../services/api/memoryApi';
import { renderWithProviders } from '../../test/test-utils';
import MemoryLearningsTab from './MemoryLearningsTab';
-const hoisted = vi.hoisted(() => ({ list: vi.fn(), learn: vi.fn(), forget: vi.fn() }));
+const hoisted = vi.hoisted(() => ({
+ list: vi.fn(),
+ learn: vi.fn(),
+ forget: vi.fn(),
+ jobs: vi.fn(),
+}));
vi.mock('../../services/api/memoryApi', async importOriginal => ({
...(await importOriginal<typeof import('../../services/api/memoryApi')>()),
memoryItemsList: (...a: unknown[]) => hoisted.list(...a),
memoryLearn: (...a: unknown[]) => hoisted.learn(...a),
memoryForget: (...a: unknown[]) => hoisted.forget(...a),
+ memoryJobsList: (...a: unknown[]) => hoisted.jobs(...a),
}));
+function pendingBuild(id: string) {
+ return {
+ id,
+ root: 'default',
+ job: { job: 'build_beliefs' },
+ queued_at: '2026-10-06T00:00:00Z',
+ attempts: 0,
+ };
+}
+
function learning(id: string, text: string): Hit {
return { id, kind: 'learning', text, meta: {}, score: 0 };
}
@@ -22,6 +38,8 @@ beforeEach(() => {
hoisted.list.mockReset();
hoisted.learn.mockReset();
hoisted.forget.mockReset();
+ hoisted.jobs.mockReset();
+ hoisted.jobs.mockResolvedValue({ pending: [], history: [] });
});
describe('MemoryLearningsTab', () => {
@@ -55,6 +73,46 @@ describe('MemoryLearningsTab', () => {
hoisted.list.mockResolvedValue({ items: [] });
renderWithProviders(<MemoryLearningsTab />);
expect(await screen.findByTestId('memory-learnings-empty')).toBeInTheDocument();
+ await waitFor(() => expect(hoisted.jobs).toHaveBeenCalled());
+ expect(screen.queryByTestId('memory-learnings-deriving')).not.toBeInTheDocument();
+ });
+
+ it('says beliefs are still building when the list is empty and a build is pending', async () => {
+ hoisted.list.mockResolvedValue({ items: [] });
+ hoisted.jobs.mockResolvedValue({
+ pending: [pendingBuild('j1'), { ...pendingBuild('j2'), job: { job: 'ingest_brain' } }],
+ history: [],
+ });
+ renderWithProviders(<MemoryLearningsTab />);
+ expect(await screen.findByTestId('memory-learnings-deriving')).toHaveTextContent(
+ 'still building beliefs'
+ );
+ expect(screen.queryByTestId('memory-learnings-empty')).not.toBeInTheDocument();
+ });
+
+ it('keeps the plain empty state when only other jobs are pending or the queue cannot be read', async () => {
+ hoisted.list.mockResolvedValue({ items: [] });
+ hoisted.jobs.mockResolvedValue({
+ pending: [{ ...pendingBuild('j2'), job: { job: 'ingest_brain' } }],
+ history: [],
+ });
+ const { unmount } = renderWithProviders(<MemoryLearningsTab />);
+ expect(await screen.findByTestId('memory-learnings-empty')).toBeInTheDocument();
+ await waitFor(() => expect(hoisted.jobs).toHaveBeenCalled());
+ expect(screen.queryByTestId('memory-learnings-deriving')).not.toBeInTheDocument();
+ unmount();
+
+ hoisted.jobs.mockRejectedValue(new Error('core offline'));
+ renderWithProviders(<MemoryLearningsTab />);
+ expect(await screen.findByTestId('memory-learnings-empty')).toBeInTheDocument();
+ expect(screen.queryByTestId('memory-learnings-deriving')).not.toBeInTheDocument();
+ });
+
+ it('does not read the job queue when there are learnings', async () => {
+ hoisted.list.mockResolvedValue({ items: [learning('l1', 'Prefers dark mode')] });
+ renderWithProviders(<MemoryLearningsTab />);
+ await screen.findByTestId('memory-learning-l1');
+ expect(hoisted.jobs).not.toHaveBeenCalled();
});
it('pages with the cursor', async () => {
diff --git a/app/src/components/memory/MemoryLearningsTab.tsx b/app/src/components/memory/MemoryLearningsTab.tsx
index 8d930cfdd4..8a0b2ca587 100644
--- a/app/src/components/memory/MemoryLearningsTab.tsx
+++ b/app/src/components/memory/MemoryLearningsTab.tsx
@@ -4,6 +4,10 @@
* adds one with `memory_learn`, and deletes with `memory_forget`. Beliefs the
* background builder distilled (tagged `belief`) carry a "Built belief" badge.
*
+ * Beliefs are built by a queued background job minutes behind the writes, so
+ * an empty list while a build is pending reads as "still building", never as
+ * "no memory" (#6718).
+ *
* debug logging: DEBUG=openhuman:memory:learnings
*/
import debug from 'debug';
@@ -18,6 +22,7 @@ import {
memoryErrorMessage,
memoryForget,
memoryItemsList,
+ memoryJobsList,
memoryLearn,
} from '../../services/api/memoryApi';
import { Alert, AlertDescription, Button, Card, Label, NativeSelect, TextArea } from '../ui';
@@ -38,6 +43,7 @@ export default function MemoryLearningsTab() {
const [kind, setKind] = useState<LearningKind>('fact');
const [adding, setAdding] = useState(false);
const [deleting, setDeleting] = useState<string | null>(null);
+ const [buildsPending, setBuildsPending] = useState(false);
const kindLabel = (k: LearningKind): string => {
switch (k) {
@@ -64,6 +70,28 @@ export default function MemoryLearningsTab() {
return page;
}, []);
+ // Only asked when the list is empty; a failure leaves the plain empty state.
+ const empty = items !== null && items.length === 0;
+ useEffect(() => {
+ if (!empty) return;
+ let cancelled = false;
+ memoryJobsList()
+ .then(jobs => {
+ if (cancelled) return;
+ const pending = (jobs.pending ?? []).filter(job => job.job?.job === 'build_beliefs');
+ log('empty list: %d belief build(s) pending', pending.length);
+ setBuildsPending(pending.length > 0);
+ })
+ .catch(err => {
+ if (cancelled) return;
+ log('jobs list failed: %o', err);
+ setBuildsPending(false);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [empty]);
+
const reload = useCallback(async () => {
setError(null);
try {
@@ -196,7 +224,13 @@ export default function MemoryLearningsTab() {
<CenteredLoadingState label={t('memoryPage.loading')} />
) : (
<Card title={t('memoryPage.learnings.listTitle')} data-testid="memory-learnings-list">
- {items.length === 0 ? (
+ {items.length === 0 && buildsPending ? (
+ <p
+ className="px-4 py-3 text-sm text-content-muted"
+ data-testid="memory-learnings-deriving">
+ {t('memoryPage.learnings.deriving')}
+ </p>
+ ) : items.length === 0 ? (
<p
className="px-4 py-3 text-sm text-content-muted"
data-testid="memory-learnings-empty">
diff --git a/app/src/lib/i18n/ar.ts b/app/src/lib/i18n/ar.ts
index 024b811536..451f960c03 100644
--- a/app/src/lib/i18n/ar.ts
+++ b/app/src/lib/i18n/ar.ts
@@ -4914,6 +4914,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'المعلومات المكتسبة',
'memoryPage.learnings.empty':
'لا توجد معلومات مكتسبة بعد. أضف واحدة أعلاه، أو سيضيفها وكيلك أثناء عمله معك.',
+ 'memoryPage.learnings.deriving':
+ 'لا شيء هنا بعد. لا تزال الذاكرة تبني المعتقدات من محادثاتك الأخيرة؛ ستظهر هنا بعد التشغيل التالي في الخلفية.',
'memoryPage.learnings.delete': 'حذف المعلومة',
'memoryPage.conversations.turns': '{count} أدوار',
'memoryPage.documents.listDescription': 'تُبقيها الذاكرة متزامنة وتجيب اعتمادًا على محتواها.',
diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.ts
index c4217d75ee..7e211cf054 100644
--- a/app/src/lib/i18n/bn.ts
+++ b/app/src/lib/i18n/bn.ts
@@ -5007,6 +5007,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'শেখা বিষয়',
'memoryPage.learnings.empty':
'এখনও কোনো শেখা বিষয় নেই। উপরে একটি যোগ করুন, অথবা আপনার সঙ্গে কাজ করতে করতে আপনার এজেন্ট নিজেই যোগ করবে।',
+ 'memoryPage.learnings.deriving':
+ 'এখনও এখানে কিছু নেই। মেমরি এখনও আপনার সাম্প্রতিক কথোপকথন থেকে ধারণা তৈরি করছে; পরবর্তী ব্যাকগ্রাউন্ড রানের পরে সেগুলো এখানে দেখা যাবে।',
'memoryPage.learnings.delete': 'শেখা বিষয় মুছুন',
'memoryPage.conversations.turns': '{count}টি টার্ন',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/de.ts b/app/src/lib/i18n/de.ts
index 5e290563f9..23ce93c8f9 100644
--- a/app/src/lib/i18n/de.ts
+++ b/app/src/lib/i18n/de.ts
@@ -5147,6 +5147,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Erkenntnisse',
'memoryPage.learnings.empty':
'Noch keine Erkenntnisse. Füge oben eine hinzu, oder dein Agent ergänzt sie bei der Zusammenarbeit mit dir.',
+ 'memoryPage.learnings.deriving':
+ 'Noch nichts da. Das Gedächtnis baut noch Überzeugungen aus deinen letzten Unterhaltungen auf; sie erscheinen hier nach dem nächsten Hintergrundlauf.',
'memoryPage.learnings.delete': 'Erkenntnis löschen',
'memoryPage.conversations.turns': '{count} Runden',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.ts
index ededa46198..b4abf72ab7 100644
--- a/app/src/lib/i18n/en.ts
+++ b/app/src/lib/i18n/en.ts
@@ -5285,6 +5285,8 @@ const en: TranslationMap = {
'memoryPage.learnings.listTitle': 'Learnings',
'memoryPage.learnings.empty':
'No learnings yet. Add one above, or your agent will add them as it works with you.',
+ 'memoryPage.learnings.deriving':
+ 'Nothing here yet. Memory is still building beliefs from your recent conversations; they appear here after the next background run.',
'memoryPage.learnings.delete': 'Delete learning',
'memoryPage.conversations.turns': '{count} turns',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/es.ts b/app/src/lib/i18n/es.ts
index 2cb5b3f359..1884898bad 100644
--- a/app/src/lib/i18n/es.ts
+++ b/app/src/lib/i18n/es.ts
@@ -5100,6 +5100,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Aprendizajes',
'memoryPage.learnings.empty':
'Aún no hay aprendizajes. Añade uno arriba o tu agente los añadirá a medida que trabaje contigo.',
+ 'memoryPage.learnings.deriving':
+ 'Aún no hay nada. La memoria todavía está construyendo creencias a partir de tus conversaciones recientes; aparecerán aquí tras la próxima ejecución en segundo plano.',
'memoryPage.learnings.delete': 'Eliminar aprendizaje',
'memoryPage.conversations.turns': '{count} turnos',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/fr.ts b/app/src/lib/i18n/fr.ts
index f6aac151c7..beace251ce 100644
--- a/app/src/lib/i18n/fr.ts
+++ b/app/src/lib/i18n/fr.ts
@@ -5125,6 +5125,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Acquis',
'memoryPage.learnings.empty':
"Aucun acquis pour l'instant. Ajoutez-en un ci-dessus, ou votre agent en ajoutera au fil de votre travail commun.",
+ 'memoryPage.learnings.deriving':
+ "Rien pour l'instant. La mémoire construit encore des croyances à partir de vos conversations récentes ; elles apparaîtront ici après la prochaine exécution en arrière-plan.",
'memoryPage.learnings.delete': "Supprimer l'acquis",
'memoryPage.conversations.turns': '{count} échanges',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/hi.ts b/app/src/lib/i18n/hi.ts
index f714481e10..8282198870 100644
--- a/app/src/lib/i18n/hi.ts
+++ b/app/src/lib/i18n/hi.ts
@@ -5006,6 +5006,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'सीखी बातें',
'memoryPage.learnings.empty':
'अभी कोई सीखी बात नहीं है। ऊपर एक जोड़ें, या आपका एजेंट आपके साथ काम करते हुए खुद जोड़ देगा।',
+ 'memoryPage.learnings.deriving':
+ 'यहाँ अभी कुछ नहीं है। मेमोरी अभी भी आपकी हाल की बातचीत से धारणाएँ बना रही है; अगली बैकग्राउंड रन के बाद वे यहाँ दिखेंगी।',
'memoryPage.learnings.delete': 'सीखी बात हटाएँ',
'memoryPage.conversations.turns': '{count} टर्न',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/id.ts b/app/src/lib/i18n/id.ts
index ceeb72fd7a..fb416f088e 100644
--- a/app/src/lib/i18n/id.ts
+++ b/app/src/lib/i18n/id.ts
@@ -5047,6 +5047,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Pembelajaran',
'memoryPage.learnings.empty':
'Belum ada pembelajaran. Tambahkan satu di atas, atau agen Anda akan menambahkannya saat bekerja bersama Anda.',
+ 'memoryPage.learnings.deriving':
+ 'Belum ada apa-apa. Memori masih membangun keyakinan dari percakapan terbaru Anda; keyakinan akan muncul di sini setelah proses latar belakang berikutnya.',
'memoryPage.learnings.delete': 'Hapus pembelajaran',
'memoryPage.conversations.turns': '{count} giliran',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/it.ts b/app/src/lib/i18n/it.ts
index 44c129ac75..33a87e3059 100644
--- a/app/src/lib/i18n/it.ts
+++ b/app/src/lib/i18n/it.ts
@@ -5085,6 +5085,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Apprendimenti',
'memoryPage.learnings.empty':
'Ancora nessun apprendimento. Aggiungine uno qui sopra, oppure il tuo agente li aggiungerà mentre lavora con te.',
+ 'memoryPage.learnings.deriving':
+ 'Ancora niente qui. La memoria sta ancora costruendo convinzioni dalle tue conversazioni recenti; compariranno qui dopo la prossima esecuzione in background.',
'memoryPage.learnings.delete': 'Elimina apprendimento',
'memoryPage.conversations.turns': '{count} scambi',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/ko.ts b/app/src/lib/i18n/ko.ts
index 8aa482511d..5ddbde45d4 100644
--- a/app/src/lib/i18n/ko.ts
+++ b/app/src/lib/i18n/ko.ts
@@ -4961,6 +4961,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': '학습 내용',
'memoryPage.learnings.empty':
'아직 학습 내용이 없습니다. 위에서 추가하거나, 에이전트가 함께 일하면서 직접 추가합니다.',
+ 'memoryPage.learnings.deriving':
+ '아직 아무것도 없습니다. 메모리가 최근 대화에서 신념을 만드는 중이며, 다음 백그라운드 실행 후 여기에 표시됩니다.',
'memoryPage.learnings.delete': '학습 내용 삭제',
'memoryPage.conversations.turns': '{count}턴',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/pl.ts b/app/src/lib/i18n/pl.ts
index 29601b629b..f9c6c7584f 100644
--- a/app/src/lib/i18n/pl.ts
+++ b/app/src/lib/i18n/pl.ts
@@ -5074,6 +5074,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Wnioski',
'memoryPage.learnings.empty':
'Brak wniosków. Dodaj pierwszy powyżej albo agent będzie je dodawać w trakcie pracy z Tobą.',
+ 'memoryPage.learnings.deriving':
+ 'Na razie nic tu nie ma. Pamięć wciąż buduje przekonania z Twoich ostatnich rozmów; pojawią się tutaj po następnym uruchomieniu w tle.',
'memoryPage.learnings.delete': 'Usuń wniosek',
'memoryPage.conversations.turns': 'Wymian: {count}',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/pt.ts b/app/src/lib/i18n/pt.ts
index 01a48f5125..82a19325a8 100644
--- a/app/src/lib/i18n/pt.ts
+++ b/app/src/lib/i18n/pt.ts
@@ -5075,6 +5075,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Aprendizados',
'memoryPage.learnings.empty':
'Nenhum aprendizado ainda. Adicione um acima, ou seu agente os adicionará conforme trabalha com você.',
+ 'memoryPage.learnings.deriving':
+ 'Nada aqui ainda. A memória ainda está construindo crenças a partir das suas conversas recentes; elas aparecerão aqui após a próxima execução em segundo plano.',
'memoryPage.learnings.delete': 'Excluir aprendizado',
'memoryPage.conversations.turns': '{count} turnos',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/ru.ts b/app/src/lib/i18n/ru.ts
index d859bc9efe..52f645a945 100644
--- a/app/src/lib/i18n/ru.ts
+++ b/app/src/lib/i18n/ru.ts
@@ -5057,6 +5057,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': 'Знания',
'memoryPage.learnings.empty':
'Пока нет знаний. Добавьте их выше, или агент будет добавлять их сам по ходу работы с вами.',
+ 'memoryPage.learnings.deriving':
+ 'Пока здесь пусто. Память ещё формирует убеждения из ваших недавних разговоров; они появятся здесь после следующего фонового запуска.',
'memoryPage.learnings.delete': 'Удалить знание',
'memoryPage.conversations.turns': 'Реплик: {count}',
'memoryPage.documents.listDescription':
diff --git a/app/src/lib/i18n/zh-CN.ts b/app/src/lib/i18n/zh-CN.ts
index 6393c37089..6bc2d9d12c 100644
--- a/app/src/lib/i18n/zh-CN.ts
+++ b/app/src/lib/i18n/zh-CN.ts
@@ -4733,6 +4733,8 @@ const messages: TranslationMap = {
'memoryPage.learnings.listTitle': '学习内容',
'memoryPage.learnings.empty':
'还没有学习内容。请在上方添加,或者让你的智能体在与你协作的过程中自动添加。',
+ 'memoryPage.learnings.deriving':
+ '这里还没有内容。记忆仍在根据你最近的对话构建信念,下一次后台运行后会显示在这里。',
'memoryPage.learnings.delete': '删除学习内容',
'memoryPage.conversations.turns': '{count} 轮',
'memoryPage.documents.listDescription': '记忆会保持这些内容同步,并根据其中的内容作答。',
diff --git a/docs/specs/memory-v2.md b/docs/specs/memory-v2.md
index d15280c8a5..a2ad2b10bc 100644
--- a/docs/specs/memory-v2.md
+++ b/docs/specs/memory-v2.md
@@ -247,3 +247,8 @@ and the pack preview), `explorer`, `learnings` (built beliefs marked),
search, ingest, synced sources), `background` (the job queue) and `settings`
(the recall policy). Legacy `?brain=context` maps to `ask`, `documents`,
`sources`, `sync` and `history` to `brain`, `graph` and `goals` to `ask`.
+
+Writes are visible as soon as they return (`WaitFor::Visible`); only beliefs
+lag, built by a queued job at least `build_delay_secs` behind the writes. So
+an empty `learnings` list while a `build_beliefs` job is pending says beliefs
+are still being built, never that memory is empty.