Skip to content

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

fix(memory): keep erase-all success when refresh callback fails

Steven Enamakel0ff8e5ac0564
diff --git a/app/src/components/memory/MemoryEraseAllCard.tsx b/app/src/components/memory/MemoryEraseAllCard.tsx
index 175058d73f..6c37a02d86 100644
--- a/app/src/components/memory/MemoryEraseAllCard.tsx
+++ b/app/src/components/memory/MemoryEraseAllCard.tsx
@@ -86,6 +86,7 @@ export default function MemoryEraseAllCard({
if (!acknowledged || erasing) return;
setErasing(true);
setError(null);
+ let erased = false;
try {
const result = await memoryEraseAll();
log('erase_all ok: erased_scopes=%d', result?.erased_scopes ?? 0);
@@ -97,7 +98,7 @@ export default function MemoryEraseAllCard({
});
setOpen(false);
setAcknowledged(false);
- onErased?.();
+ erased = true;
} catch (err) {
const key = eraseErrorKey(err);
log('erase_all failed: code=%s', memoryErrorCode(err) ?? 'none');
@@ -105,6 +106,14 @@ export default function MemoryEraseAllCard({
} finally {
setErasing(false);
}
+ // The erase has already succeeded; a refresh failure must not read as one.
+ if (erased) {
+ try {
+ onErased?.();
+ } catch (err) {
+ log('onErased callback failed: %s', err instanceof Error ? err.name : 'unknown');
+ }
+ }
};
return (
diff --git a/gitbooks/features/memory.md b/gitbooks/features/memory.md
index af80254e79..33485fac7f 100644
--- a/gitbooks/features/memory.md
+++ b/gitbooks/features/memory.md
@@ -34,7 +34,7 @@ An engine stores your memory and answers questions about it. There are two:
Either way your memory items are stored in CortexDB, not on your computer; OpenHuman keeps only bookkeeping (queued jobs, sync and import progress) locally. See [Where your memory is stored](privacy-and-security.md#where-your-memory-is-stored).
-Pick one on the **Engine** tab. If you are signed out and have no CortexDB key, memory is **off**: the agent has no memory tool, nothing is stored, and the Memory page tells you why.
+Pick one on the **Engine** tab. If you are signed out and have neither a CortexDB key nor a host-supplied TinyHumans API key, memory is **off**: the agent has no memory tool, nothing is stored, and the Memory page tells you why.
## What the engine does
diff --git a/gitbooks/guides/privacy-sensitive-data.md b/gitbooks/guides/privacy-sensitive-data.md
index 11ba26e8e9..432e2fbd74 100644
--- a/gitbooks/guides/privacy-sensitive-data.md
+++ b/gitbooks/guides/privacy-sensitive-data.md
@@ -15,7 +15,7 @@ If you want the engineering detail, read [Privacy & Security](../features/privac
## The one-sentence version
-**Your settings, files and secrets stay on your computer; your memory is stored in CortexDB (hosted by TinyHumans for your account, or your own). The OpenHuman backend handles what has to be brokered: signing you in, hosted memory, routing model requests, and talking to the services you connect.**
+**Your settings and secrets stay on your computer; your memory is stored in CortexDB (hosted by TinyHumans for your account, or your own). The OpenHuman backend handles what has to be brokered: signing you in, hosted memory, routing model requests, and talking to the services you connect.**
Everything below is an expansion of that sentence.
diff --git a/scripts/mock-api/routes/memory.mjs b/scripts/mock-api/routes/memory.mjs
index 94ccf6ec42..caf4a4411b 100644
--- a/scripts/mock-api/routes/memory.mjs
+++ b/scripts/mock-api/routes/memory.mjs
@@ -152,6 +152,8 @@ function eraseAll({ req, res }) {
const scopes = new Set(store.events.map((e) => e.scope)).size;
store.events = [];
store.packs.clear();
+ store.idempotency.clear();
+ store.claims.clear();
ok(res, { erased: true, scopes });
return true;
}
diff --git a/tests/memory_v2_e2e.rs b/tests/memory_v2_e2e.rs
index fe97b84ff0..1856ff4fdd 100644
--- a/tests/memory_v2_e2e.rs
+++ b/tests/memory_v2_e2e.rs
@@ -452,6 +452,7 @@ async fn memory_is_off_when_signed_out() {
("openhuman.memory_brain_ingest", json!({ "text": "a doc" })),
("openhuman.memory_jobs_run", json!({})),
("openhuman.memory_import_start", json!({ "consent": true })),
+ ("openhuman.memory_erase_all", json!({ "confirm": true })),
];
for (method, params) in off_calls {
assert_eq!(f.code(method, params).await, "MEMORY_OFF", "{method}");
@@ -963,6 +964,24 @@ async fn erase_all_needs_confirmation_and_erases_the_whole_hosted_memory() {
let f = Fixture::new(true).await;
f.learn("a fact about tea").await;
f.learn("a fact about coffee").await;
+ // A second hosted-memory category: a document, so a learnings-only
+ // erase cannot pass this test.
+ f.ok(
+ "openhuman.memory_brain_ingest",
+ json!({ "text": "a document about espresso machines" }),
+ )
+ .await;
+ let documents = |f: &Fixture| {
+ f.ok(
+ "openhuman.memory_items_list",
+ json!({ "filter": { "kinds": ["document"] } }),
+ )
+ };
+ let docs_before = documents(&f).await;
+ assert!(
+ !ids_of(&docs_before, "items").is_empty(),
+ "the document was stored: {docs_before}"
+ );
let before = f
.ok(
"openhuman.memory_items_list",
@@ -1005,6 +1024,8 @@ async fn erase_all_needs_confirmation_and_erases_the_whole_hosted_memory() {
)
.await;
assert_eq!(after["items"], json!([]), "{after}");
+ let docs_after = documents(&f).await;
+ assert_eq!(docs_after["items"], json!([]), "{docs_after}");
let refetch = f
.ok("openhuman.memory_fetch", json!({ "query": "coffee" }))
.await;