Answers that appeared on screen and then vanished
The problem
A reply would stream beautifully into the chat, and then be gone when the player reopened the thread the next day. Nothing in the client was wrong, and the failure was invisible in development, where the process stays alive.
What we did
The route was sending its terminal done event and closing the stream before persisting the assistant message. On a serverless platform, closing the response is a signal the function may be reclaimed, so the write that followed sometimes never ran and left no error, because the process was already gone. We reordered the stream lifecycle so the database write completes first and the stream closes last, and added explicit error capture on both the primary write and the truncation-retry write, which had been failing silently.
The outcome
Conversation history became reliable, and the class of bug that produces no logs was removed rather than patched.
















