0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00

fix(memory): surface a failed write when draining a local turn for the gateway

The drain that ends a locally started turn before a gateway-managed step
swallowed the persistence rejection and cleared both turn references. Since
`end()` marks the turn ended before it writes, the turn could not be retried,
so its unsaved messages were lost while the run reported success.

The drain now persists the turn's unsaved messages directly as a recovery and
rethrows, so a storage failure reaches the caller. The write condition mirrors
`end()`, which only writes when there are messages to write.

The docs now name the Gateway project-key exclusions: a project that routes a
request with your own provider key, or that has memory disabled, is proxied
without stored observations while Mastra skips local Observational Memory for
`mastra/` models, so neither side keeps the conversation.

The end-to-end test now asserts the stored turn includes the model's reply
instead of only the user message.

Co-Authored-By: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
This commit is contained in:
mastra-platform[bot] 2026-11-15 03:51:39 +00:00
commit a0a4d3f691
6 changed files with 79 additions and 7 deletions