diff --git a/explore-analyze/ai-features/agent-builder/agents-and-workflows.md b/explore-analyze/ai-features/agent-builder/agents-and-workflows.md index 7a0db3ed37..9db00c1d2b 100644 --- a/explore-analyze/ai-features/agent-builder/agents-and-workflows.md +++ b/explore-analyze/ai-features/agent-builder/agents-and-workflows.md @@ -1,6 +1,6 @@ --- navigation_title: "Connect agents and workflows" -description: "Learn how to connect Agent Builder agents and Elastic Workflows, including workflow tools, pre-execution workflows, and the `ai.agent` step." +description: "Learn how Agent Builder works with Elastic Workflows, including creating workflows from chat, workflow tools, pre-execution workflows, and the `ai.agent` step." applies_to: stack: preview 9.3+ serverless: preview @@ -14,19 +14,15 @@ products: # Connect {{agent-builder}} agents and Elastic Workflows -Elastic Workflows and {{agent-builder}} allow you to combine deterministic automation with conversational reasoning. By invoking an AI agent directly within a workflow execution, you can treat the agent as a "reasoning engine" that summarizes data, classifies events, or makes decisions before passing the results to the next step in your automation. - -:::{note} -This guide explains how to call an agent from a workflow. If you want to trigger a workflow in an agent conversation, you need to create a custom [workflow tool](./tools/workflow-tools.md). For workflows that run before the agent makes any LLM calls in response to a user message, refer to [Pre-execution workflows](#pre-execution-workflows). -::: +Elastic Workflows and {{agent-builder}} combine deterministic automation with conversational reasoning. You can create workflows conversationally, make workflows available to agents, and invoke agents from workflows. ## Approaches -There are three ways to integrate agents and workflows: +There are three ways to use {{agent-builder}} and workflows together: -* **The `ai.agent` step:** A simplified shorthand step for common operations. Use this when you want to send a prompt to an agent and receive a text response without complex configuration. -* **The `kibana.request` step:** A generic step that provides full access to the {{agent-builder}} APIs. Use this for advanced use cases, such as listing available agents or managing agent sessions programmatically. -* **Pre-execution workflows:** Workflows assigned to an agent that run once after each user message, before the agent makes any LLM calls in response. Use this when you want deterministic setup or validation before the LLM starts. +* **Create workflows from Agent Chat** {applies_to}`stack: ga 9.5+` {applies_to}`serverless: ga`: Describe the automation you want in natural language, refine the generated draft, then open **Preview** and select **Save** to create it. Refer to [Create skills and workflows in chat](chat.md#create-skills-and-workflows-directly-from-chat). +* **Use workflows from agents:** Trigger an existing workflow from a conversation with a [workflow tool](./tools/workflow-tools.md), or assign [pre-execution workflows](#pre-execution-workflows) that run before the agent starts reasoning. +* **Use agents from workflows:** Invoke an agent from a workflow with the [`ai.agent` step](#use-ai-agent-workflow-step). For advanced API operations, use the [`kibana.request` step](#use-kibana-request-workflow-step). ## Prerequisites @@ -36,7 +32,6 @@ Before you begin: * Enable the Workflows feature in **Advanced settings**. * Ensure you have the correct privileges to create and run workflows. * For details, refer to [Set up workflows](/explore-analyze/workflows/get-started/setup.md). -* Create at least one workflow. ## Pre-execution workflows [pre-execution-workflows] diff --git a/explore-analyze/ai-features/agent-builder/chat.md b/explore-analyze/ai-features/agent-builder/chat.md index ea19adecc6..7b47575d14 100644 --- a/explore-analyze/ai-features/agent-builder/chat.md +++ b/explore-analyze/ai-features/agent-builder/chat.md @@ -282,6 +282,51 @@ For example, before creating a dashboard the agent might ask which sample data s :width: 650px ::: +## Create skills and workflows in chat [create-skills-and-workflows-directly-from-chat] + +```{applies_to} +stack: ga 9.5+ +serverless: ga +``` + +In addition to answering questions and analyzing data, agents can help you create reusable skills and Elastic Workflows without leaving the conversation. Describe what you want to build in natural language: + +- **Skills**: For example, "Create a skill that handles production alerts using our incident runbook." +- **Workflows**: For example, "Create a workflow that checks for failed payments every five minutes and sends a Slack notification." + +Creating a resource from chat is a [human-in-the-loop](#human-in-the-loop-prompts) process: + +1. The agent gathers the requirements from your request. If important information is missing or ambiguous, it pauses to ask [clarifying questions](#answer-a-clarifying-question). +2. The agent generates a draft and presents it in the conversation. You can review the configuration and ask for changes in natural language. +3. When the draft is ready, confirm creation from the preview: + - For skills, select **Create skill**. + - For workflows, select **Preview**, review the definition, then select **Save**. If you are replacing an existing workflow, select **Override**. + + The resource is not created until you complete this step. + +When you create a workflow, include details such as its trigger, inputs, data sources, conditions, and connectors. The agent asks for any missing information, generates and validates the workflow YAML, and shows the proposed changes for you to review. You can continue refining the draft in the conversation before you open the preview. + +For example, the following response includes the generated workflow definition and a summary of its trigger and steps. Select **Preview** to review and save the workflow: + +:::{image} images/create-workflow-from-chat.png +:screenshot: +:alt: Agent Chat showing a workflow request, generated YAML diff, workflow summary, and Preview button +:width: 720px +::: + +For example, the following preview shows a skill draft that you can review before selecting **Create skill**: + +:::{image} images/create-skill-from-chat.png +:screenshot: +:alt: Skill draft in Agent Chat showing its description, instructions preview, associated tool references, and a Create skill button +:width: 750px +::: + +You need the same privileges that are required to create the resource in its management UI. For resource-specific fields, limitations, and alternative creation methods, refer to: + +- [Create and manage custom skills](custom-skills.md#create-a-skill-from-chat) +- [Create and manage workflows](/explore-analyze/workflows.md) + ## Customize your agent [customize-your-agent] ```{applies_to} diff --git a/explore-analyze/ai-features/agent-builder/custom-skills.md b/explore-analyze/ai-features/agent-builder/custom-skills.md index 5bde0ed87a..b8a0ab49c5 100644 --- a/explore-analyze/ai-features/agent-builder/custom-skills.md +++ b/explore-analyze/ai-features/agent-builder/custom-skills.md @@ -25,11 +25,19 @@ Create a custom skill when you have domain-specific knowledge or procedures that - **Scope tools to a task**: Bundle specific tools with the instructions that explain how and when to use them, so the agent only has access to relevant tools for the task at hand. - **Keep agent prompts clean**: Move detailed, task-specific instructions out of the system prompt and into a skill that loads only when needed. -## Create a custom skill +## Create a custom skill [create-a-custom-skill] + +You can create a custom skill in three ways: + +- Use the {{agent-builder}} UI. +- Use the {{kib}} REST API. +- Ask an agent to create it from Agent Chat. + +### Create a skill in the UI [create-a-skill-in-the-ui] Follow these steps to create a custom skill and add it to your skill library. Once saved, you need to add the skill to an agent before the agent can use it. -You can create a skill from **Manage components > Skills**, or inline when adding skills to an agent from **Customize > Skills**. +You can create a skill from **Manage components → Skills**, or inline when adding skills to an agent from **Customize → Skills**. :::{tip} For guidance on writing effective descriptions and instructions, refer to [Skill creation guidelines](skill-creation-guidelines.md). @@ -38,7 +46,7 @@ For guidance on writing effective descriptions and instructions, refer to [Skill :::::{stepper} ::::{step} Open the Create skill dialog -Go to **Manage components > Skills**, then select **Create a skill**. +Go to **Manage components → Skills**, then select **Create a skill**. :::{image} images/create-new-skill.png :alt: Create skill dialog showing fields for ID, Name, Description, Instructions, and Associated tools @@ -69,9 +77,9 @@ Select **Save**. The skill is added to your library and becomes available to ass ::::{step} Add the skill to an agent -Custom skills in your library are not available to your agents until you explicitly add them. To add a skill, go to **Customize > Skills** on the agent you want to configure and select **Add skills**. From here you can: +Custom skills in your library are not available to your agents until you explicitly add them. To add a skill, go to **Customize → Skills** on the agent you want to configure and select **Add skills**. From here you can: -- **Import from skill library**: Select an existing skill from **Manage components > Skills**. After importing, make sure the skill is toggled on in the agent's skill list. +- **Import from skill library**: Select an existing skill from **Manage components → Skills**. After importing, make sure the skill is turned on in the agent's skill list. - **Create a skill**: Build a new skill and add it to this agent in one step. The skill is enabled for the agent automatically and also saved to your library. Built-in skill availability depends on your deployment type. Refer to [Built-in skills reference](builtin-skills-reference.md) for details. @@ -88,28 +96,32 @@ For guidance on writing effective instructions, refer to [Skill creation guideli ::::: -## Create a skill from chat +### Create a skill with the API [skills-api] + +Create and manage skills programmatically using the {{kib}} REST API. The API supports all the same fields as the UI, including [`referenced_content`]({{kib-apis}}operation/operation-post-agent-builder-skills#operation-post-agent-builder-skills-body-application-json-referenced_content) for additional named content blocks the agent can read selectively. For request examples, refer to [Skills APIs](kibana-api.md#skills-apis). + +- [List skills]({{kib-apis}}operation/operation-get-agent-builder-skills) `GET /api/agent_builder/skills` +- [Create a skill]({{kib-apis}}operation/operation-post-agent-builder-skills) `POST /api/agent_builder/skills` +- [Get a skill by ID]({{kib-apis}}operation/operation-get-agent-builder-skills-skillid) `GET /api/agent_builder/skills/{skillId}` +- [Update a skill]({{kib-apis}}operation/operation-put-agent-builder-skills-skillid) `PUT /api/agent_builder/skills/{skillId}` +- [Delete a skill]({{kib-apis}}operation/operation-delete-agent-builder-skills-skillid) `DELETE /api/agent_builder/skills/{skillId}` + +### Create a skill from Agent Chat [create-a-skill-from-chat] ```{applies_to} stack: ga 9.5+ serverless: ga ``` -You can create custom skills conversationally by asking an agent to build one directly in the chat interface. Instead of filling in a form, you describe the skill you want and the agent guides you through defining the name, description, instructions, and tools. +Open a conversation with any agent and ask it to create a skill. For example, "Create a skill that handles production alerts using our incident runbook." The agent asks clarifying questions when it needs more information, then presents the generated skill as a draft. -To create a skill from chat, open a conversation with any agent and ask it to create a new skill. For example, you might say "Create a skill that triages production alerts using our incident runbook." The agent walks you through each field, suggests instructions based on your input, and saves the skill to your library when you confirm. +Review the description, instructions, associated tools, and references, and ask the agent to edit anything that needs changing. When the draft is ready, select **Create skill**. The skill is not added to your library until you select **Create skill**. -This approach is useful when you want to iterate quickly or when you find it easier to explain a workflow in natural language than to write structured instructions from scratch. - -## Skills API - -You can also create and manage skills programmatically using the {{kib}} REST API. The API supports all the same fields as the UI, including [`referenced_content`]({{kib-apis}}operation/operation-post-agent-builder-skills#operation-post-agent-builder-skills-body-application-json-referenced_content) for additional named content blocks the agent can read selectively. For request examples, refer to [Skills APIs](kibana-api.md#skills-apis). - -- [List skills]({{kib-apis}}operation/operation-get-agent-builder-skills) `GET /api/agent_builder/skills` -- [Create a skill]({{kib-apis}}operation/operation-post-agent-builder-skills) `POST /api/agent_builder/skills` -- [Get a skill by ID]({{kib-apis}}operation/operation-get-agent-builder-skills-skillid) `GET /api/agent_builder/skills/{skillId}` -- [Update a skill]({{kib-apis}}operation/operation-put-agent-builder-skills-skillid) `PUT /api/agent_builder/skills/{skillId}` -- [Delete a skill]({{kib-apis}}operation/operation-delete-agent-builder-skills-skillid) `DELETE /api/agent_builder/skills/{skillId}` +:::{image} images/create-skill-from-chat.png +:screenshot: +:alt: Skill draft in Agent Chat showing its description, instructions preview, associated tool references, and a Create skill button +:width: 750px +::: ## Related pages diff --git a/explore-analyze/ai-features/agent-builder/glossary.md b/explore-analyze/ai-features/agent-builder/glossary.md index 0b97412364..fe5f44cfd3 100644 --- a/explore-analyze/ai-features/agent-builder/glossary.md +++ b/explore-analyze/ai-features/agent-builder/glossary.md @@ -348,4 +348,4 @@ Workflow tool {applies_to}`stack: preview 9.3+` {applies_to}`serverless: preview $$$workflows$$$ Workflows -: Elastic's native automation engine for declarative, event-driven automation defined in YAML. {{agent-builder}} integrates with workflows in two directions: agents can trigger workflows through workflow tools, and workflows can call agents through the `ai.agent` and `kibana.request` steps. See [](agents-and-workflows.md#approaches). +: Elastic's native automation engine for declarative, event-driven automation defined in YAML. You can use {{agent-builder}} and workflows together in three ways: {applies_to}`stack: ga 9.5+` {applies_to}`serverless: ga` [create workflows from Agent Chat](chat.md#create-skills-and-workflows-directly-from-chat), trigger existing workflows from agents through [workflow tools](tools/workflow-tools.md), and call agents from workflows through the [`ai.agent` and `kibana.request` steps](agents-and-workflows.md#approaches). diff --git a/explore-analyze/ai-features/agent-builder/images/create-skill-from-chat.png b/explore-analyze/ai-features/agent-builder/images/create-skill-from-chat.png new file mode 100644 index 0000000000..5e8b468496 Binary files /dev/null and b/explore-analyze/ai-features/agent-builder/images/create-skill-from-chat.png differ diff --git a/explore-analyze/ai-features/agent-builder/images/create-workflow-from-chat.png b/explore-analyze/ai-features/agent-builder/images/create-workflow-from-chat.png new file mode 100644 index 0000000000..132b49c0cc Binary files /dev/null and b/explore-analyze/ai-features/agent-builder/images/create-workflow-from-chat.png differ diff --git a/explore-analyze/ai-features/agent-builder/tools/builtin-tools-reference.md b/explore-analyze/ai-features/agent-builder/tools/builtin-tools-reference.md index defa2006ea..d3ffe5e0f8 100644 --- a/explore-analyze/ai-features/agent-builder/tools/builtin-tools-reference.md +++ b/explore-analyze/ai-features/agent-builder/tools/builtin-tools-reference.md @@ -81,8 +81,8 @@ These platform core tools let agents run and track [Elastic Workflows](/explore- `platform.core.resume_workflow_execution` {applies_to}`stack: ga 9.4+` : Resumes an [Elastic Workflows](/explore-analyze/workflows.md) execution that is paused at a [`waitForInput`](/explore-analyze/workflows/authoring-techniques/human-in-the-loop.md) step, providing the reviewer's input to the workflow so it can continue. -`platform.core.generate_workflow` {applies_to}`stack: preview 9.5` -: Generates or updates an [Elastic Workflows](/explore-analyze/workflows.md) definition from a natural language description, delegating to a specialized workflow-authoring agent that knows workflow syntax, step types, and available connectors. +`platform.core.generate_workflow` {applies_to}`stack: ga 9.5+` {applies_to}`serverless: ga` +: Generates or updates an [Elastic Workflows](/explore-analyze/workflows.md) definition from a natural language description, delegating to a specialized workflow-authoring agent that knows workflow syntax, step types, and available connectors. This tool powers [workflow creation from Agent Chat](../chat.md#create-skills-and-workflows-directly-from-chat). `platform.core.execute_workflow` {applies_to}`stack: preview 9.5` : Executes an [Elastic Workflows](/explore-analyze/workflows.md) definition, given a saved workflow ID, inline YAML for an ephemeral run, or a workflow YAML attachment. diff --git a/explore-analyze/ai-features/agent-builder/tools/workflow-tools.md b/explore-analyze/ai-features/agent-builder/tools/workflow-tools.md index f794c91549..ec00244181 100644 --- a/explore-analyze/ai-features/agent-builder/tools/workflow-tools.md +++ b/explore-analyze/ai-features/agent-builder/tools/workflow-tools.md @@ -17,7 +17,7 @@ products: Workflow tools enable agents to trigger [Elastic Workflows](/explore-analyze/workflows.md) directly from a conversation and use their output. This is ideal for offloading tasks from the LLM that require a deterministic, repeatable sequence of actions. :::{note} -This page explains how to trigger a workflow in an agent conversation. If you want to use an agent within a workflow step, refer to [Call agents from workflows](../agents-and-workflows.md). +This page explains how to trigger an existing workflow in an agent conversation. To create a new workflow from Agent Chat, refer to [Create skills and workflows in chat](../chat.md#create-skills-and-workflows-directly-from-chat). If you want to use an agent within a workflow step, refer to [Call agents from workflows](../agents-and-workflows.md). ::: ## Prerequisites