-
Notifications
You must be signed in to change notification settings - Fork 235
docs(agentic-trust): Analyze AI agents guide #8383
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
Open
afgambin
wants to merge
17
commits into
main
Choose a base branch
from
af-3393-ai-agents-optimize
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.
+237
−59
Open
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2a86e35
docs(agentic-trust): Analyze AI agents guide
afgambin 101dfa0
Add assets: icons for Operate
afgambin 882fa0d
Merge branch 'main' into af-3393-ai-agents-optimize
afgambin aa12f95
Add images to Monitor your AI agents guide
afgambin 8937c80
Add step 1 and step 2
afgambin 72fa586
Add step 3 and step 4
afgambin 112e3af
Tweak prerequisites section
afgambin 774245f
Merge branch 'main' into af-3393-ai-agents-optimize
afgambin 286da22
Add tool usage and dashboard sections
afgambin 3f204a8
Remove Optimize section from Monitor your agents
afgambin 86fa46f
Merge branch 'main' into af-3393-ai-agents-optimize
afgambin ada3cb8
Fix internal link
afgambin 3eb7235
Merge branch 'main' into af-3393-ai-agents-optimize
afgambin 211f922
minor grammar edits
christinaausley 97ef5c7
Address review comments
afgambin 0dd409d
Enable only H2 headings in the right-hand ToC
afgambin 4c8b326
Merge branch 'main' into af-3393-ai-agents-optimize
afgambin 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
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
178 changes: 178 additions & 0 deletions
178
docs/components/agentic-orchestration/analyze-ai-agents.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,178 @@ | ||
| --- | ||
| id: analyze-ai-agents | ||
| title: Analyze your AI agents with Optimize | ||
| sidebar_label: Analyze your AI agents | ||
| description: "Analyze and improve the performance of your AI agent executions using Optimize." | ||
| keywords: ["agentic ai", "AI agents", "Optimize"] | ||
| --- | ||
|
|
||
| import ScriptTask from './img/script-task.png'; | ||
| import Heatmap from './img/heatmap.png'; | ||
| import PieChart from './img/pie-chart.png'; | ||
| import Dashboard from './img/dashboard-optimize.png'; | ||
|
|
||
| Analyze and improve the performance of your AI agent executions using Optimize. | ||
|
|
||
| ## About | ||
|
|
||
| In this guide, you will: | ||
|
|
||
| - Understand what data Optimize can analyze for AI agents. | ||
| - Create reports and heatmaps, including token and tool usage. | ||
| - Build a dashboard to track AI agent behavior over time. | ||
|
|
||
| After completing this guide, you will be able to analyze AI agent executions in Optimize and build dashboards that track usage and performance trends. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - You have access to [Optimize](/components/optimize/what-is-optimize.md). | ||
| - You have deployed and run the [AI Agent Chat Quick Start](https://marketplace.camunda.com/en-US/apps/587865) model blueprint. This is needed for Optimize to fetch execution data to analyze. Consider running it using different prompts to trigger various AI agent tools. | ||
|
|
||
| :::important | ||
| This guide is a follow-up to [Build your first AI agent](../../guides/getting-started-agentic-orchestration.md), where you will use the same example AI agent process. It is recommended going through that guide first. However, it can be applied to other AI agent process implementations. | ||
| ::: | ||
|
|
||
| ## Step 1: Make your data available | ||
|
|
||
| To make data available to Optimize, make sure it's scoped at the process level. If it's scoped to a lower level, for example, within a connector or tool-execution scope, extract it into process variables. | ||
|
|
||
| :::important | ||
| Optimize can only use variable data at the **process level**. | ||
| ::: | ||
|
|
||
| ### Example: Collect token usage | ||
|
|
||
| In the AI Agent Chat Quick Start example, token usage data is not available at the process level, but in a nested scope. To surface those metrics, you can add a script task after the AI agent execution that copies those values into process variables. | ||
|
|
||
| How you extract these values depends on how your AI agent implementation exposes token usage. The important aspect is that the target variables exist at the **process level** when the instance finishes. | ||
|
|
||
| To do so: | ||
|
|
||
| 1. Add a [script task](/components/modeler/bpmn/script-tasks/script-tasks.md). | ||
| 1. Configure its **Properties** as follows: | ||
| - In **General**, **Name**: Gather metrics. | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - In **Implementation**, select **FEEL expression**. | ||
| - In **Script**, | ||
| - **Result variable**: `tokenUsage`. | ||
| - **FEEL expression**: `agent.context.metrics.tokenUsage.inputTokenCount`. | ||
| - In **Output mapping**, add two process variables: | ||
| - `inputTokenUsage` with **Variable assignment value**: `agent.context.metrics.tokenUsage.inputTokenCount`. | ||
| - `outputTokenUsage` with **Variable assignment value**: `agent.context.metrics.tokenUsage.outputTokenCount`. | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
afgambin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| You should see something like the following: | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <img src={ScriptTask} alt="Process instance overview"/> | ||
|
|
||
| ## Step 2: Examine data in Optimize | ||
|
|
||
| By leveraging data collected during process execution, you can use Optimize to examine it through reports and dashboards and identify areas for improvement in your AI agent processes. | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Open Optimize. | ||
| 1. Go to the **Dashboards** tab. | ||
| 1. Select your AI agent process, **AI Agent Chat With Tools**, in the **Process dashboards and KPIs** section. | ||
| 1. Verify that Optimize shows data for your executed process instances in the **Business Operations** section, including your AI agent process model diagram and other statistics below. | ||
| 1. Explore the other metrics shown below in the **Business Reporting** and **Process Improvement** sections. | ||
|
|
||
| See the Optimize [getting started](/components/optimize/improve-processes-with-optimize.md) guide for more details on what you can do with Optimize for business intelligence. | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Step 3: Create reports for token usage | ||
|
|
||
| You can create reports for token usage across process instances and over time. | ||
| To do so: | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Go to the **Collections** tab. | ||
| 1. Select **Report** from the **Create new** dropdown. | ||
| 1. Select **AI Agent Chat With Tools** from the **Select one or more processes** dropdown. You can fetch data for all process model versions or customize it. | ||
| 1. Choose a blank template. | ||
| 1. Enable **Update preview automatically** to make it easier to see the report results as you configure it. | ||
| 1. In the **Report setup** section, select **Variable** in the **View** option, and then select **tokenUsage**. | ||
| 1. Click the pencil icon and select an aggregation that matches your goal. For example: | ||
| - **Sum** to track total tokens across instances. | ||
| - **Average** to track typical usage per process instance. | ||
| 1. Save the report with a descriptive name. For example, **Token usage**. | ||
|
|
||
| :::note | ||
| You can create similar reports, targeting other goals and process variables, such as `inputTokenUsage` or `outputTokenUsage`. | ||
| ::: | ||
|
|
||
| ### Example: Set a target threshold | ||
|
|
||
| If you have a token budget, you can set a target in the report. | ||
|
|
||
| 1. Follow [the previous steps 1 through 6](#step-3-create-reports-for-token-usage). | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. In the **Visualization** settings, click the gear icon, and then enable **Set target** to configure a target value, for example, a maximum token usage threshold. | ||
| 1. Set the target to less than 10,000 tokens. | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. Save the report with a descriptive name. For example, **Token usage with threshold**. | ||
|
|
||
| ## Step 4: Create reports for tool usage | ||
|
|
||
| You can create reports for tool usage across process instances and over time. | ||
|
|
||
| ### Example: Create a heatmap | ||
|
|
||
| Use a heatmap to understand how long your AI agent spends in each task. | ||
|
|
||
| 1. Go to the **Collections** tab. | ||
| 1. Select **Report** from the **Create new** dropdown. | ||
| 1. Select **Flow node** as the **View**. | ||
| 1. Select **Duration** as the **Measure**. | ||
| 1. (Optional) Filter the report by selecting **Flow node selection** in the **Filter flow nodes** dropdown. For example, select only tool tasks within the AI Agent connector. | ||
| 1. In the **Visualization** settings, select **Heatmap**. Then click the gear icon and enable the tooltip to show absolute values. | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. Save the report with a descriptive name. For example, **Tool usage heatmap**. | ||
|
|
||
| <p align="center"> | ||
| <img src={Heatmap} alt="Tool usage heatmap" width="80%"/> | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </p> | ||
afgambin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Example: Create a report for tool call counts | ||
|
|
||
| Create a bar chart to see how many times each tool is called. | ||
|
|
||
| 1. Go to the **Collections** tab. | ||
| 1. Select **Report** from the **Create new** dropdown. | ||
| 1. Select **Flow node** as **View**. | ||
| 1. Select **Count** as the **Measure**. | ||
| 1. (Optional) Filter the report by selecting **Flow node selection** in the **Filter flow nodes** dropdown. For example, select only tool tasks within the AI Agent connector. | ||
| 1. In the **Visualization** settings, select **Bar chart** or **Pie chart**. Then click the gear icon and enable both tooltips to show absolute and relative values. | ||
| 1. Save the report with a descriptive name. For example, **Tool usage**. | ||
|
|
||
| <p align="center"> | ||
| <img src={PieChart} alt="Tool usage pie chart" width="50%"/> | ||
| </p> | ||
|
|
||
| ### Example: Track trends over time | ||
|
|
||
| Use a timeline report to analyze trends over time. | ||
| For example, you can see how many times a tool is called per day over a one-week period. | ||
|
|
||
| 1. Go to the **Collections** tab. | ||
| 1. Select **Report** from the **Create new** dropdown. | ||
| 1. Select **Flow node** as **View**. | ||
| 1. Select **Count** as the **Measure**. | ||
| 1. In **Group by**, select **Start date**. Then choose your preferred interval, for example, **Week**. | ||
| 1. (Optional) Filter the report by selecting **Flow node selection** in the **Filter flow nodes** dropdown. For example, select only tool tasks within the AI Agent connector. | ||
| 1. In the **Visualization** settings, select **Bar chart** or **Line chart**. Then click the gear icon and enable both tooltips to show absolute and relative values. | ||
| 1. Save the report with a descriptive name. For example, **Tool usage over time**. | ||
|
|
||
| ## Step 5: Build a dashboard | ||
|
|
||
| You can create a dashboard, a collection of reports that you can view together, for your AI agent. | ||
| To do so: | ||
|
|
||
| 1. Go to the **Collections** tab. | ||
| 1. Select **Dashboard** from the **Create new** dropdown. | ||
| 1. Click the plus icon to add tiles for the reports you created. | ||
| 1. In the **Optimize report** section, add reports as needed. | ||
| 1. Arrange the tiles to customize your dashboard layout. | ||
| 1. Save the dashboard with a descriptive name. For example, **AI Agent Chat Quick Start dashboard**. | ||
|
|
||
| <p align="center"> | ||
| <img src={Dashboard} alt="Dashboard overview" width="80%"/> | ||
| </p> | ||
|
|
||
| ## Next steps | ||
|
|
||
| Now that you know how to analyze your AI agents, you can: | ||
|
|
||
| - [Monitor your AI agents](/components/agentic-orchestration/monitor-ai-agents.md) with Operate. | ||
| - Learn more about [Camunda agentic orchestration](/components/agentic-orchestration/agentic-orchestration-overview.md) and the [AI Agent connector](/components/connectors/out-of-the-box-connectors/agentic-ai-aiagent.md). | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+99.7 KB
docs/components/agentic-orchestration/img/process-instance-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
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.
Uh oh!
There was an error while loading. Please reload this page.