#1929·InsForge

[Feature]: a forget endpoint for agent memory, /api/memory has no way to remove a stored fact

Author: ssrajadhCreated Aug 11, 2026Updated Sep 24, 2026
Labelsenhancementneeds-triage

What feature do you want?

A forget verb on /api/memory, so an agent can remove a memory it stored.

The memory API is remember / recall / index, and all three are mounted here. MemoryService has three public methods to match. There is no fourth verb and no delete path on the service.

I'd like to add one, and I'd like to keep it small. Concretely:

POST /api/memory/forget

jsonc
// request
{ "scope": "default", "ids": ["<uuid>", "<uuid>"] }

// response
{ "forgotten": ["<uuid>"] }   // ids actually removed, in the caller's scope

Design choices, each picked to match something already in the tree rather than to introduce a new opinion:

Decision Choice Matches
Verb + method POST /forget the other three routes are all POST with scope in the body
Selector explicit UUIDs only, no delete-by-query, no delete-by-scope blast radius; index already hands an agent the ids
Scope guard WHERE scope = $1 AND id = ANY($2) recall and index are both scope-filtered
Unknown id 200 with that id simply absent from forgotten remember returns NOOP rather than erroring; keeps retries idempotent
Deletion hard DELETE no migration needed; see the note on tombstones below

Scoping the delete by scope rather than by id alone is the point I'd most want reviewed. It mirrors the guard remember already applies on the reconcile path, an UPDATE is honored only when target_id is a real UUID and appears in the matched set, so a hallucinated id can never reach the DB. A model that can hallucinate an id for UPDATE can hallucinate one for forget, and forget is the verb that can't be undone. Requiring the id to live in the caller's own scope applies the same defense to the same threat.

Scope of the change: +1 route handler, +1 service method, +2 schemas in packages/shared-schemas/src/memory-api.schema.ts, and cases added to backend/tests/unit/memory.service.test.ts (mocked pool, asserting the scope predicate is present, and that an id from another scope removes nothing). No migration. No new dependency. Nothing in openapi/, since memory has no spec there yet.

One thing I deliberately left out of v1. A hard delete means a forgotten fact can come back: the next transcript that mentions it goes through extraction, finds no near-duplicate above RECONCILE_THRESHOLD, and ADDs it again. Preventing that needs a tombstone, a migration, plus a filter in recall, index, and the reconcile match set. That's a bigger change with a real design question inside it (is forgetting an erasure or an assertion that something is false?), so I've left it out rather than smuggle it in. Happy to open it separately if the answer is that resurrection matters.

Why do you need this?

Today nothing can remove a memory, not the agent that wrote it, and not the data API.

The obvious workaround doesn't exist, which is the part worth checking before this gets triaged as "just use the database." /api/database/records/:table proxies to PostgREST and does support DELETE, but migration 056 exposes schemas to that proxy on a deny-list, and memory is named in the deny-list alongside auth, storage, and the rest of the internal schemas. So memory.memories is walled off from the data API by design.

That leaves exactly one way to delete a row: POST /api/database/advance/rawsql, which is verifyAdmin, a human with admin credentials writing SQL by hand. The memory routes authenticate with verifyApiKey, because memory is "a platform-managed primitive" whose callers are the CLI / agent. Those two audiences don't overlap. An agent cannot remove anything it stored, through any route.

Why that costs something:

  1. Wrong facts are sticky. remember converges via reconcile, UPDATE when a near-duplicate is found above RECONCILE_THRESHOLD, ADD otherwise. That corrects a memory when a replacement shows up. It has no answer for a memory that is simply wrong, or newly irrelevant, with nothing to supersede it. "We chose Redis for the job queue" survives the switch to Postgres until someone happens to write something similar enough to trigger an UPDATE instead of an ADD.
  2. recall will surface it. The vector arm has DEFAULT_RECALL_THRESHOLD to keep unrelated queries quiet, but the keyword arm has no threshold at all, and RRF makes a row eligible if either arm matched. A stale memory containing the right identifier ranks on the query it's stale about. The recency tiebreak pushes toward current truth only among rows already tied.
  3. It's the operational verb people ask for first. A secret pasted into a transcript, a customer's data under a per-user scope, a fact that was never true. Right now every one of those escalates to an admin with a SQL console.

I hit (1) building an app on this API and had to drop to rawsql to clear a bad row, which is what prompted the issue.

I raised this as one of the open questions at the end of #1908 and would rather ask it here, where it's concrete and separable: is deletion absent by design? A store that only accumulates and merges is a defensible position, it makes memory append-only and auditable, and I'd take that as an answer. But I couldn't tell from the source whether it's a decision or a not-yet, and the deny-list entry in 056 suggests the surface has been thought about deliberately enough that it might be the former.