원클릭으로
agentpprof-flamegraph
Generate semantic flamegraphs from local AI agent sessions using agentpprof with iterative tag rule development.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Generate semantic flamegraphs from local AI agent sessions using agentpprof with iterative tag rule development.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | agentpprof-flamegraph |
| description | Generate semantic flamegraphs from local AI agent sessions using agentpprof with iterative tag rule development. |
| when_to_use | Use when the user asks to profile agent sessions, visualize token usage, create flamegraphs, see where token budget went, or analyze agent behavior patterns. |
| argument-hint | [project-path] |
Generate meaningful flamegraphs from local Codex/Claude Code sessions by iteratively developing tag rules that achieve high prompt coverage.
Run agentpprof without rules to see diagnostics:
agentpprof \
--project-root /path/to/project \
--view tokens \
-o initial.json \
--format json \
--include-previews
The output includes:
tagging.total_prompts: total prompts foundtagging.unmatched_prompts: prompts without tagstagging.unmatched_samples: sample unmatched prompts (up to 20)tagging.hint: suggested next stepLook at unmatched_samples to identify patterns:
Add --tag-rule arguments iteratively:
agentpprof \
--project-root /path/to/project \
--tag-rule 'prompt:review=(?i)review|审核|check' \
--tag-rule 'prompt:debug=(?i)fix|bug|error|broken' \
--tag-rule 'prompt:git=(?i)commit|push|pull|git' \
--view tokens \
-o iter1.folded
Rule syntax: KIND:TAG=REGEX
prompt, session, llm, or all(?i)Avoid vague tags like task, work, misc, thing, stuff, other — they don't convey semantic meaning and won't aggregate well. Use specific tags like debug, review, paper, naming that describe the activity.
Never use catch-all rules like prompt:misc=. or llm:other=. — they defeat the purpose of semantic tagging by lumping everything together. If you can't classify an item, leave it unmatched and add more specific rules.
Never use placeholder tags like llm:placeholder, llm:response, prompt:other — they indicate that the tagging rules are incomplete. If you see placeholder tags dominating the distribution, investigate why the content isn't being classified properly. Common causes:
"claude response" preview means the actual response content wasn't extracted)Each run shows diagnostics and warnings:
Warning: 150/1000 prompts unmatched. Add prompt tag rules.
Check detailed coverage:
agentpprof --project-root . -o out.json --format json 2>&1 | jq '.tagging'
Definition of "well-tagged":
< 5% unmatched
prompts.unmatched / prompts.total < 5%sessions.unmatched / sessions.total < 5%llm_calls.unmatched / llm_calls.total < 5%Distribution quality metrics:
The tool prints detailed distribution analysis:
Distribution (12 prompt tags, 2620 total): top1=35.5%, top3=58.2%, top5=72.1%, entropy=0.78
Top tags:
1. prompt:review = 931 (35.5%)
2. prompt:query = 228 (8.7%)
3. prompt:discuss = 173 (6.6%)
4. prompt:edit = 156 (6.0%)
5. prompt:code = 194 (7.4%)
Warnings are shown if metrics are poor:
Warning: prompt:misc dominates (55.2%). Target: top1 < 40%. Split into sub-categories.
Warning: low entropy (0.45). Distribution is uneven. Target: entropy > 0.7.
Spot-check unmatched samples:
jq '.tagging.unmatched_samples | map(select(.kind == "prompt")) | .[0:10]' out.json
If unmatched prompts share patterns, add rules. Continue iterating until ALL categories have < 5% unmatched. Avoid vague catch-all tags like misc — use specific semantic tags that describe the activity.
for view in tokens files network; do
agentpprof \
--project-root /path/to/project \
"${TAG_RULES[@]}" \
--view "$view" \
--svg-width 1200 \
-o "project-${view}.svg"
done
SVG width: Use --svg-width to adjust flamegraph width (default: 1200px). Narrower widths (800-1000) improve readability for deep flamegraphs; wider (1600-2000) for shallow ones with many tags.
| View | Width means | Use for |
|---|---|---|
tokens | Token count | Where did model budget go? |
files | File effect count | Which paths were touched? |
network | Network effect count | Which domains were contacted? |
# Paper writing
--tag-rule 'prompt:paper=(?i)paper|arxiv|latex|abstract|intro|section'
# Code review
--tag-rule 'prompt:review=(?i)review|审核|check|diff|pr'
# Git operations
--tag-rule 'prompt:git=(?i)commit|push|pull|git|merge|rebase'
# Debugging
--tag-rule 'prompt:debug=(?i)fix|bug|error|broken|为啥|failed'
# Testing
--tag-rule 'prompt:test=(?i)test|cargo test|pytest|verify'
# Formatting/style
--tag-rule 'prompt:format=(?i)格式|style|format|font|图'
# Confirmations (short responses)
--tag-rule 'prompt:confirm=(?i)^嗯$|^是$|^好$|^ok$'
# Context continuations
--tag-rule 'prompt:context=(?i)session is being continued'
# Subagent delegations
--tag-rule 'prompt:delegate=(?i)subagent|task-notification'
For repeatable analysis, use --session-file instead of --project-root:
agentpprof \
--session-file ~/.claude/projects/.../session1.jsonl \
--session-file ~/.claude/projects/.../session2.jsonl \
--project-name my-project \
"${TAG_RULES[@]}" \
--view tokens \
-o output.svg
From tokens view: Which activities consumed the most LLM budget, cache effectiveness, unexpectedly expensive sessions.
From time view: Wall-clock time distribution, longest prompts, workflow bottlenecks.
From files view: Codebase access patterns, security audit for unexpected file access.
From network view: External service contacts, process chains, security audit for domain access.
--preset enables built-in keyword rules for quick testing, but they are generic and unlikely to match your project well--tag-rule or --preset, all prompts are marked unmatchedSee docs/flamegraph-example/agentsight.sh for a complete example with AgentSight's own development traces.
Analyze agent transcripts and traces to recommend collaboration improvements and generate decision-oriented HTML reports.
Analyze AgentSight system evidence to recommend operational improvements for agent runs.