Describe the bug
AI conversation records are ordered by created_at alone. A turn's user and assistant records are inserted back to back once the stream ends, and TIMESTAMP columns are stored at whole-second precision, so the pair almost always shares one created_at. The database resolves the tie as it pleases, and often enough the answer comes back before its question. This shows in the conversation views and in the context built for the next turn.
The same tie exposes the prompt. The opening question is stored as the full rendered prompt, and both detail endpoints replace the first record's content with the conversation topic. When the answer sorts first, the answer is overwritten with the topic and the stored prompt appears in full one record later.
To Reproduce
- Ask the AI assistant a question and wait for the answer.
- Open the conversation in Admin > AI Assistant, or reopen it from the chat history.
- Some conversations show the answer above the question; some show the prompt template as the user message and the question text where the answer should be.
Whether a given conversation is affected depends on how the database orders the tied rows, so it is intermittent. Observed on PostgreSQL (Aurora) with v2.0.2.
Expected behavior
Records appear in the order they were written, and the topic only ever replaces the opening question.
Platform
- Device: Desktop
- OS: macOS
- Browser and version: Chrome
- Version: v2.0.2
Describe the bug
AI conversation records are ordered by
created_atalone. A turn's user and assistant records are inserted back to back once the stream ends, andTIMESTAMPcolumns are stored at whole-second precision, so the pair almost always shares onecreated_at. The database resolves the tie as it pleases, and often enough the answer comes back before its question. This shows in the conversation views and in the context built for the next turn.The same tie exposes the prompt. The opening question is stored as the full rendered prompt, and both detail endpoints replace the first record's content with the conversation topic. When the answer sorts first, the answer is overwritten with the topic and the stored prompt appears in full one record later.
To Reproduce
Whether a given conversation is affected depends on how the database orders the tied rows, so it is intermittent. Observed on PostgreSQL (Aurora) with v2.0.2.
Expected behavior
Records appear in the order they were written, and the topic only ever replaces the opening question.
Platform