agentic-optimization
Skill5 starsChanged 5 months agoMITView on GitHub
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.
In this repository9 other files it gives its agents.
- deep-analysisSkill
- download-profile-traceSkill
- download-snapshotSkill
- enable-profilerSkill
- enable-snapshot-debuggerSkill
- error-explorationSkill
- get-profile-hotpathSkill
- get-snapshot-debug-infoSkill
- perf-optimizationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 11 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Follow the Standard Skill Preamble to check for existing investigation context and gather inputs.
- Distinctive: line 34
If none of the above are available, follow Identify Application Insights Resource to locate the resource.
- Distinctive: line 40
Time range: Start and end times for the analysis window (ISO 8601 UTC).
- Very specific: line 44
If investigation-notes.md does not already exist in the working directory, create it now with the resource context gathered in steps 1–2.
- Very specific: line 46
Write the following fields to investigation-notes.md using the format defined in investigation-notes.md:
- Distinctive: line 53
If the file already exists, verify the resource context matches and update if needed.
- Very specific: line 57
Run the script in run-analyze.md to execute the aira.exe analyze command.
- Very specific: line 91
If the anomaly operations table has entries, write the key findings to investigation-notes.md before handing off:
- Distinctive: line 93
Add a "Key Findings" section with:
- Distinctive: line 98
Add an "Anomaly Operations" section with the top anomaly operation IDs, durations, and severity scores
- Very specific: line 103
Response context: Run aira.exe response-context --response-id <responseId> to see the full agent conversation flow for that operation.
- Very specific: line 104
Compare agent versions: If the issue correlates with a specific agent version, suggest aira.exe compare-versions.
- Distinctive: line 106
If the anomaly operations table is empty (no spikes detected), suggest:
- Very specific: line 119
Cross-reference with profiler data: If latency issues are found in downstream services, suggest using the perf-optimization skill to …
- Distinctive: line 123
Always confirm the Application Insights resource with the user before running the analysis.
- Distinctive: line 124
Start with a default analysis (no filters, last 24 hours, limit 1000) to get a broad overview, then narrow down based on findings.
- Distinctive: line 128
When comparing agent performance across versions, note the agent name from the results and suggest the user run a follow-up comparison.
- Distinctive: line 129
If the CLI returns exit code 1 with "No telemetry records found", check the error message — it now provides actionable guidance on what to …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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:
- Investigation Notes
For finding the Application Insights resource, see:
- Identify Application Insights Resource
For the full CLI specification (all available commands), see:
- CLI Specification
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

