Expand description
Context analysis — per-tool token breakdown and duplicate detection. Context analysis — per-tool token breakdown and duplicate detection.
Analyzes conversation history to identify where tokens are being spent.
Used by compaction decisions, /usage reporting, and microcompact.
§What it reports
- Per-tool token counts — how many tokens each tool’s results consume (Read, Grep, Bash, etc.)
- Duplicate file reads — files read multiple times (wasted context)
- Human vs assistant split — how much of the context is user messages vs model responses
- Attachment sizes — images and files pasted into the conversation
§How it’s used
- Auto-compact: triggers compaction when total tokens exceed threshold
/usagecommand: shows the token breakdown to the user- Microcompact: identifies old tool results safe to clear
Inspired by Claude Code’s contextAnalysis.ts.
Structs§
- Context
Analysis - Per-tool and per-role token breakdown of a conversation context.
- Duplicate
Read - Info about a duplicated file read in context.
Functions§
- analyze_
context - Analyze conversation history and produce a token breakdown.