agentic-optimization
Analyze AI agent telemetry from Application Insights, including anomaly detection, trend analysis, and performance statistics. Use this when asked to analyze AI agent performance, detect anomalies in agent telemetry, or review agent trace data.
- License 许可
- MIT
- 最近更新
- 2026-06-18
- Stars
- ★ 5
- Forks
- 4
01 前言 Front Matter
- name
- agentic-optimization
- category
- exploring
- description
- Analyze AI agent telemetry from Application Insights, including anomaly detection, trend analysis, and performance statistics. Use this when asked to analyze AI agent performance, detect anomalies in agent telemetry, or review agent trace data.
02 资源文件 3
- 参考文档references/cli-spec-summary.md2.3 KB
- 脚本scripts/aira.exe34.9 MB
- 脚本scripts/run-analyze.md9.2 KB
03 SKILL.md 正文
Agentic Optimization
This skill analyzes AI agent telemetry traces from Application Insights using the aira.exe CLI tool. It performs anomaly detection, trend analysis, and generates performance statistics to help identify issues in AI agent behavior.
Prerequisites
- The user must be logged in to Azure CLI (
az login) - The user must provide Application Insights resource details: Subscription ID, Resource Group, and Component Name
Steps
1–2. Check investigation notes and gather inputs
Follow the Standard Skill Preamble to check for existing investigation context and gather inputs.
In addition to the standard App ID, this skill requires the following Application Insights identity fields:
- Subscription ID: Azure subscription GUID
- Resource Group: Resource group containing the Application Insights resource
- Component Name: The Application Insights component name (resource name)
These are typically available in investigation-notes.md. If only a Resource ID is available, parse the subscription ID, resource group, and component name from the ARM resource ID format:
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/microsoft.insights/components/{componentName}
If none of the above are available, follow Identify Application Insights Resource to locate the resource.
Optional inputs — ask the user if they want to narrow the analysis:
- Agent name: Filter by a specific agent name
- Agent version: Filter by a specific agent version
- Limit: Maximum number of records to analyze (1–50,000). Defaults to 1000 — suitable for initial exploration; increase for thorough analysis.
- Time range: Start and end times for the analysis window (ISO 8601 UTC). Defaults to the last 24 hours. Widen if the user wants historical analysis.
2b. Create or update investigation notes
If investigation-notes.md does not already exist in the working directory, create it now with the resource context gathered in steps 1–2. This ensures downstream skills (especially deep-analysis) can pick up the context without re-asking the user.
Write the following fields to investigation-notes.md using the format defined in investigation-notes.md:
- Subscription ID
- Resource Group
- Component Name
- Resource ID (constructed from the above:
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/microsoft.insights/components/{componentName})
If the file already exists, verify the resource context matches and update if needed.
3. Run the analyze command and present results
Run the script in run-analyze.md to execute the aira.exe analyze command. The script acquires a fresh access token, invokes the CLI with JSON output, and post-processes the results into a readable summary with operation IDs extracted — all in a single run.
Access token: This skill uses the Application Insights data-plane token (
https://api.applicationinsights.io), which is different from the profiler dataplane token used by other skills. The script handles token acquisition automatically.
Execution time: The analysis may take a while depending on the volume of telemetry data. Inform the user that this may take some time, especially with large
--limitvalues or wide time ranges.
The script output contains everything needed to present results and offer deep-dive. Present it to the user with the following interpretation:
-
Lead with the summary header — State total records, agent count, and time range.
-
Highlight per-agent performance — Call out:
- Agents with P95 > 5,000ms as high-latency
- Large gaps between mean and P95 (indicates inconsistent performance / tail latency)
- Low token counts with high latency (latency is likely in tool calls, not LLM)
-
Explain the operation breakdown — The script shows per-operation-type stats:
invoke_agent— overall agent invocation (parent span)chat— LLM model calls (check latency and token counts)execute_tool— tool/API calls (often the bottleneck; checkbyToolbreakdown)
-
Interpret trends — Notable trends (confidence ≥ 0.5) are shown. Explain:
- Duration increasing → potential regression or growing prompt size
- Token usage increasing → context window growth, possible cost concern
- Duration decreasing → improvement or reduced workload
-
Present anomaly operations for deep-dive — The script extracts operation IDs from anomaly spikes and displays them in a numbered table. Present this table directly and ask the user which operation they'd like to deep-dive into. Each row includes:
- Operation ID (needed for
deep-analysisskill handoff) - Duration and severity
- Span types and model for context
- Operation ID (needed for
Raw JSON: The script saves the full JSON to
aira-output.jsonin the working directory. Let the user know they can inspect this file for the complete data.
4. Deep-dive handoff
If the anomaly operations table has entries, write the key findings to investigation-notes.md before handing off:
-
Add a "Key Findings" section with:
- Agent name, time window, and summary statistics (mean, P95, max latency)
- The bottleneck layer (LLM vs tool calls) and which tools are slowest
- Trend direction if notable
-
Add an "Anomaly Operations" section with the top anomaly operation IDs, durations, and severity scores
Then ask the user which operation to investigate further:
- Cross-resource deep analysis (recommended): Hand off the selected operation ID to the
deep-analysisskill to trace the operation across downstream services (tools, APIs, databases) and see where time was spent. The operation ID and resource context will be available ininvestigation-notes.md. - Response context: Run
aira.exe response-context --response-id <responseId>to see the full agent conversation flow for that operation. Important: use theresponseIdfield (not theoperationId) as the--response-idargument — these are different identifiers. The anomaly table output includes both. - Compare agent versions: If the issue correlates with a specific agent version, suggest
aira.exe compare-versions.
If the anomaly operations table is empty (no spikes detected), suggest:
- Widen the time range to capture more data and potential anomalies
- Increase the limit for more thorough analysis
- Re-run with a specific agent name to focus the analysis
- Check the raw JSON (
aira-output.json) for lower-severity anomalies that didn't meet the threshold
5. Additional follow-up options
Beyond the deep-dive, offer these follow-up options based on findings:
- Narrow the analysis: Re-run with
--agent-nameand/or--agent-versionfilters to focus on a specific agent - Adjust the time window: Narrow or widen the analysis period to isolate issues
- Cross-reference with profiler data: If latency issues are found in downstream services, suggest using the
perf-optimizationskill to correlate with profiler traces
Tips
- Always confirm the Application Insights resource with the user before running the analysis.
- Start with a default analysis (no filters, last 24 hours, limit 1000) to get a broad overview, then narrow down based on findings.
- The script defaults to JSON output (
-o json) with post-processing that extracts a readable summary and operation IDs in one pass. The raw JSON is saved toaira-output.jsonfor user inspection. - The
--limitparameter caps the number of telemetry records analyzed. The CLI defaults to 1000. For thorough analysis, increase up to 50,000. - The script defaults to a 24-hour time window. Widen it for historical analysis; narrow it to isolate recent incidents.
- When comparing agent performance across versions, note the agent name from the results and suggest the user run a follow-up comparison.
- If the CLI returns exit code 1 with "No telemetry records found", check the error message — it now provides actionable guidance on what to try next.
- The goal is to reach "ready for deep-dive" in a single run — present summary + operation IDs together so the user can pick one immediately.
References
For the investigation notes format and read/write protocol, see:
For finding the Application Insights resource, see:
For the full CLI specification (all available commands), see:
04 同仓库更多 Skills
perf-optimization
Guide for analyzing performance issues based on profiler and code optimizations, including CPU, latency, and throughput. Use this when asked to investigate performance bottlenecks or optimize application performance.
get-snapshot-debug-info
Fetch exception details, call stack, and variable values from an Application Insights Snapshot Debugger snapshot. Use this when asked to inspect a snapshot, view exception info, debug an exception, or see variable values from a crash.
get-profile-hotpath
Fetch and display the hot path from an Application Insights Profiler trace. Use this when asked to get the profiler hot path, call tree, or trace analysis for an App Insights resource.
error-exploration
Explore errors in Application Insights — exceptions, failed requests, and failed dependencies. Use this when asked to find errors, investigate failures, identify reliability issues, or recommend which errors to fix.
enable-snapshot-debugger
Guide users through enabling the Application Insights Snapshot Debugger for .NET on their platform. Use this when asked to enable the snapshot debugger, set up snapshot collection, or when snapshot data is missing.
enable-profiler
Guide users through enabling the Application Insights Profiler for .NET on their platform. Use this when asked to enable the profiler, set up profiling, or when profiler data is missing.