-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution][AI Assistant] Update ConversationSummary schema and interface (#13657)
#232288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution][AI Assistant] Update ConversationSummary schema and interface (#13657)
#232288
Conversation
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
|
cc @pgayvallet keeping you in the loop for the summarization related changes. |
...elastic_assistant/server/ai_assistant_data_clients/conversations/field_maps_configuration.ts
Show resolved
Hide resolved
| }, | ||
| 'summary.public': { | ||
| type: 'boolean', | ||
| 'summary.semantic_content': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not applicable to us now since we're deprecating summary.content, but wanted to mention that the common pattern I've seen for when wanting to add embeddings for an existing field you can use copy_to or multi-fields, that way inserts and search stay the same.
jbudz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.buildkite/ftr_security_serverless_configs.yml LGTM
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
cc @e40pud |
| const updatedAt = new Date().toISOString(); | ||
| const params = transformToUpdateScheme(updatedAt, conversationUpdateProps); | ||
|
|
||
| const maxRetries = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering why did you remove this retry logic? Sometimes there can be a conflict when updating the title at the same time as appending a message, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found this bulk update API option that we can use https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict. Will update bulk updates accordingly.
…date (#233288) ## Summary Part of Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 In my [previous PR](#232288), I accidentally removed "retry on conflict" [logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978). These changes add a retry logic on bulk update conflicts. For that we use a `retry_on_conflict` option https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict. The retry count is set to 3 to match previous behaviour. cc @stephmilovic
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
#233428) ## Summary Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 RFC: [internal link](https://docs.google.com/document/d/13jAJ5Q3_At_zAuwKjvpYehnM5uzKJSwZIZ1aJJNAf5k) This PR reverts conversation mappings changes introduced in #232288. Since we decided to put on hold the Using Past Conversation as Context feature, we decided to remove added summary field backed by the `semantic_text` field to avoid potential issues that users mights have when updating a conversation while the inference endpoint is not available. **Changes**: * Removed mapping fields: `semantic_content` and `summarized_message_ids` * As part of these changes, the `summary` field was hidden on the API level and conversations response object won't have it anymore --------- Co-authored-by: kibanamachine <[email protected]>
…date (elastic#233288) ## Summary Part of Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 In my [previous PR](elastic#232288), I accidentally removed "retry on conflict" [logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978). These changes add a retry logic on bulk update conflicts. For that we use a `retry_on_conflict` option https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict. The retry count is set to 3 to match previous behaviour. cc @stephmilovic
elastic#233428) ## Summary Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 RFC: [internal link](https://docs.google.com/document/d/13jAJ5Q3_At_zAuwKjvpYehnM5uzKJSwZIZ1aJJNAf5k) This PR reverts conversation mappings changes introduced in elastic#232288. Since we decided to put on hold the Using Past Conversation as Context feature, we decided to remove added summary field backed by the `semantic_text` field to avoid potential issues that users mights have when updating a conversation while the inference endpoint is not available. **Changes**: * Removed mapping fields: `semantic_content` and `summarized_message_ids` * As part of these changes, the `summary` field was hidden on the API level and conversations response object won't have it anymore --------- Co-authored-by: kibanamachine <[email protected]>
… and interface (elastic#13657) (elastic#232288) ## Summary Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 RFC: [internal link](https://docs.google.com/document/d/13jAJ5Q3_At_zAuwKjvpYehnM5uzKJSwZIZ1aJJNAf5k) With these changes we update the conversation summary schema to accommodate new fields to allow conversation summarization and past conversation search. Also, as part of these changes, the OLD (unused) summary fields are removed from the APIs. ### Mapping changes The conversations index mapping already has a `summary` field which is an object that looks like: <details> <summary><b>OLD</b> summary schema</summary> ```json "summary": { "properties": { "@timestamp": { "type": "date" }, "confidence": { "type": "keyword" }, "content": { "type": "text" }, "public": { "type": "boolean" } } } ``` </details> To be able to summarize conversations and semantically search through existing summaries, the new fields (`semantic_content` and `summarized_message_ids`) are added into the mapping: <details> <summary><b>Updated</b> summary schema</summary> ```json "summary": { "properties": { "@timestamp": { "type": "date" }, "confidence": { "type": "keyword" }, "content": { "type": "text" }, "public": { "type": "boolean" }, "semantic_content": { "type": "semantic_text", "inference_id": ".elser-2-elasticsearch" }, "summarized_message_ids": { "type": "keyword", "array": true } } } ``` </details> ### New fields description `semantic_content` field will be used to store conversation summary and allows semantical search through the ELSER v2 or E5 models. `summarized_message_ids` field will contain a list of all messages that are summarized and part of the summary stored within the `semantic_content` field. ### Legacy fields and API interface changes There are bunch of fields that were never used and won't be supported or used in future - `summary.confidence`, `summary.content` and `summary.public`. After discussion with @YulNaumenko and @elastic/security-generative-ai, this fields will be marked as legacy on the mappings level for compatibility with the installed indices and will be removed on the API level. Previously, we allowed to update `summary.confidence`, `summary.content` and `summary.public` fields via API calls and never used in kibana UI. **NOTE**: Thanks @spong to pointing to [this cluster](https://overview.elastic-cloud.com/app/dashboards#/view/serverless-api-services-http-requests-overview?_g=h@6558260) to see the API usage in production. It shows that within last 90 days, the update conversation API (the only way for users to update conversations and potentially add a summary to it) was used only 41 times which looks low and I believe negligible. <img width="1144" height="423" alt="Screenshot 2025-08-20 at 10 50 35" src="https://github.com/user-attachments/assets/6cb8e1a2-4d9d-44d2-8e66-2de6d8ac74e2" /> From now on, the conversation will have next summary fields on the **API level**: ```typescript interface ConversationSummary { /** * The timestamp summary was updated. */ timestamp: string; /** * Summary text of the conversation over time. */ semanticContent?: string; /** * The list of summarized messages. */ summarizedMessageIds?: string[]; } ``` ### Testing To test, you can use next API calls: <details> <summary><b>Fetch</b> all existing conversations</summary> This call will fetch all existing conversation. Good for overview of existing conversations and verifying expected summary values. ```curl curl --location 'http://localhost:5601/sbb/api/security_ai_assistant/current_user/conversations/_find' \ --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \ --header 'kbn-xsrf: true' \ --header 'elastic-api-version: 2023-10-31' ``` </details> <details> <summary><b>Update</b> a conversation</summary> This call will update a conversation and add/update a summary. ```curl curl --location --request PUT 'http://localhost:5601/sbb/api/security_ai_assistant/current_user/conversations/{{CONVERSATION_ID}}' \ --header 'kbn-xsrf: true' \ --header 'elastic-api-version: 2023-10-31' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \ --data '{ "id": "a565baa8-5566-47b2-ab69-807248b2fc46", "summary": { "semanticContent": "Very nice demo semantic content." } }' ``` </details> <details> <summary><b>Bulk Update</b> existing conversation(s)</summary> This call will update a conversation and add/update a summary. ```curl curl --location 'http://localhost:5601/sbb/internal/elastic_assistant/current_user/conversations/_bulk_action' \ --header 'kbn-xsrf: true' \ --header 'elastic-api-version: 1' \ --header 'x-elastic-internal-origin: Kibana' \ --header 'kbn-version: 9.2.0' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \ --data '{ "update": [ { "id": "{{CONVERSATION_ID}}", "summary": { "semanticContent": "Very nice demo semantic content." } } ] }' ``` </details> Some test cases: 1. Check that if not updated, a new conversation does not have a summary 2. Check that `summary` contains expected value after it has been updated via one of the above APIs 3. Check that we do not return legacy fields (`summary.confidence`, `summary.content` and `summary.public`) even if you add a document with those fields set. You can set legacy fields, either via DevTools or via update APIs from above in previous kibana version. --------- Co-authored-by: kibanamachine <[email protected]>
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
…date (elastic#233288) ## Summary Part of Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 In my [previous PR](elastic#232288), I accidentally removed "retry on conflict" [logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978). These changes add a retry logic on bulk update conflicts. For that we use a `retry_on_conflict` option https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict. The retry count is set to 3 to match previous behaviour. cc @stephmilovic
elastic#233428) ## Summary Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 RFC: [internal link](https://docs.google.com/document/d/13jAJ5Q3_At_zAuwKjvpYehnM5uzKJSwZIZ1aJJNAf5k) This PR reverts conversation mappings changes introduced in elastic#232288. Since we decided to put on hold the Using Past Conversation as Context feature, we decided to remove added summary field backed by the `semantic_text` field to avoid potential issues that users mights have when updating a conversation while the inference endpoint is not available. **Changes**: * Removed mapping fields: `semantic_content` and `summarized_message_ids` * As part of these changes, the `summary` field was hidden on the API level and conversations response object won't have it anymore --------- Co-authored-by: kibanamachine <[email protected]>
… and interface (elastic#13657) (elastic#232288) ## Summary Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 RFC: [internal link](https://docs.google.com/document/d/13jAJ5Q3_At_zAuwKjvpYehnM5uzKJSwZIZ1aJJNAf5k) With these changes we update the conversation summary schema to accommodate new fields to allow conversation summarization and past conversation search. Also, as part of these changes, the OLD (unused) summary fields are removed from the APIs. ### Mapping changes The conversations index mapping already has a `summary` field which is an object that looks like: <details> <summary><b>OLD</b> summary schema</summary> ```json "summary": { "properties": { "@timestamp": { "type": "date" }, "confidence": { "type": "keyword" }, "content": { "type": "text" }, "public": { "type": "boolean" } } } ``` </details> To be able to summarize conversations and semantically search through existing summaries, the new fields (`semantic_content` and `summarized_message_ids`) are added into the mapping: <details> <summary><b>Updated</b> summary schema</summary> ```json "summary": { "properties": { "@timestamp": { "type": "date" }, "confidence": { "type": "keyword" }, "content": { "type": "text" }, "public": { "type": "boolean" }, "semantic_content": { "type": "semantic_text", "inference_id": ".elser-2-elasticsearch" }, "summarized_message_ids": { "type": "keyword", "array": true } } } ``` </details> ### New fields description `semantic_content` field will be used to store conversation summary and allows semantical search through the ELSER v2 or E5 models. `summarized_message_ids` field will contain a list of all messages that are summarized and part of the summary stored within the `semantic_content` field. ### Legacy fields and API interface changes There are bunch of fields that were never used and won't be supported or used in future - `summary.confidence`, `summary.content` and `summary.public`. After discussion with @YulNaumenko and @elastic/security-generative-ai, this fields will be marked as legacy on the mappings level for compatibility with the installed indices and will be removed on the API level. Previously, we allowed to update `summary.confidence`, `summary.content` and `summary.public` fields via API calls and never used in kibana UI. **NOTE**: Thanks @spong to pointing to [this cluster](https://overview.elastic-cloud.com/app/dashboards#/view/serverless-api-services-http-requests-overview?_g=h@6558260) to see the API usage in production. It shows that within last 90 days, the update conversation API (the only way for users to update conversations and potentially add a summary to it) was used only 41 times which looks low and I believe negligible. <img width="1144" height="423" alt="Screenshot 2025-08-20 at 10 50 35" src="https://github.com/user-attachments/assets/6cb8e1a2-4d9d-44d2-8e66-2de6d8ac74e2" /> From now on, the conversation will have next summary fields on the **API level**: ```typescript interface ConversationSummary { /** * The timestamp summary was updated. */ timestamp: string; /** * Summary text of the conversation over time. */ semanticContent?: string; /** * The list of summarized messages. */ summarizedMessageIds?: string[]; } ``` ### Testing To test, you can use next API calls: <details> <summary><b>Fetch</b> all existing conversations</summary> This call will fetch all existing conversation. Good for overview of existing conversations and verifying expected summary values. ```curl curl --location 'http://localhost:5601/sbb/api/security_ai_assistant/current_user/conversations/_find' \ --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \ --header 'kbn-xsrf: true' \ --header 'elastic-api-version: 2023-10-31' ``` </details> <details> <summary><b>Update</b> a conversation</summary> This call will update a conversation and add/update a summary. ```curl curl --location --request PUT 'http://localhost:5601/sbb/api/security_ai_assistant/current_user/conversations/{{CONVERSATION_ID}}' \ --header 'kbn-xsrf: true' \ --header 'elastic-api-version: 2023-10-31' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \ --data '{ "id": "a565baa8-5566-47b2-ab69-807248b2fc46", "summary": { "semanticContent": "Very nice demo semantic content." } }' ``` </details> <details> <summary><b>Bulk Update</b> existing conversation(s)</summary> This call will update a conversation and add/update a summary. ```curl curl --location 'http://localhost:5601/sbb/internal/elastic_assistant/current_user/conversations/_bulk_action' \ --header 'kbn-xsrf: true' \ --header 'elastic-api-version: 1' \ --header 'x-elastic-internal-origin: Kibana' \ --header 'kbn-version: 9.2.0' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==' \ --data '{ "update": [ { "id": "{{CONVERSATION_ID}}", "summary": { "semanticContent": "Very nice demo semantic content." } } ] }' ``` </details> Some test cases: 1. Check that if not updated, a new conversation does not have a summary 2. Check that `summary` contains expected value after it has been updated via one of the above APIs 3. Check that we do not return legacy fields (`summary.confidence`, `summary.content` and `summary.public`) even if you add a document with those fields set. You can set legacy fields, either via DevTools or via update APIs from above in previous kibana version. --------- Co-authored-by: kibanamachine <[email protected]>
…date (elastic#233288) ## Summary Part of Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 In my [previous PR](elastic#232288), I accidentally removed "retry on conflict" [logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978). These changes add a retry logic on bulk update conflicts. For that we use a `retry_on_conflict` option https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict. The retry count is set to 3 to match previous behaviour. cc @stephmilovic (cherry picked from commit 8170cff) # Conflicts: # x-pack/solutions/security/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/index.test.ts
…date (elastic#233288) ## Summary Part of Epic: elastic/security-team#12768 Meta: elastic/security-team#13657 In my [previous PR](elastic#232288), I accidentally removed "retry on conflict" [logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978). These changes add a retry logic on bulk update conflicts. For that we use a `retry_on_conflict` option https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict. The retry count is set to 3 to match previous behaviour. cc @stephmilovic (cherry picked from commit 8170cff) # Conflicts: # x-pack/solutions/security/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/index.test.ts
…ulk update (#233288) (#234867) # Backport This will backport the following commits from `main` to `9.1`: - [[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)](#233288) <!--- Backport version: 10.0.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-29T15:04:39Z","message":"[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)\n\n## Summary\n\nPart of\nEpic: https://github.com/elastic/security-team/issues/12768\nMeta: https://github.com/elastic/security-team/issues/13657\n\nIn my [previous PR](#232288), I\naccidentally removed \"retry on conflict\"\n[logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978).\n\nThese changes add a retry logic on bulk update conflicts. For that we\nuse a `retry_on_conflict` option\nhttps://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict.\nThe retry count is set to 3 to match previous behaviour.\n\ncc @stephmilovic","sha":"8170cff4f95f5dad24f3d40f0b2a84ab083af93e","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team: SecuritySolution","Team:Security Generative AI","v9.2.0"],"title":"[Security Solution][AI Assistant] Handle conflicts during the bulk update","number":233288,"url":"https://github.com/elastic/kibana/pull/233288","mergeCommit":{"message":"[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)\n\n## Summary\n\nPart of\nEpic: https://github.com/elastic/security-team/issues/12768\nMeta: https://github.com/elastic/security-team/issues/13657\n\nIn my [previous PR](#232288), I\naccidentally removed \"retry on conflict\"\n[logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978).\n\nThese changes add a retry logic on bulk update conflicts. For that we\nuse a `retry_on_conflict` option\nhttps://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict.\nThe retry count is set to 3 to match previous behaviour.\n\ncc @stephmilovic","sha":"8170cff4f95f5dad24f3d40f0b2a84ab083af93e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233288","number":233288,"mergeCommit":{"message":"[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)\n\n## Summary\n\nPart of\nEpic: https://github.com/elastic/security-team/issues/12768\nMeta: https://github.com/elastic/security-team/issues/13657\n\nIn my [previous PR](#232288), I\naccidentally removed \"retry on conflict\"\n[logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978).\n\nThese changes add a retry logic on bulk update conflicts. For that we\nuse a `retry_on_conflict` option\nhttps://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict.\nThe retry count is set to 3 to match previous behaviour.\n\ncc @stephmilovic","sha":"8170cff4f95f5dad24f3d40f0b2a84ab083af93e"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
…bulk update (#233288) (#234869) # Backport This will backport the following commits from `main` to `8.19`: - [[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)](#233288) <!--- Backport version: 10.0.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-29T15:04:39Z","message":"[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)\n\n## Summary\n\nPart of\nEpic: https://github.com/elastic/security-team/issues/12768\nMeta: https://github.com/elastic/security-team/issues/13657\n\nIn my [previous PR](#232288), I\naccidentally removed \"retry on conflict\"\n[logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978).\n\nThese changes add a retry logic on bulk update conflicts. For that we\nuse a `retry_on_conflict` option\nhttps://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict.\nThe retry count is set to 3 to match previous behaviour.\n\ncc @stephmilovic","sha":"8170cff4f95f5dad24f3d40f0b2a84ab083af93e","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team: SecuritySolution","Team:Security Generative AI","v9.2.0"],"title":"[Security Solution][AI Assistant] Handle conflicts during the bulk update","number":233288,"url":"https://github.com/elastic/kibana/pull/233288","mergeCommit":{"message":"[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)\n\n## Summary\n\nPart of\nEpic: https://github.com/elastic/security-team/issues/12768\nMeta: https://github.com/elastic/security-team/issues/13657\n\nIn my [previous PR](#232288), I\naccidentally removed \"retry on conflict\"\n[logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978).\n\nThese changes add a retry logic on bulk update conflicts. For that we\nuse a `retry_on_conflict` option\nhttps://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict.\nThe retry count is set to 3 to match previous behaviour.\n\ncc @stephmilovic","sha":"8170cff4f95f5dad24f3d40f0b2a84ab083af93e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233288","number":233288,"mergeCommit":{"message":"[Security Solution][AI Assistant] Handle conflicts during the bulk update (#233288)\n\n## Summary\n\nPart of\nEpic: https://github.com/elastic/security-team/issues/12768\nMeta: https://github.com/elastic/security-team/issues/13657\n\nIn my [previous PR](#232288), I\naccidentally removed \"retry on conflict\"\n[logic](https://github.com/elastic/kibana/pull/232288/files#r2305375978).\n\nThese changes add a retry logic on bulk update conflicts. For that we\nuse a `retry_on_conflict` option\nhttps://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk#operation-bulk-body-application-json-update-retry_on_conflict.\nThe retry count is set to 3 to match previous behaviour.\n\ncc @stephmilovic","sha":"8170cff4f95f5dad24f3d40f0b2a84ab083af93e"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
Summary
Epic: https://github.com/elastic/security-team/issues/12768
Meta: https://github.com/elastic/security-team/issues/13657
RFC: internal link
With these changes we update the conversation summary schema to accommodate new fields to allow conversation summarization and past conversation search. Also, as part of these changes, the OLD (unused) summary fields are removed from the APIs.
Mapping changes
The conversations index mapping already has a
summaryfield which is an object that looks like:OLD summary schema
To be able to summarize conversations and semantically search through existing summaries, the new fields (
semantic_contentandsummarized_message_ids) are added into the mapping:Updated summary schema
New fields description
semantic_contentfield will be used to store conversation summary and allows semantical search through the ELSER v2 or E5 models.summarized_message_idsfield will contain a list of all messages that are summarized and part of the summary stored within thesemantic_contentfield.Legacy fields and API interface changes
There are bunch of fields that were never used and won't be supported or used in future -
summary.confidence,summary.contentandsummary.public. After discussion with @YulNaumenko and @elastic/security-generative-ai, this fields will be marked as legacy on the mappings level for compatibility with the installed indices and will be removed on the API level. Previously, we allowed to updatesummary.confidence,summary.contentandsummary.publicfields via API calls and never used in kibana UI.NOTE: Thanks @spong to pointing to this cluster to see the API usage in production. It shows that within last 90 days, the update conversation API (the only way for users to update conversations and potentially add a summary to it) was used only 41 times which looks low and I believe negligible.
From now on, the conversation will have next summary fields on the API level:
Testing
To test, you can use next API calls:
Fetch all existing conversations
This call will fetch all existing conversation. Good for overview of existing conversations and verifying expected summary values.
Update a conversation
This call will update a conversation and add/update a summary.
Bulk Update existing conversation(s)
This call will update a conversation and add/update a summary.
Some test cases:
summarycontains expected value after it has been updated via one of the above APIssummary.confidence,summary.contentandsummary.public) even if you add a document with those fields set. You can set legacy fields, either via DevTools or via update APIs from above in previous kibana version.