-
Notifications
You must be signed in to change notification settings - Fork 197
Create Workflows guide for Agent Builder #4717
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
Draft
charlotte-hoblik
wants to merge
21
commits into
main
Choose a base branch
from
charlotte-AB-workflows-643
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−0
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
548cb39
Add workflows page
charlotte-hoblik aa09236
AI steps
charlotte-hoblik 705cdcc
create a tool with using workflows
charlotte-hoblik 755a662
add steps and examples
charlotte-hoblik 005154f
Update example
charlotte-hoblik fa296ad
apply guidelines
charlotte-hoblik 7f401cc
fix example
charlotte-hoblik 7f93e1d
Merge branch 'main' into charlotte-AB-workflows-643
charlotte-hoblik c7c527f
update applies_to
charlotte-hoblik c65441a
fix suggestions
charlotte-hoblik 9635c43
update link to workflows page
charlotte-hoblik be87dad
Update explore-analyze/ai-features/agent-builder/workflows.md
charlotte-hoblik f92b085
Update explore-analyze/ai-features/agent-builder/workflows.md
charlotte-hoblik 7c3ecf7
update example
charlotte-hoblik 7a55deb
update admin prerequisites
charlotte-hoblik 6cc8156
comment out failing links
charlotte-hoblik 1c2252b
replace intro
charlotte-hoblik 69cbec6
resolve screenshot issues
charlotte-hoblik 6d21789
move workflows.md under tools
charlotte-hoblik 5b0700f
fix links
charlotte-hoblik 52b6578
rename page
charlotte-hoblik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+143 KB
explore-analyze/ai-features/agent-builder/images/agent-builder-workflow-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+264 KB
explore-analyze/ai-features/agent-builder/images/create-new-tool-workflows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 136 additions & 0 deletions
136
explore-analyze/ai-features/agent-builder/tools/workflows.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| --- | ||
| navigation_title: "Workflow tools" | ||
| description: "Learn how to trigger Elastic Workflows from Elastic Agent Builder and invoke your agents within workflow steps." | ||
| applies_to: | ||
| stack: preview 9.3+ | ||
| serverless: preview | ||
| products: | ||
| - id: elasticsearch | ||
| - id: kibana | ||
| - id: observability | ||
| - id: security | ||
| - id: cloud-serverless | ||
| --- | ||
|
|
||
| # Workflow tools | ||
|
|
||
| Workflows and {{agent-builder}} are built to work together: | ||
| % (/explore-analyze/workflows.md) | ||
|
|
||
| * Assign agents workflow tools to trigger workflows from your chats. | ||
| * Add `ai.agent` steps to invoke agents in your workflows. | ||
|
|
||
| Agents chat with your data by retrieving, summarizing, and reasoning. Workflows execute reliably with business-grade guardrails. Together, they combine flexible reasoning with deterministic execution. | ||
|
|
||
| ## Before you begin | ||
|
|
||
| Before using these features, ensure that: | ||
|
|
||
| * **Workflows are set up:** The feature must be enabled and you need specific privileges to create and run workflows. For details, see Set up workflows | ||
| % (/explore-analyze/workflows/setup.md). | ||
| * (Optional) If using the example below, ensure the [{{kib}} sample flight data](https://www.elastic.co/docs/extend/kibana/sample-data) is installed. | ||
|
|
||
| ## Trigger a workflow from an agent | ||
| Follow these steps to wrap an existing workflow into a tool that your agent can call. This is ideal for tasks that require a strict, repeatable sequence of actions. | ||
|
|
||
| :::{image} ../images/create-new-tool-workflows.png | ||
| :screenshot: | ||
| :width: 900px | ||
| :alt: Screenshot of creating a new workflow tool. | ||
| ::: | ||
|
|
||
| ### Create a workflow tool | ||
| 1. Navigate to **Agents > More > View all tools > New tool**. | ||
| 2. Select **Workflow** as the tool type. | ||
| 3. Select the specific workflow you want to wrap from the drop down list. | ||
|
|
||
| :::{note} | ||
| The UI will automatically detect the `inputs` defined in your workflow YAML and map them to tool parameters. | ||
| ::: | ||
|
|
||
| 4. Fill in the required fields: | ||
| * **Tool ID**: Create a unique identifier for the tool. | ||
| * **Description**: Ensure the description clearly explains *when* the agent should use this tool. | ||
| 5. Click **Save**. | ||
|
|
||
| ### Invoke the tool in chat | ||
| Once you assign this tool to an agent, the agent can trigger the workflow autonomously. | ||
|
|
||
| 1. Navigate to **Agents**, select your agent, and click **Add tool** to assign the workflow tool you just created. | ||
| 2. Open the **Agent chat** and ask a question that triggers the workflow. | ||
| 3. The agent extracts the necessary parameters from the conversation, runs the workflow, and returns the workflow's final output to the chat. | ||
|
|
||
| :::{image} ../images/agent-builder-workflow-tool.png | ||
| :screenshot: | ||
| :width: 500px | ||
| :alt: Screenshot of reasoning steps of agent builder. | ||
| ::: | ||
|
|
||
| ## Call an agent from a workflow | ||
| Follow these steps to invoke an AI agent as a step within a workflow. This allows you to use the agent's reasoning capabilities to process data and return a summary. | ||
|
|
||
| 1. Open the **Workflows** editor and create or edit a workflow. | ||
| 2. Add a new step with the type `ai.agent`. | ||
| 3. Configure the step with the following parameters: | ||
| * **`agent_id`**: The ID of the agent to call. | ||
| * **`message`**: The prompt to send to the agent. | ||
|
|
||
| #### Example: Analyze flight delays | ||
| The following example demonstrates a workflow that searches for flight delays and uses the **Elastic AI Agent** to summarize the impact. | ||
charlotte-hoblik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```yaml | ||
| version: "1" | ||
| name: analyze_flight_delays | ||
| description: Fetches delayed flights and uses an agent to summarize the impact. | ||
| enabled: true | ||
| triggers: | ||
| - type: manual | ||
| steps: | ||
| # Step 1: Get data from Elasticsearch | ||
| - name: get_delayed_flights | ||
| type: elasticsearch.search | ||
| with: | ||
| index: "kibana_sample_data_flights" | ||
| query: | ||
| range: | ||
| FlightDelayMin: | ||
| gt: 60 | ||
| size: 5 | ||
|
|
||
| # Step 2: Ask the agent to reason over the data | ||
| - name: summarize_delays | ||
| type: ai.agent | ||
| with: | ||
| agent_id: "elastic-ai-agent" <1> | ||
| message: | <2> | ||
| Review the following flight delay records and summarize which airlines are most affected and the average delay time: | ||
| {{ steps.get_delayed_flights.output }} | ||
|
|
||
| # Step 3: Print the agent's summary | ||
| - name: print_summary | ||
| type: console | ||
| with: | ||
| message: "{{ steps.summarize_delays.output }}" | ||
| ``` | ||
| 1. **agent_id**: The ID of the agent you want to call (must exist in Agent Builder). | ||
| 2. **message**: The prompt sent to the agent. You can use template variables (like `{{ steps.step_name.output }}`) to inject data dynamically. | ||
|
|
||
| ### Call Agent Builder APIs | ||
charlotte-hoblik marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If ai.agent step works we might not need this section. Let's check with product folks on Monday to confirm. |
||
| For advanced use cases, workflows can interact with {{agent-builder}} programmatically using the generic `kibana.request` step. This allows you to perform management actions that aren't covered by the `ai.agent` step, such as listing available agents. | ||
|
|
||
| ```yaml | ||
| name: list_agents | ||
| enabled: true | ||
| triggers: | ||
| - type: manual | ||
| steps: | ||
| - name: list_agents | ||
| type: kibana.request | ||
| with: | ||
| method: GET | ||
| path: /api/agent_builder/agents | ||
| ``` | ||
|
|
||
| ## Related pages | ||
| * [Tools overview](../tools.md) | ||
| % * [Workflows](/explore-analyze/workflows.md) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This might need to be a standalone page under Tools