[Security Assistant] Fixes conversation message not appended/title not updating#233219
[Security Assistant] Fixes conversation message not appended/title not updating#233219stephmilovic merged 7 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
|
This change: https://github.com/elastic/kibana/pull/232288/files#r2305375978 |
|
We might want to consider using this bulk update API option https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict |
|
Client side changes look good! @e40pud's suggestion sounds reasonable for the server-side code. |
|
Here are the changes that I proposed #233288 |
This is great for the bulk update, but since |
| ]); | ||
|
|
||
| const maxRetries = 3; | ||
| const maxRetries = 10; |
There was a problem hiding this comment.
I do not think this is enough. I have seen up to 8 retries happen.
We should fix the exponential backoff below to actually be exponential. E.g:
const delay = Math.min(50 * 2 ** attempt, 1000);
|
@elasticmachine merge upstream |
KDKHD
left a comment
There was a problem hiding this comment.
Tested locally and was unable to reproduce the original issue.
💚 Build Succeeded
Metrics [docs]Page load bundle
History
|
|
Starting backport for target branches: 8.19, 9.1 https://github.com/elastic/kibana/actions/runs/17656003638 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…t updating (elastic#233219) (cherry picked from commit b81bbd0)
…t updating (elastic#233219) (cherry picked from commit b81bbd0)
…itle not updating (#233219) (#234967) # Backport This will backport the following commits from `main` to `8.19`: - [[Security Assistant] Fixes conversation message not appended/title not updating (#233219)](#233219) <!--- Backport version: 10.0.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"stephanie.milovic@elastic.co"},"sourceCommit":{"committedDate":"2025-09-11T20:06:53Z","message":"[Security Assistant] Fixes conversation message not appended/title not updating (#233219)","sha":"b81bbd005f94e6a333b04b06da3ac108e179fa6a","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team: SecuritySolution","backport:version","v9.2.0","v9.1.3","v8.19.3"],"title":"[Security Assistant] Fixes conversation message not appended/title not updating","number":233219,"url":"https://github.com/elastic/kibana/pull/233219","mergeCommit":{"message":"[Security Assistant] Fixes conversation message not appended/title not updating (#233219)","sha":"b81bbd005f94e6a333b04b06da3ac108e179fa6a"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233219","number":233219,"mergeCommit":{"message":"[Security Assistant] Fixes conversation message not appended/title not updating (#233219)","sha":"b81bbd005f94e6a333b04b06da3ac108e179fa6a"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Ievgen Sorokopud <ievgen.sorokopud@elastic.co>
…tle not updating (#233219) (#234966) # Backport This will backport the following commits from `main` to `9.1`: - [[Security Assistant] Fixes conversation message not appended/title not updating (#233219)](#233219) <!--- Backport version: 10.0.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"stephanie.milovic@elastic.co"},"sourceCommit":{"committedDate":"2025-09-11T20:06:53Z","message":"[Security Assistant] Fixes conversation message not appended/title not updating (#233219)","sha":"b81bbd005f94e6a333b04b06da3ac108e179fa6a","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team: SecuritySolution","backport:version","v9.2.0","v9.1.3","v8.19.3"],"title":"[Security Assistant] Fixes conversation message not appended/title not updating","number":233219,"url":"https://github.com/elastic/kibana/pull/233219","mergeCommit":{"message":"[Security Assistant] Fixes conversation message not appended/title not updating (#233219)","sha":"b81bbd005f94e6a333b04b06da3ac108e179fa6a"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233219","number":233219,"mergeCommit":{"message":"[Security Assistant] Fixes conversation message not appended/title not updating (#233219)","sha":"b81bbd005f94e6a333b04b06da3ac108e179fa6a"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Ievgen Sorokopud <ievgen.sorokopud@elastic.co>
Summary
While working on assistant sharing, I discovered several related bugs tied to race conditions and async/sync mismatches in conversation handling:
These issues were all related to conflicts in updating the data stream after changes were made to run title generation and first message handling asynchronously within the graph.
Root Causes
Data Conflicts During Message Append
Title Not Updating Reliably
Loading Comment Flicker
isFetchingResponsestate only covered API call completion, not the entire message flow.Fixes Implemented
Backend
append_conversation_messages.tsupdateByQuerywithDocumentsDataWriter.bulkfor safer updates.DocumentsDataWriter.Frontend
use_chat_send.tsxisLoadingChatSendstate that persists for the entire flow.try...finallyblock to ensure consistent state.Results
✅ Assistant’s first response is always saved
✅ Conversation titles now update reliably, even under async conditions
✅ Loading comment stays visible until the full response arrives (no flicker)
✅ Improved user experience with smooth, reliable message handling
Visual Examples
Missing first response due to race condition:

Title not updating reliably in UI:

How to Test