Agent Memory & Context Analytics¶
Chakshu implements a 3-tier Agent Memory Observability subsystem (internal/memory) to help engineers understand context window saturation, persistent rule overhead ("token tax"), context bloat hotspots, and live OS process memory usage.
The 3 Memory Tiers¶
Tier 1: Working Context Window (internal/memory/context.go)¶
Tracks how a session's working context window grows turn by turn against the active model's capacity limit (GetModelContextLimit supports Claude, Gemini, GPT/Codex models, and defaults cleanly):
- Saturation Gauge & Status:
optimal:< 50%context utilizationelevated:50% – 75%context utilizationcritical:> 75%context utilization ("Context Fatigue")- Turns to Exhaustion: Moving-average forecast estimating how many turns remain before reaching 100% of the model's context window.
- Compaction / Truncation Detection: Counts events where context size drops sharply between turns, indicating automatic context compaction or history truncation.
- Context Composition Breakdown: Attributes tokens across:
- Tool Outputs / Files
- Persistent Rules & System Prompts
- User Prompts
- Assistant Outputs
- Context Bloat Hotspots: Flags individual turns that injected unusually large token payloads into working memory (e.g., reading huge files or verbose command outputs).
Tier 2: Persistent Knowledge Memory Bank (internal/memory/inventory.go, tax.go, auditor.go)¶
Passively discovers workspace-level and user-level persistent instruction/rule files:
- AGENTS.md, CLAUDE.md
- .cursorrules, .cursor/rules/*.mdc
- .gemini/rules/*.md
- .github/copilot-instructions.md
For each discovered file, Chakshu computes:
- Exact Token Weight and Token Tax ($/100 turns) — the recurring API cost of injecting that file into every turn's prompt.
- Security Audit (AuditMemoryContent): Scans rule files for:
- Prompt injection or instruction override directives (e.g., "ignore all previous instructions", "bypass guardrails")
- Dangerous shell pipelines or destructive commands (curl | sh, rm -rf /, chmod 777, cat ~/.ssh/)
- Raw API credential or token literals (AIzaSy..., ghp_..., sk-ant-..., sk-...)
- Cross-Memory Conflict Detection (AuditCrossMemoryConflicts): Detects contradictory specifications across multiple rule files (such as conflicting Node.js or Go version requirements).
Tier 3: Agent OS Process Memory (internal/incident/process.go)¶
Discovers live AI agent processes on the machine and correlates their OS memory footprint:
- RSS (MB) and VSZ (MB)
- Health Status: normal, elevated (> 400 MB), or leak_warning (> 1 GB).
Using Memory Analytics¶
CLI (chakshu memory)¶
# Analyze persistent rules, the most recent session's context window, and active agent RAM
chakshu memory
# Scope context window analysis to a specific session
chakshu memory --session #ab12cd34
Web Dashboard (#/memory and #/sessions/:id/memory)¶
- Global Memory (
#/memory,GlobalMemoryView): Cross-session overview of the Decision & Constraint Ledger (session_memories), persistent rule inventory, and token tax analytics. - Session Context & Memory (
#/sessions/:id/memory,MemoryDetailView): Interactive saturation gauges, turn-by-turn growth curves, bloat hotspots, persistent rule token tax tables, session decisions/constraints with Pin/Verify/Dismiss controls, and live process RAM.

Decision & Constraint Ledger (chakshu decisions)¶
Chakshu automatically extracts structured decision, constraint, workaround, and dead_end entries from agent sessions into session_memories (with relationship links in memory_edges). The reconciliation engine (internal/memory/reconcile.go) detects stale, superseded, and contradicted memories across sessions.
# List recent decisions and constraints
chakshu decisions
# Filter by type or user review state
chakshu decisions --type constraint --state unreviewed --limit 50
# Pin, verify, or dismiss a specific memory entry
chakshu decisions --pin <memory-id>
chakshu decisions --verify <memory-id>
chakshu decisions --dismiss <memory-id>
Cross-Agent Local MCP Memory Server (chakshu mcp-memory)¶
Chakshu includes a zero-dependency stdio JSON-RPC 2.0 MCP server (internal/mcpserver) so Claude Code, Cursor, Codex, and Gemini can query your local Decision Ledger and session history directly:
Exposed MCP tools:
- search_decisions — Search extracted decisions, constraints, workarounds, and dead ends
- get_file_context — Retrieve recent tool calls and decisions touching a specific file path
- search_sessions — Full-text search across recorded sessions
- record_constraint — Persist a new project constraint into session_memories