Corrections
Retract one record the model read wrongly, for good, and optionally say what is true instead.
Records are read by a model, and a model can get one wrong. /v1/memory/correct takes one
record back. It does not touch what the person said: the message stays, and only the reading of it is retracted.
Correct a record
Pass the record's id as search returns it under facts, and, if you know it, what is true instead:
curl https://api.twinmemory.dev/v1/memory/correct \
-H "Authorization: Bearer $TWIN_MEMORY_API_KEY" \
-H "X-Twin-Account: user_42" \
-H "Content-Type: application/json" \
-d '{
"record_id": "th_8b5e5d4c8946d815#r028d461216652fe5",
"replacement": "Alice lives in Porto since 2026-10-15."
}'{
"retracted": "th_8b5e5d4c8946d815#r028d461216652fe5",
"text": "Alice lives in Lisbon",
"replacement": "correction-334be8de711f8fde"
}text is the record that was retracted. replacement is the id of the note that holds what is true instead, or
null when you sent none.
What changes, and when
- At once: search,
knownand history stop showing the record. In the example, history for Alice'shome_citythen returns only Berlin. - At once: the replacement is added as a note with the id
correction-<digest>, and search finds it by its words. - Later: the replacement note is read into records like any other note, the next time the end user's memory is read.
For good
A correction is kept apart from the records it applies to. When the conversation is read again, or the end user's memory is rebuilt, the retracted record stays retracted.
A record that is already retracted is no longer held, so correcting it again answers 404. To change what the
replacement says, add the note again with its id, correction-…, and new text: that is an
edit like any other.
Other records keep their ids. A record also has an address of the form records/th_x.json#3, a position in its
file, which correct also accepts; addresses after a retracted record move down by one, so prefer the id.
When there is nothing to correct
A record id the end user does not hold answers 404 no record '<id>' in this account. Records exist only after
the conversation has been read, so a correction right after an add finds nothing.
To remove what a person said, not the reading of it, use forget. To fix an item you added, such as a typo, send it again with the same id; see Versions & edits. When something changed, add a new item: memory keeps both, dated.
Related
- Correct reference.
- Lineage: find the words a record was read from before you correct it.