Raised by the local cross-family review of LibreChat-AI#16551 (finding local:73acf4a:L-002).
The compaction abort path in api/server/routes/agents/index.js asks resolveAbortedTurnAnchorDecision (packages/api) whether the projected anchor row exists, then saves the aborted response with that anchor as parentMessageId. If the anchor row is deleted between the existence read and the save (a user deleting the message while Stop is in flight), the response is written as an orphan.
The window predates LibreChat-AI#16551: on dev the abort route saves without any anchor check, and LibreChat-AI#16551 narrows it to the read-to-write span. Closing it needs a conditional, parent-checked write in a data-schemas method (or a transaction) rather than a separate existence read, the same shape as the fix for #232.
Raised by the local cross-family review of LibreChat-AI#16551 (finding local:73acf4a:L-002).
The compaction abort path in
api/server/routes/agents/index.jsasksresolveAbortedTurnAnchorDecision(packages/api) whether the projected anchor row exists, then saves the aborted response with that anchor asparentMessageId. If the anchor row is deleted between the existence read and the save (a user deleting the message while Stop is in flight), the response is written as an orphan.The window predates LibreChat-AI#16551: on
devthe abort route saves without any anchor check, and LibreChat-AI#16551 narrows it to the read-to-write span. Closing it needs a conditional, parent-checked write in a data-schemas method (or a transaction) rather than a separate existence read, the same shape as the fix for #232.