Skip to content

Commit 634ec77

Browse files
e40pudkibanamachine
authored andcommitted
[Security Solution][AI Assistant] Update ConversationSummary schema 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]>
1 parent b0fa542 commit 634ec77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2111
-531
lines changed

.buildkite/ftr_security_serverless_configs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ enabled:
108108
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/attack_discovery/schedules/trial_license_complete_tier/configs/serverless.config.ts
109109
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/attack_discovery/schedules/basic_license_essentials_tier/configs/ess.config.ts
110110
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/attack_discovery/schedules/basic_license_essentials_tier/configs/serverless.config.ts
111+
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/conversations/trial_license_complete_tier/configs/ess.config.ts
112+
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/conversations/trial_license_complete_tier/configs/serverless.config.ts
111113
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/trial_license_complete_tier/configs/serverless.config.ts
112114
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/risk_engine/basic_license_essentials_tier/configs/serverless.config.ts
113115
- x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/entity_store/trial_license_complete_tier/configs/serverless.config.ts

oas_docs/output/kibana.serverless.yaml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61559,14 +61559,6 @@ components:
6155961559
- insights
6156061560
example: assistant
6156161561
type: string
61562-
Security_AI_Assistant_API_ConversationConfidence:
61563-
description: The conversation confidence.
61564-
enum:
61565-
- low
61566-
- medium
61567-
- high
61568-
example: high
61569-
type: string
6157061562
Security_AI_Assistant_API_ConversationCreateProps:
6157161563
type: object
6157261564
properties:
@@ -61651,24 +61643,28 @@ components:
6165161643
- namespace
6165261644
- category
6165361645
Security_AI_Assistant_API_ConversationSummary:
61646+
allOf:
61647+
- $ref: '#/components/schemas/Security_AI_Assistant_API_ConversationSummaryBase'
61648+
- type: object
61649+
properties:
61650+
timestamp:
61651+
$ref: '#/components/schemas/Security_AI_Assistant_API_NonEmptyTimestamp'
61652+
description: The timestamp summary was updated.
61653+
example: '2025-04-30T16:00:00Z'
61654+
required:
61655+
- timestamp
61656+
Security_AI_Assistant_API_ConversationSummaryBase:
6165461657
type: object
6165561658
properties:
61656-
confidence:
61657-
$ref: '#/components/schemas/Security_AI_Assistant_API_ConversationConfidence'
61658-
description: How confident you are about this being a correct and useful learning.
61659-
example: high
61660-
content:
61659+
semanticContent:
6166161660
description: Summary text of the conversation over time.
6166261661
example: This conversation covered how to configure the Security AI Assistant.
6166361662
type: string
61664-
public:
61665-
description: Define if summary is marked as publicly available.
61666-
example: true
61667-
type: boolean
61668-
timestamp:
61669-
$ref: '#/components/schemas/Security_AI_Assistant_API_NonEmptyTimestamp'
61670-
description: The timestamp summary was updated.
61671-
example: '2025-04-30T16:00:00Z'
61663+
summarizedMessageIds:
61664+
description: The list of summarized messages.
61665+
items:
61666+
$ref: '#/components/schemas/Security_AI_Assistant_API_NonEmptyString'
61667+
type: array
6167261668
Security_AI_Assistant_API_ConversationUpdateProps:
6167361669
type: object
6167461670
properties:
@@ -61692,7 +61688,7 @@ components:
6169261688
replacements:
6169361689
$ref: '#/components/schemas/Security_AI_Assistant_API_Replacements'
6169461690
summary:
61695-
$ref: '#/components/schemas/Security_AI_Assistant_API_ConversationSummary'
61691+
$ref: '#/components/schemas/Security_AI_Assistant_API_ConversationSummaryBase'
6169661692
title:
6169761693
description: The conversation title.
6169861694
example: Updated Security AI Assistant Setup

oas_docs/output/kibana.yaml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74108,14 +74108,6 @@ components:
7410874108
- insights
7410974109
example: assistant
7411074110
type: string
74111-
Security_AI_Assistant_API_ConversationConfidence:
74112-
description: The conversation confidence.
74113-
enum:
74114-
- low
74115-
- medium
74116-
- high
74117-
example: high
74118-
type: string
7411974111
Security_AI_Assistant_API_ConversationCreateProps:
7412074112
type: object
7412174113
properties:
@@ -74200,24 +74192,28 @@ components:
7420074192
- namespace
7420174193
- category
7420274194
Security_AI_Assistant_API_ConversationSummary:
74195+
allOf:
74196+
- $ref: '#/components/schemas/Security_AI_Assistant_API_ConversationSummaryBase'
74197+
- type: object
74198+
properties:
74199+
timestamp:
74200+
$ref: '#/components/schemas/Security_AI_Assistant_API_NonEmptyTimestamp'
74201+
description: The timestamp summary was updated.
74202+
example: '2025-04-30T16:00:00Z'
74203+
required:
74204+
- timestamp
74205+
Security_AI_Assistant_API_ConversationSummaryBase:
7420374206
type: object
7420474207
properties:
74205-
confidence:
74206-
$ref: '#/components/schemas/Security_AI_Assistant_API_ConversationConfidence'
74207-
description: How confident you are about this being a correct and useful learning.
74208-
example: high
74209-
content:
74208+
semanticContent:
7421074209
description: Summary text of the conversation over time.
7421174210
example: This conversation covered how to configure the Security AI Assistant.
7421274211
type: string
74213-
public:
74214-
description: Define if summary is marked as publicly available.
74215-
example: true
74216-
type: boolean
74217-
timestamp:
74218-
$ref: '#/components/schemas/Security_AI_Assistant_API_NonEmptyTimestamp'
74219-
description: The timestamp summary was updated.
74220-
example: '2025-04-30T16:00:00Z'
74212+
summarizedMessageIds:
74213+
description: The list of summarized messages.
74214+
items:
74215+
$ref: '#/components/schemas/Security_AI_Assistant_API_NonEmptyString'
74216+
type: array
7422174217
Security_AI_Assistant_API_ConversationUpdateProps:
7422274218
type: object
7422374219
properties:
@@ -74241,7 +74237,7 @@ components:
7424174237
replacements:
7424274238
$ref: '#/components/schemas/Security_AI_Assistant_API_Replacements'
7424374239
summary:
74244-
$ref: '#/components/schemas/Security_AI_Assistant_API_ConversationSummary'
74240+
$ref: '#/components/schemas/Security_AI_Assistant_API_ConversationSummaryBase'
7424574241
title:
7424674242
description: The conversation title.
7424774243
example: Updated Security AI Assistant Setup

x-pack/platform/packages/shared/kbn-elastic-assistant-common/docs/openapi/ess/elastic_assistant_api_2023_10_31.bundled.schema.yaml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,14 +1959,6 @@ components:
19591959
- insights
19601960
example: assistant
19611961
type: string
1962-
ConversationConfidence:
1963-
description: The conversation confidence.
1964-
enum:
1965-
- low
1966-
- medium
1967-
- high
1968-
example: high
1969-
type: string
19701962
ConversationCreateProps:
19711963
type: object
19721964
properties:
@@ -2051,28 +2043,30 @@ components:
20512043
- namespace
20522044
- category
20532045
ConversationSummary:
2046+
allOf:
2047+
- $ref: '#/components/schemas/ConversationSummaryBase'
2048+
- type: object
2049+
properties:
2050+
timestamp:
2051+
$ref: '#/components/schemas/NonEmptyTimestamp'
2052+
description: The timestamp summary was updated.
2053+
example: '2025-04-30T16:00:00Z'
2054+
required:
2055+
- timestamp
2056+
ConversationSummaryBase:
20542057
type: object
20552058
properties:
2056-
confidence:
2057-
$ref: '#/components/schemas/ConversationConfidence'
2058-
description: >-
2059-
How confident you are about this being a correct and useful
2060-
learning.
2061-
example: high
2062-
content:
2059+
semanticContent:
20632060
description: Summary text of the conversation over time.
20642061
example: >-
20652062
This conversation covered how to configure the Security AI
20662063
Assistant.
20672064
type: string
2068-
public:
2069-
description: Define if summary is marked as publicly available.
2070-
example: true
2071-
type: boolean
2072-
timestamp:
2073-
$ref: '#/components/schemas/NonEmptyTimestamp'
2074-
description: The timestamp summary was updated.
2075-
example: '2025-04-30T16:00:00Z'
2065+
summarizedMessageIds:
2066+
description: The list of summarized messages.
2067+
items:
2068+
$ref: '#/components/schemas/NonEmptyString'
2069+
type: array
20762070
ConversationUpdateProps:
20772071
type: object
20782072
properties:
@@ -2096,7 +2090,7 @@ components:
20962090
replacements:
20972091
$ref: '#/components/schemas/Replacements'
20982092
summary:
2099-
$ref: '#/components/schemas/ConversationSummary'
2093+
$ref: '#/components/schemas/ConversationSummaryBase'
21002094
title:
21012095
description: The conversation title.
21022096
example: Updated Security AI Assistant Setup

x-pack/platform/packages/shared/kbn-elastic-assistant-common/docs/openapi/serverless/elastic_assistant_api_2023_10_31.bundled.schema.yaml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,14 +1959,6 @@ components:
19591959
- insights
19601960
example: assistant
19611961
type: string
1962-
ConversationConfidence:
1963-
description: The conversation confidence.
1964-
enum:
1965-
- low
1966-
- medium
1967-
- high
1968-
example: high
1969-
type: string
19701962
ConversationCreateProps:
19711963
type: object
19721964
properties:
@@ -2051,28 +2043,30 @@ components:
20512043
- namespace
20522044
- category
20532045
ConversationSummary:
2046+
allOf:
2047+
- $ref: '#/components/schemas/ConversationSummaryBase'
2048+
- type: object
2049+
properties:
2050+
timestamp:
2051+
$ref: '#/components/schemas/NonEmptyTimestamp'
2052+
description: The timestamp summary was updated.
2053+
example: '2025-04-30T16:00:00Z'
2054+
required:
2055+
- timestamp
2056+
ConversationSummaryBase:
20542057
type: object
20552058
properties:
2056-
confidence:
2057-
$ref: '#/components/schemas/ConversationConfidence'
2058-
description: >-
2059-
How confident you are about this being a correct and useful
2060-
learning.
2061-
example: high
2062-
content:
2059+
semanticContent:
20632060
description: Summary text of the conversation over time.
20642061
example: >-
20652062
This conversation covered how to configure the Security AI
20662063
Assistant.
20672064
type: string
2068-
public:
2069-
description: Define if summary is marked as publicly available.
2070-
example: true
2071-
type: boolean
2072-
timestamp:
2073-
$ref: '#/components/schemas/NonEmptyTimestamp'
2074-
description: The timestamp summary was updated.
2075-
example: '2025-04-30T16:00:00Z'
2065+
summarizedMessageIds:
2066+
description: The list of summarized messages.
2067+
items:
2068+
$ref: '#/components/schemas/NonEmptyString'
2069+
type: array
20762070
ConversationUpdateProps:
20772071
type: object
20782072
properties:
@@ -2096,7 +2090,7 @@ components:
20962090
replacements:
20972091
$ref: '#/components/schemas/Replacements'
20982092
summary:
2099-
$ref: '#/components/schemas/ConversationSummary'
2093+
$ref: '#/components/schemas/ConversationSummaryBase'
21002094
title:
21012095
description: The conversation title.
21022096
example: Updated Security AI Assistant Setup

x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/conversations/common_attributes.gen.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,26 +298,28 @@ export const ApiConfig = z.object({
298298
model: z.string().optional(),
299299
});
300300

301-
export type ConversationSummary = z.infer<typeof ConversationSummary>;
302-
export const ConversationSummary = z.object({
301+
export type ConversationSummaryBase = z.infer<typeof ConversationSummaryBase>;
302+
export const ConversationSummaryBase = z.object({
303303
/**
304304
* Summary text of the conversation over time.
305305
*/
306-
content: z.string().optional(),
307-
/**
308-
* The timestamp summary was updated.
309-
*/
310-
timestamp: NonEmptyTimestamp.optional(),
306+
semanticContent: z.string().optional(),
311307
/**
312-
* Define if summary is marked as publicly available.
308+
* The list of summarized messages.
313309
*/
314-
public: z.boolean().optional(),
315-
/**
316-
* How confident you are about this being a correct and useful learning.
317-
*/
318-
confidence: ConversationConfidence.optional(),
310+
summarizedMessageIds: z.array(NonEmptyString).optional(),
319311
});
320312

313+
export type ConversationSummary = z.infer<typeof ConversationSummary>;
314+
export const ConversationSummary = ConversationSummaryBase.merge(
315+
z.object({
316+
/**
317+
* The timestamp summary was updated.
318+
*/
319+
timestamp: NonEmptyTimestamp,
320+
})
321+
);
322+
321323
export type ErrorSchema = z.infer<typeof ErrorSchema>;
322324
export const ErrorSchema = z
323325
.object({
@@ -389,7 +391,7 @@ export const ConversationUpdateProps = z.object({
389391
* LLM API configuration.
390392
*/
391393
apiConfig: ApiConfig.optional(),
392-
summary: ConversationSummary.optional(),
394+
summary: ConversationSummaryBase.optional(),
393395
/**
394396
* Exclude from last conversation storage.
395397
*/

x-pack/platform/packages/shared/kbn-elastic-assistant-common/impl/schemas/conversations/common_attributes.schema.yaml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,25 +306,30 @@ components:
306306
description: Model
307307
example: 'gpt-4'
308308

309-
ConversationSummary:
309+
ConversationSummaryBase:
310310
type: object
311311
properties:
312-
content:
312+
semanticContent:
313313
type: string
314314
description: Summary text of the conversation over time.
315315
example: 'This conversation covered how to configure the Security AI Assistant.'
316-
timestamp:
317-
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyTimestamp'
318-
description: The timestamp summary was updated.
319-
example: '2025-04-30T16:00:00Z'
320-
public:
321-
type: boolean
322-
description: Define if summary is marked as publicly available.
323-
example: true
324-
confidence:
325-
$ref: '#/components/schemas/ConversationConfidence'
326-
description: How confident you are about this being a correct and useful learning.
327-
example: 'high'
316+
summarizedMessageIds:
317+
type: array
318+
description: The list of summarized messages.
319+
items:
320+
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyString'
321+
322+
ConversationSummary:
323+
allOf:
324+
- $ref: '#/components/schemas/ConversationSummaryBase'
325+
- type: object
326+
required:
327+
- timestamp
328+
properties:
329+
timestamp:
330+
$ref: '../common_attributes.schema.yaml#/components/schemas/NonEmptyTimestamp'
331+
description: The timestamp summary was updated.
332+
example: '2025-04-30T16:00:00Z'
328333

329334
ErrorSchema:
330335
type: object
@@ -426,7 +431,7 @@ components:
426431
$ref: '#/components/schemas/ApiConfig'
427432
description: LLM API configuration.
428433
summary:
429-
$ref: '#/components/schemas/ConversationSummary'
434+
$ref: '#/components/schemas/ConversationSummaryBase'
430435
excludeFromLastConversationStorage:
431436
description: Exclude from last conversation storage.
432437
type: boolean

0 commit comments

Comments
 (0)