JSON working-memory updates can lose unrelated concurrent edits
Concurrent JSON working-memory updates can overwrite unrelated changes. For example, two callers read { "name": "A", "tone": "brief" }; one changes name, and the other changes tone. Submitting each full record through updateWorkingMemory leaves only the last caller's changes.
The schema-based working-memory tool merges a read snapshot before saving, but the read and save are separate storage operations. An in-process lock also cannot serialize writes from separate server processes.
This is reproducible with the memory implementation at fdcd75925fcfa3cfc6b2333bfc1fbdfb79ad97e3. Replacement is useful and should remain the default. An explicit resource-scoped JSON merge, performed inside a PostgreSQL row-locked transaction, would let callers preserve unrelated concurrent fields. Unsupported adapters should reject an explicit merge rather than silently replace the record.
I have a proposed change with separate-connection PostgreSQL tests covering simultaneous first writes, unrelated edits, deletion, metadata preservation, and rollback. It also covers server authorization and client transport. Full-record replacement writers would retain their existing behavior.
Source: mastra-ai/mastra