Skip to content

Security attachments in Agent Builder#243574

Merged
stephmilovic merged 118 commits intoelastic:mainfrom
stephmilovic:security_alert_attachment_with_tool
Dec 4, 2025
Merged

Security attachments in Agent Builder#243574
stephmilovic merged 118 commits intoelastic:mainfrom
stephmilovic:security_alert_attachment_with_tool

Conversation

@stephmilovic
Copy link
Copy Markdown
Contributor

@stephmilovic stephmilovic commented Nov 19, 2025

Summary

Adds one platform tool, three security attachment types, and three security tools to the Agent Builder in order to implement existing "Ask in Assistant" workflows within Agent Builder.

Platform additions are always available; security additions are gated behind the xpack.securitySolution.enableExperimental:["agentBuilderEnabled"] experimental feature flag (default: false).

Platform-Level Additions

New Platform Tool: Cases Tool (platform.core.cases)

Location: x-pack/platform/plugins/shared/onechat/server/services/tools/builtin/definitions/cases/

Retrieves and searches cases across Elastic Security, Observability, and Stack Management. Supports:

  • Get case by ID
  • Find cases by alert IDs (with deduplication)
  • Search with filters (severity, status, tags, assignees, reporters, category, owner, date range)
  • Optional comment inclusion with summaries
  • Multi-page fetching (up to 10 pages)
  • Enhanced responses with markdown links and URLs

Note: Always registered; not conditional on any feature flag.

Security Solution Additions

Feature Flag: All security additions are gated behind the agentBuilderEnabled experimental feature flag (xpack.securitySolution.experimentalFeatures.agentBuilderEnabled), which defaults to false. When disabled, security attachments and tools are not registered, and UI components fall back to legacy AI Assistant functionality.

New Security Attachment Types

  1. Alert Attachment (security.alert) — Attaches security alert data (or attack discovery) with workflow to gather risk scores, attack discoveries, cases, Security Labs, and ES|QL queries.
  2. Entity Attachment (security.entity) — Attaches entity risk info (host/user/service/generic) with workflow to query risk scores.
  3. Rule Attachment (security.rule) — Attaches rule or rule query with workflow to generate working queries or find documentation.

New Security Tools

  1. Entity Risk Score Tool (security.entity_risk_score) — Gets latest entity risk scores and contributing inputs with normalized scores (0-100) and enhanced alert data.
  2. Attack Discovery Search Tool (security.attack_discovery_search) — Searches attack discoveries by alert IDs using ES|QL, filters last 7 days, returns up to 100 results.
  3. Security Labs Search Tool (security.security_labs_search) — Searches Security Labs knowledge base with natural language queries, filters to Security Labs content, limits to 3 results.

Additional Changes

  • Added NewAgentBuilderAttachment component and useAgentBuilderAttachment hook
  • Integrated attachment buttons in Security Solution UI (alert flyouts, attack discovery panels, entity analytics, rule creation) with feature flag checks
  • Registered security attachments and tools conditionally based on agentBuilderEnabled flag
  • Added constants: SecurityAgentBuilderAttachments enum, securityTool helper, cases to platformCoreTools, product_reference to AttachmentType enum

Open in Agent Builder flyout

The useAgentBuilderAttachment hook returns a function that will open the Agent Builder flyout.

  • Open a flyout/modal with the Agent Builder UI
  • Pre-populate with attachment data and invoke the conversation
  • Allow interaction in the flyout without navigation
Screenshot 2025-11-29 at 10 21 57 AM

TODO: Fix cases where the flyout was opened from another flyout, the zIndex is not high enough on AB flyout

Screenshots of NewAgentBuilderAttachment additions

NOTE: These screenshots below have an outdated Agent button icon, I've updated to use the robot icon. The buttons now have the proper icon:

Screenshot 2025-12-03 at 2 20 49 PM alerts attack-discovery-1 attack-discovery-2 attack-discovery-3 entity-1 entity-2 rules-1 rules-2 rules-3 ease

@botelastic botelastic Bot added ci:project-deploy-observability Create an Observability project Team:Fleet Team label for Observability Data Collection Fleet team Team:obs-ai Observability AI team Team:obs-presentation Focus: APM UI, Infra UI, Hosts UI, Universal Profiling, Obs Overview and left Navigation labels Dec 3, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-presentation-team (Team:obs-presentation)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ai-team (Team:obs-ai)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 3, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@stephmilovic stephmilovic force-pushed the security_alert_attachment_with_tool branch from 7f9c9b3 to 3babba1 Compare December 3, 2025 23:05
@stephmilovic stephmilovic removed request for a team December 3, 2025 23:06
Copy link
Copy Markdown
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple comments just as fyi, none are blockers!

'rule.reference',

/* Kibana alert fields */
'kibana.alert.uuid',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea, but we could retrieve some of these from here which is a platform share package?

Comment on lines +53 to +64
const isAgentBuilderEnabled = useIsExperimentalFeatureEnabled('agentBuilderEnabled');

const alertData = useMemo(() => {
const rawData = getRawData(dataFormattedForFieldBrowser ?? []);
return stringifyEssentialAlertData(rawData);
}, [dataFormattedForFieldBrowser]);

const { openAgentBuilderFlyout } = useAgentBuilderAttachment({
attachmentType: SecurityAgentBuilderAttachments.alert,
attachmentData: { alert: alertData },
attachmentPrompt: isAlert ? ALERT_ATTACHMENT_PROMPT : EVENT_ATTACHMENT_PROMPT,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, this piece of code is duplicated between here and the ease flyout. What do you think about moving this into a hook that would be shared between the 2 flyouts?

I'm bringing this up because we will also need this code again in the new attacks flyout (see the footer here). At this time we do not have the Ask AI assistant button there, but it's coming very soon (cc @agusruidiazgd)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have different prompt arguments. I think its fine to call useAgentBuilderAttachment directly, but if you want to create a hook when the time comes feel free

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Dec 4, 2025

💛 Build succeeded, but was flaky

  • Buildkite Build
  • Commit: 3372463
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-243574-33724639eec3

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 8455 8460 +5

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
onechat 8 10 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
onechat 474.8KB 472.3KB -2.5KB
securitySolution 11.1MB 11.1MB +9.7KB
total +7.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
onechat 22.4KB 25.3KB +2.9KB
securitySolution 166.8KB 169.6KB +2.8KB
total +5.7KB
Unknown metric groups

API count

id before after diff
onechat 24 26 +2
securitySolution 203 204 +1
total +3

ESLint disabled line counts

id before after diff
securitySolution 698 699 +1

Total ESLint disabled count

id before after diff
securitySolution 806 807 +1

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:project-deploy-observability Create an Observability project release_note:enhancement Team:Fleet Team label for Observability Data Collection Fleet team Team:obs-ai Observability AI team Team:obs-presentation Focus: APM UI, Infra UI, Hosts UI, Universal Profiling, Obs Overview and left Navigation Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.