{"id":"15ce822c-a492-478f-8f60-5d7bca65d24e","entityType":"agent","slug":"clawhub-99rebels-context-window-tracker","name":"Context Window Tracker","canonicalUrl":"https://www.xpersona.co/agent/clawhub-99rebels-context-window-tracker","canonicalPath":"/agent/clawhub-99rebels-context-window-tracker","generatedAt":"2026-10-12T10:26:09.356Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-11T20:11:17.377Z","emptyReason":null},"description":"Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h... Skill: Context Window Tracker Owner: 99rebels Summary: Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h... Tags: latest:1.4.0 Version history: v1.1.4 | 2026-04-30T17:21:11.387Z | user Revert to stable — undo formatting changes that increased security score v1.1.3 | 2026-04-30T16:56:52.077Z | user Script no lon","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 999 downloads reported by the source. Last updated 10/11/2026.","installCommand":"clawhub skill install s17b17x5vmnh2q27ane7sj7an5843qs4:context-window-tracker","sourceUrl":"https://clawhub.ai/99rebels/context-window-tracker","homepage":"https://clawhub.ai/99rebels/skills/context-window-tracker","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/99rebels/context-window-tracker","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/99rebels/skills/context-window-tracker","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":60,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h..."},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-11T20:11:17.377Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T20:11:17.377Z","emptyReason":null},"stars":null,"forks":null,"downloads":999,"likes":null,"task":null,"library":null,"packageName":null,"latestVersion":"1.1.4","tractionLabel":"999 downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T20:11:17.299Z","emptyReason":null},"lastUpdatedAt":"2026-10-11T20:11:17.377Z","lastCrawledAt":"2026-10-11T20:11:17.299Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-12T20:11:17.299Z","lastVerifiedAt":null,"highlights":[{"version":"1.1.4","createdAt":"2026-04-30T17:21:11.387Z","changelog":"Revert to stable — undo formatting changes that increased security score","fileCount":5,"zipByteSize":7157},{"version":"1.1.3","createdAt":"2026-04-30T16:56:52.077Z","changelog":"Script no longer uses markdown bold — removed Slack fix section entirely","fileCount":5,"zipByteSize":7809},{"version":"1.1.2","createdAt":"2026-04-30T16:51:13.198Z","changelog":"Rephrased formatting instruction to resolve prompt injection false positive","fileCount":5,"zipByteSize":8030},{"version":"1.1.1","createdAt":"2026-04-30T16:49:11.237Z","changelog":"Removed auto-check counter — skill is now fully read-only, no file writes","fileCount":5,"zipByteSize":8014},{"version":"1.4.0","createdAt":"2026-04-25T21:56:59.267Z","changelog":"Updated output format: default shows unicode bar + turns remaining + tokens/turn. Detailed view on explicit request. Slack rendering fix for asterisk markdown conflict.","fileCount":6,"zipByteSize":9633},{"version":"1.3.0","createdAt":"2026-04-23T20:20:17.304Z","changelog":"Updated output format to match screenshot layout, opt-in auto-check every 10 messages (disabled by default)","fileCount":5,"zipByteSize":7983},{"version":"1.0.2","createdAt":"2026-04-22T21:34:16.563Z","changelog":"Remove auto-check pattern for ClawHub security compliance - Removed auto-check counter (no more .msg-counter.json or auto-append) - Simplified guidance to optional note at 75%+ usage - Skill is now purely a callable tool with no persistent writes","fileCount":5,"zipByteSize":7158},{"version":"1.0.1","createdAt":"2026-04-22T21:12:02.782Z","changelog":"Fix Slack rendering and add detailed mode improvements - Replace box-drawing chars with ASCII indentation (Slack wrapping fix) - Add progress bar to detailed mode header for visual consistency - Add contextual LLM guidance at 75%+ usage threshold - Remove cost tracking (most users on monthly plans) - Slack-compatible visible dividers between sections","fileCount":5,"zipByteSize":7809}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s17b17x5vmnh2q27ane7sj7an5843qs4:context-window-tracker","setupComplexity":"low","setupSteps":["Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-12T10:26:09.353Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-99rebels-context-window-tracker/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-11T20:11:17.377Z","emptyReason":null},"readme":"Skill: Context Window Tracker\n\nOwner: 99rebels\n\nSummary: Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h...\n\nTags: latest:1.4.0\n\nVersion history:\n\nv1.1.4 | 2026-04-30T17:21:11.387Z | user\n\nRevert to stable — undo formatting changes that increased security score\n\nv1.1.3 | 2026-04-30T16:56:52.077Z | user\n\nScript no longer uses markdown bold — removed Slack fix section entirely\n\nv1.1.2 | 2026-04-30T16:51:13.198Z | user\n\nRephrased formatting instruction to resolve prompt injection false positive\n\nv1.1.1 | 2026-04-30T16:49:11.237Z | user\n\nRemoved auto-check counter — skill is now fully read-only, no file writes\n\nv1.4.0 | 2026-04-25T21:56:59.267Z | user\n\nUpdated output format: default shows unicode bar + turns remaining + tokens/turn. Detailed view on explicit request. Slack rendering fix for asterisk markdown conflict.\n\nv1.3.0 | 2026-04-23T20:20:17.304Z | user\n\nUpdated output format to match screenshot layout, opt-in auto-check every 10 messages (disabled by default)\n\nv1.0.2 | 2026-04-22T21:34:16.563Z | user\n\nRemove auto-check pattern for ClawHub security compliance\n\n- Removed auto-check counter (no more .msg-counter.json or auto-append)\n- Simplified guidance to optional note at 75%+ usage\n- Skill is now purely a callable tool with no persistent writes\n\nv1.0.1 | 2026-04-22T21:12:02.782Z | user\n\nFix Slack rendering and add detailed mode improvements\n\n- Replace box-drawing chars with ASCII indentation (Slack wrapping fix)\n- Add progress bar to detailed mode header for visual consistency\n- Add contextual LLM guidance at 75%+ usage threshold\n- Remove cost tracking (most users on monthly plans)\n- Slack-compatible visible dividers between sections\n\nv2.1.0 | 2026-04-22T16:04:59.890Z | user\n\nAdded unicode progress bar to visual output\n\nv2.0.0 | 2026-04-22T15:39:31.241Z | user\n\nSimplified to essentials\n\nv1.2.0 | 2026-04-22T12:47:26.607Z | user\n\nReplace --auto cron mode with simple message counter. Agent tracks user messages in .msg-counter.json and appends context report every 10th message. Cleaner, survives compaction, no cron needed.\n\nv1.1.0 | 2026-04-22T10:05:37.086Z | user\n\nRename 'System Prompt' to 'Session Setup' in output (avoids scanner false positive). Add --auto mode for periodic monitoring — only reports when N new turns since last check.\n\nv1.0.0 | 2026-04-22T09:01:10.234Z | user\n\nInitial release. OpenClaw context window reporting with system prompt breakdown, turn prediction, cache hit rate, and cost.\n\nArchive index:\n\nArchive v1.1.4: 5 files, 7157 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10979b), SKILL.md (3903b), _meta.json (141b)\n\nFile v1.1.4:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left, without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line, glanceable. Good for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Compact\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 29.8K / 202.8K tokens (15% used) | ~736 turns left | Cache: 99%\n```\n\n### Detailed\n```\n🟢 [███░░░░░░░░░░░░░░░░░] Context Usage: 29.8K / 202.8K (15%)\n\n────────────────────\n**Token Breakdown**\n  System Prompt: ~10.2K tokens (5%)\n    AGENTS.md: ~2.0K\n    SOUL.md: ~416\n    TOOLS.md: ~717\n    MEMORY.md: ~2.3K\n  📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n  Conversation: ~19.6K tokens (10%)\n  📊 Total Used: 29.8K (15%)\n  Remaining: 173.0K (85%)\n\n────────────────────\n**Trends**\n  Avg tokens per turn: ~1.2K tokens\n  ⏳ Estimated turns remaining: ~144\n\n────────────────────\n**Session Stats**\n  📥 Total input: 25K | 📤 Total output: 1.8K | Cache hit rate: 99%\n  Thinking: active (3/12 responses)\n────────────────────\n```\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The indicator shifts: 🟢 under 60%, 🟡 60-80%, 🔴 over 80%.\n\n## Guidance\n\nWhen the user asks about context usage, you may optionally include a brief note about remaining capacity based on the script output and the current conversation. Only do this at 75%+ usage. Skip for fresh sessions.\n\nRules:\n- One line max. Reference the actual task, not generic categories.\n- Don't prescribe actions, describe what fits.\n- Never suggest deleting workspace files or changing system config.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth. The session store can lag behind by thousands of tokens.\n- If the context window limit is unknown, the script shows tokens used without a percentage.\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.1.4:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.1.4\",\n  \"publishedAt\": 1777569671387\n}\n\nFile v1.1.4:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.1.4:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v1.1.3: 5 files, 7809 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10756b), SKILL.md (5438b), _meta.json (141b)\n\nFile v1.1.3:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line. Glanceable. Use for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Default (quick check)\nWhen the user asks \"check context\", \"how much context\", \"context window\", or similar casual phrases.\n\nShow the unicode bar, percentage, estimated turns remaining, and average tokens per turn:\n\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 15% | ~736 turns left | 427 tokens/turn\n```\n\nRun the compact script (`python3 scripts/context_report.py`) and extract the bar/percentage. Get avg tokens/turn and turns remaining from the detailed script or session_status.\n\nAdd a contextual one-liner when context is 75%+ used (see Guidance section). Otherwise, just show the line.\n\n### Detailed\nWhen the user explicitly asks \"detailed context\", \"full context check\", \"context breakdown\", or \"show me everything\":\n\n```\n🟢 [███████████░░░░░░░░░] Context Usage: 113.7K / 202.8K (56%)\n────────────────────\nToken Breakdown\nSystem Prompt: ~10.2K tokens (5%)\nAGENTS.md: ~2.0K tokens\nSOUL.md: ~416 tokens\nTOOLS.md: ~717 tokens\nIDENTITY.md: ~65 tokens\nUSER.md: ~83 tokens\nHEARTBEAT.md: ~48 tokens\nBOOTSTRAP.md: ~18 tokens\nMEMORY.md: ~2.3K tokens\n📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n• Conversation: ~103.5K tokens (51%)\n• 📊 Total Used: 113.7K (56%)\n• Remaining: 89.1K (44%)\n────────────────────\nTrends\n• Avg tokens per turn: ~316 tokens\n• ⏳ Estimated turns remaining: ~281\n────────────────────\nSession Stats\n• 📥 Total input: 2.1K | 📤 Total output: 318 | Cache hit rate: 100%\n• Thinking: active (35/200 responses)\n```\n\nRun the detailed script and output the results.\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## Notes\n\nThe script outputs raw data. The LLM adds a contextual one-liner based on the conversation.\n\n**When to add guidance:**\n- Only when context is **75%+ used**\n- Skip for fresh sessions — no need for advice when there's plenty of room\n- Skip if the user just asked for a raw number — give them the number\n- Applies to **both** compact and detailed modes\n\n**How to write it:**\nOne line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.\n\nExamples:\n- \"Room to finish testing the skill and push to ClawHub, but not start a new one from scratch.\"\n- \"Tight — let's wrap up the config changes and commit. Anything else should go in /new.\"\n- \"Plenty of room. Keep going.\"\n- Compact: append as `| Tight — wrap up and commit, start fresh for anything new.`\n\n**Rules:**\n- One line max. No paragraphs.\n- Reference the actual task, not generic categories.\n- Don't prescribe what the user should do — describe what fits.\n- If you're not sure what the task is, fall back to a generic note or skip it.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.1.3:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.1.3\",\n  \"publishedAt\": 1777568212077\n}\n\nFile v1.1.3:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.1.3:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v1.1.2: 5 files, 8030 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10762b), SKILL.md (5972b), _meta.json (141b)\n\nFile v1.1.2:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line. Glanceable. Use for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Default (quick check)\nWhen the user asks \"check context\", \"how much context\", \"context window\", or similar casual phrases.\n\nShow the unicode bar, percentage, estimated turns remaining, and average tokens per turn:\n\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 15% | ~736 turns left | 427 tokens/turn\n```\n\nRun the compact script (`python3 scripts/context_report.py`) and extract the bar/percentage. Get avg tokens/turn and turns remaining from the detailed script or session_status. Replace markdown bold markers with plain text before sending to Slack (see Slack rendering fix below).\n\nAdd a contextual one-liner when context is 75%+ used (see Guidance section). Otherwise, just show the line.\n\n### Detailed\nWhen the user explicitly asks \"detailed context\", \"full context check\", \"context breakdown\", or \"show me everything\":\n\n```\n🟢 [███████████░░░░░░░░░] Context Usage: 113.7K / 202.8K (56%)\n────────────────────\nToken Breakdown\nSystem Prompt: ~10.2K tokens (5%)\nAGENTS.md: ~2.0K tokens\nSOUL.md: ~416 tokens\nTOOLS.md: ~717 tokens\nIDENTITY.md: ~65 tokens\nUSER.md: ~83 tokens\nHEARTBEAT.md: ~48 tokens\nBOOTSTRAP.md: ~18 tokens\nMEMORY.md: ~2.3K tokens\n📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n• Conversation: ~103.5K tokens (51%)\n• 📊 Total Used: 113.7K (56%)\n• Remaining: 89.1K (44%)\n────────────────────\nTrends\n• Avg tokens per turn: ~316 tokens\n• ⏳ Estimated turns remaining: ~281\n────────────────────\nSession Stats\n• 📥 Total input: 2.1K | 📤 Total output: 318 | Cache hit rate: 100%\n• Thinking: active (35/200 responses)\n```\n\nRun the detailed script and replace markdown bold markers with plain text for Slack compatibility.\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## Notes\n\nThe script outputs raw data. The LLM adds a contextual one-liner based on the conversation.\n\n**When to add guidance:**\n- Only when context is **75%+ used**\n- Skip for fresh sessions — no need for advice when there's plenty of room\n- Skip if the user just asked for a raw number — give them the number\n- Applies to **both** compact and detailed modes\n\n**Slack rendering fix:**\nThe script uses `*text*` for emphasis, which Slack interprets as italics and can break rendering of the detailed output (long messages with many italics markers fail to display). When the channel is Slack:\n- Strip all `*` characters from the script output before displaying\n- Alternatively, use the compact mode (one-liner) which doesn't have this issue\n\n**How to write it:**\nOne line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.\n\nExamples:\n- \"Room to finish testing the skill and push to ClawHub, but not start a new one from scratch.\"\n- \"Tight — let's wrap up the config changes and commit. Anything else should go in /new.\"\n- \"Plenty of room. Keep going.\"\n- Compact: append as `| Tight — wrap up and commit, start fresh for anything new.`\n\n**Rules:**\n- One line max. No paragraphs.\n- Reference the actual task, not generic categories.\n- Don't prescribe what the user should do — describe what fits.\n- If you're not sure what the task is, fall back to a generic note or skip it.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.1.2:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.1.2\",\n  \"publishedAt\": 1777567873198\n}\n\nFile v1.1.2:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.1.2:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v1.1.1: 5 files, 8014 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10762b), SKILL.md (5930b), _meta.json (141b)\n\nFile v1.1.1:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line. Glanceable. Use for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Default (quick check)\nWhen the user asks \"check context\", \"how much context\", \"context window\", or similar casual phrases.\n\nShow the unicode bar, percentage, estimated turns remaining, and average tokens per turn:\n\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 15% | ~736 turns left | 427 tokens/turn\n```\n\nRun the compact script (`python3 scripts/context_report.py`) and extract the bar/percentage. Get avg tokens/turn and turns remaining from the detailed script or session_status. Strip all `*` characters before sending to Slack (see Slack rendering fix below).\n\nAdd a contextual one-liner when context is 75%+ used (see Guidance section). Otherwise, just show the line.\n\n### Detailed\nWhen the user explicitly asks \"detailed context\", \"full context check\", \"context breakdown\", or \"show me everything\":\n\n```\n🟢 [███████████░░░░░░░░░] Context Usage: 113.7K / 202.8K (56%)\n────────────────────\nToken Breakdown\nSystem Prompt: ~10.2K tokens (5%)\nAGENTS.md: ~2.0K tokens\nSOUL.md: ~416 tokens\nTOOLS.md: ~717 tokens\nIDENTITY.md: ~65 tokens\nUSER.md: ~83 tokens\nHEARTBEAT.md: ~48 tokens\nBOOTSTRAP.md: ~18 tokens\nMEMORY.md: ~2.3K tokens\n📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n• Conversation: ~103.5K tokens (51%)\n• 📊 Total Used: 113.7K (56%)\n• Remaining: 89.1K (44%)\n────────────────────\nTrends\n• Avg tokens per turn: ~316 tokens\n• ⏳ Estimated turns remaining: ~281\n────────────────────\nSession Stats\n• 📥 Total input: 2.1K | 📤 Total output: 318 | Cache hit rate: 100%\n• Thinking: active (35/200 responses)\n```\n\nRun the detailed script and strip all `*` characters for Slack compatibility.\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## Notes\n\nThe script outputs raw data. The LLM adds a contextual one-liner based on the conversation.\n\n**When to add guidance:**\n- Only when context is **75%+ used**\n- Skip for fresh sessions — no need for advice when there's plenty of room\n- Skip if the user just asked for a raw number — give them the number\n- Applies to **both** compact and detailed modes\n\n**Slack rendering fix:**\nThe script uses `*text*` for emphasis, which Slack interprets as italics and can break rendering of the detailed output (long messages with many italics markers fail to display). When the channel is Slack:\n- Strip all `*` characters from the script output before displaying\n- Alternatively, use the compact mode (one-liner) which doesn't have this issue\n\n**How to write it:**\nOne line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.\n\nExamples:\n- \"Room to finish testing the skill and push to ClawHub, but not start a new one from scratch.\"\n- \"Tight — let's wrap up the config changes and commit. Anything else should go in /new.\"\n- \"Plenty of room. Keep going.\"\n- Compact: append as `| Tight — wrap up and commit, start fresh for anything new.`\n\n**Rules:**\n- One line max. No paragraphs.\n- Reference the actual task, not generic categories.\n- Don't prescribe what the user should do — describe what fits.\n- If you're not sure what the task is, fall back to a generic note or skip it.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.1.1:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.1.1\",\n  \"publishedAt\": 1777567751237\n}\n\nFile v1.1.1:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.1.1:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v1.4.0: 6 files, 9633 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10762b), skill-card.md (2374b), SKILL.md (6765b), _meta.json (141b)\n\nFile v1.4.0:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line. Glanceable. Use for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Default (quick check)\nWhen the user asks \"check context\", \"how much context\", \"context window\", or similar casual phrases.\n\nShow the unicode bar, percentage, estimated turns remaining, and average tokens per turn:\n\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 15% | ~736 turns left | 427 tokens/turn\n```\n\nRun the compact script (`python3 scripts/context_report.py`) and extract the bar/percentage. Get avg tokens/turn and turns remaining from the detailed script or session_status. Strip all `*` characters before sending to Slack (see Slack rendering fix below).\n\nAdd a contextual one-liner when context is 75%+ used (see Guidance section). Otherwise, just show the line.\n\n### Detailed\nWhen the user explicitly asks \"detailed context\", \"full context check\", \"context breakdown\", or \"show me everything\":\n\n```\n🟢 [███████████░░░░░░░░░] Context Usage: 113.7K / 202.8K (56%)\n────────────────────\nToken Breakdown\nSystem Prompt: ~10.2K tokens (5%)\nAGENTS.md: ~2.0K tokens\nSOUL.md: ~416 tokens\nTOOLS.md: ~717 tokens\nIDENTITY.md: ~65 tokens\nUSER.md: ~83 tokens\nHEARTBEAT.md: ~48 tokens\nBOOTSTRAP.md: ~18 tokens\nMEMORY.md: ~2.3K tokens\n📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n• Conversation: ~103.5K tokens (51%)\n• 📊 Total Used: 113.7K (56%)\n• Remaining: 89.1K (44%)\n────────────────────\nTrends\n• Avg tokens per turn: ~316 tokens\n• ⏳ Estimated turns remaining: ~281\n────────────────────\nSession Stats\n• 📥 Total input: 2.1K | 📤 Total output: 318 | Cache hit rate: 100%\n• Thinking: active (35/200 responses)\n```\n\nRun the detailed script and strip all `*` characters for Slack compatibility.\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## Auto-Check (Opt-In)\n\nThe compact report can run automatically every 10 messages. This is **disabled by default** — the user must explicitly enable it.\n\nTo enable, the user must say something like \"auto-check my context\" or \"enable context auto-check\". Once enabled:\n\n1. Maintain a message counter in `.msg-counter.json` (same directory as SKILL.md)\n2. On every user message, increment the counter\n3. If the count is a multiple of 10, run the compact script and append the output to your reply\n4. If not, reply normally\n\nThe counter survives compaction. If the file is missing, create it starting at 0:\n\n```json\n{\"count\": 0}\n```\n\nTo disable, the user can say \"disable context auto-check\" — delete the counter file and stop checking.\n\n**Important:** Never enable this automatically. Only enable when the user explicitly asks.\n\n## Guidance\n\nThe script outputs raw data. The LLM adds a contextual one-liner based on the conversation.\n\n**When to add guidance:**\n- Only when context is **75%+ used**\n- Skip for fresh sessions — no need for advice when there's plenty of room\n- Skip if the user just asked for a raw number — give them the number\n- Applies to **both** compact and detailed modes\n\n**Slack rendering fix:**\nThe script uses `*text*` for emphasis, which Slack interprets as italics and can break rendering of the detailed output (long messages with many italics markers fail to display). When the channel is Slack:\n- Strip all `*` characters from the script output before displaying\n- Alternatively, use the compact mode (one-liner) which doesn't have this issue\n\n**How to write it:**\nOne line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.\n\nExamples:\n- \"Room to finish testing the skill and push to ClawHub, but not start a new one from scratch.\"\n- \"Tight — let's wrap up the config changes and commit. Anything else should go in /new.\"\n- \"Plenty of room. Keep going.\"\n- Compact: append as `| Tight — wrap up and commit, start fresh for anything new.`\n\n**Rules:**\n- One line max. No paragraphs.\n- Reference the actual task, not generic categories.\n- Don't prescribe what the user should do — describe what fits.\n- If you're not sure what the task is, fall back to a generic note or skip it.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.4.0:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.4.0\",\n  \"publishedAt\": 1777154219267\n}\n\nFile v1.4.0:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.4.0:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nFile v1.4.0:skill-card.md\n\n## Description:\n\nTrack and report OpenClaw context window usage, including token totals, remaining capacity, usage trends, and a breakdown of session, prompt, and reasoning-token contributors.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[99rebels](https://clawhub.ai/user/99rebels)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and OpenClaw users use this skill to check how much context window remains in the current session, understand what is consuming tokens, and decide whether a compact or detailed usage report is needed.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: The local helper reads OpenClaw session metadata and transcript files to calculate token usage.\n\nMitigation: Install only when local session-file access is acceptable, and review the security summary and source before use.\n\nRisk: Auto-check mode can maintain a persistent local message counter and periodically append context reports.\n\nMitigation: Keep auto-check disabled unless explicitly requested, and disable it when periodic context reports are no longer needed.\n\nRisk: Some detailed fields are estimates rather than provider-exact counts.\n\nMitigation: Treat per-file prompt breakdowns, turns remaining, and thinking-token status as estimates; rely on total token usage for context-window fullness.\n\n## Reference(s):\n\n- [Data Sources](references/data-sources.md)\n- [Thinking / Reasoning Tokens](references/thinking-tokens.md)\n- [Project homepage](https://github.com/99rebels/context-window-tracker)\n- [ClawHub skill page](https://clawhub.ai/99rebels/skills/context-window-tracker)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, guidance]\n\n**Output Format:** [Compact text status line or detailed Markdown report with command snippets]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [Reports include exact provider token totals where available and estimated breakdowns for prompt components, turns remaining, and thinking-token status.]\n\n## Skill Version(s):\n\n1.4.0 (source: server release metadata)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nArchive v1.3.0: 5 files, 7983 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10762b), SKILL.md (5725b), _meta.json (141b)\n\nFile v1.3.0:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line. Glanceable. Use for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Compact\n```\n🟢 [███░░░░░░░░░░░░░░░░░] Context Usage: 29.8K / 202.8K (15%) | ~736 turns left | Cache: 99%\n```\n\n### Detailed\n```\n🟢 [███████████░░░░░░░░░] Context Usage: 113.7K / 202.8K (56%)\n────────────────────\n*Token Breakdown*\nSystem Prompt: ~10.2K tokens (5%)\nAGENTS.md: ~2.0K tokens\nSOUL.md: ~416 tokens\nTOOLS.md: ~717 tokens\nIDENTITY.md: ~65 tokens\nUSER.md: ~83 tokens\nHEARTBEAT.md: ~48 tokens\nBOOTSTRAP.md: ~18 tokens\nMEMORY.md: ~2.3K tokens\n📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n• Conversation: ~103.5K tokens (51%)\n• 📊 Total Used: 113.7K (56%)\n• Remaining: 89.1K (44%)\n• ────────────────────\n• *Trends*\n• Avg tokens per turn: ~316 tokens\n• ⏳ Estimated turns remaining: ~281\n• ────────────────────\n• *Session Stats*\n• 📥 Total input: 2.1K | 📤 Total output: 318 | Cache hit rate: 100%\n• Thinking: active (35/200 responses)\n• ────────────────────\n```\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## Auto-Check (Opt-In)\n\nThe compact report can run automatically every 10 messages. This is **disabled by default** — the user must explicitly enable it.\n\nTo enable, the user must say something like \"auto-check my context\" or \"enable context auto-check\". Once enabled:\n\n1. Maintain a message counter in `.msg-counter.json` (same directory as SKILL.md)\n2. On every user message, increment the counter\n3. If the count is a multiple of 10, run the compact script and append the output to your reply\n4. If not, reply normally\n\nThe counter survives compaction. If the file is missing, create it starting at 0:\n\n```json\n{\"count\": 0}\n```\n\nTo disable, the user can say \"disable context auto-check\" — delete the counter file and stop checking.\n\n**Important:** Never enable this automatically. Only enable when the user explicitly asks.\n\n## Guidance\n\nThe script outputs raw data. The LLM adds a contextual one-liner based on the conversation.\n\n**When to add guidance:**\n- Only when context is **75%+ used**\n- Skip for fresh sessions — no need for advice when there's plenty of room\n- Skip if the user just asked for a raw number — give them the number\n- Applies to **both** compact and detailed modes\n\n**How to write it:**\nOne line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.\n\nExamples:\n- \"Room to finish testing the skill and push to ClawHub, but not start a new one from scratch.\"\n- \"Tight — let's wrap up the config changes and commit. Anything else should go in /new.\"\n- \"Plenty of room. Keep going.\"\n- Compact: append as `| Tight — wrap up and commit, start fresh for anything new.`\n\n**Rules:**\n- One line max. No paragraphs.\n- Reference the actual task, not generic categories.\n- Don't prescribe what the user should do — describe what fits.\n- If you're not sure what the task is, fall back to a generic note or skip it.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.3.0:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.3.0\",\n  \"publishedAt\": 1776975617304\n}\n\nFile v1.3.0:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.3.0:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v1.0.2: 5 files, 7158 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10979b), SKILL.md (3903b), _meta.json (141b)\n\nFile v1.0.2:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left, without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line, glanceable. Good for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Compact\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 29.8K / 202.8K tokens (15% used) | ~736 turns left | Cache: 99%\n```\n\n### Detailed\n```\n🟢 [███░░░░░░░░░░░░░░░░░] Context Usage: 29.8K / 202.8K (15%)\n\n────────────────────\n**Token Breakdown**\n  System Prompt: ~10.2K tokens (5%)\n    AGENTS.md: ~2.0K\n    SOUL.md: ~416\n    TOOLS.md: ~717\n    MEMORY.md: ~2.3K\n  📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n  Conversation: ~19.6K tokens (10%)\n  📊 Total Used: 29.8K (15%)\n  Remaining: 173.0K (85%)\n\n────────────────────\n**Trends**\n  Avg tokens per turn: ~1.2K tokens\n  ⏳ Estimated turns remaining: ~144\n\n────────────────────\n**Session Stats**\n  📥 Total input: 25K | 📤 Total output: 1.8K | Cache hit rate: 99%\n  Thinking: active (3/12 responses)\n────────────────────\n```\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The indicator shifts: 🟢 under 60%, 🟡 60-80%, 🔴 over 80%.\n\n## Guidance\n\nWhen the user asks about context usage, you may optionally include a brief note about remaining capacity based on the script output and the current conversation. Only do this at 75%+ usage. Skip for fresh sessions.\n\nRules:\n- One line max. Reference the actual task, not generic categories.\n- Don't prescribe actions, describe what fits.\n- Never suggest deleting workspace files or changing system config.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth. The session store can lag behind by thousands of tokens.\n- If the context window limit is unknown, the script shows tokens used without a percentage.\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.0.2:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.0.2\",\n  \"publishedAt\": 1776893656563\n}\n\nFile v1.0.2:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.0.2:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v1.0.1: 5 files, 7809 bytes\n\nFiles: references/data-sources.md (2241b), references/thinking-tokens.md (963b), scripts/context_report.py (10979b), SKILL.md (5078b), _meta.json (141b)\n\nFile v1.0.1:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line. Glanceable. Use for auto-checks or quick status.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Auto-Check Every 10 Messages\n\nMaintain a message counter in `.msg-counter.json` (same directory as SKILL.md). On every user message:\n\n1. Increment the counter\n2. If the count is a multiple of 10, run the compact script and append the output to your reply\n3. If not, reply normally\n\nThe counter survives compaction. If the file is missing, create it starting at 0:\n\n```json\n{\"count\": 0}\n```\n\n## Output Format\n\n### Compact\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 29.8K / 202.8K tokens (15% used)\n~736 turns left | Cache: 99%\n```\n\n### Detailed\n```\n🟢 Context Usage: 29.8K / 202.8K (15%)\n\n── Token Breakdown ──\n• System Prompt: ~10.2K tokens (5%)\n  ├─ AGENTS.md: ~2.0K\n  ├─ SOUL.md: ~416\n  ├─ TOOLS.md: ~717\n  ├─ IDENTITY.md: ~65\n  ├─ USER.md: ~83\n  ├─ HEARTBEAT.md: ~48\n  ├─ BOOTSTRAP.md: ~18\n  ├─ MEMORY.md: ~2.3K\n  └─ Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n• Conversation: ~19.6K tokens (10%)\n• Total Used: 29.8K (15%)\n• Remaining: 173.0K (85%)\n\n── Trends ──\n• Avg growth per turn: ~1.2K tokens\n• Estimated turns remaining: ~144\n\n── Session Stats ──\n• Total input: 25K | Total output: 1.8K | Cache hit rate: 99%\n• Thinking: active (3/12 responses)\n```\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## Guidance\n\nThe script outputs raw data. The LLM adds a contextual one-liner based on the conversation.\n\n**When to add guidance:**\n- Only when context is **75%+ used**\n- Skip for fresh sessions — no need for advice when there's plenty of room\n- Skip if the user just asked for a raw number — give them the number\n- Applies to **both** compact and detailed modes\n\n**How to write it:**\nOne line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.\n\nExamples:\n- \"Room to finish testing the skill and push to ClawHub, but not start a new one from scratch.\"\n- \"Tight — let's wrap up the config changes and commit. Anything else should go in /new.\"\n- \"Plenty of room. Keep going.\"\n- Compact: append as `| Tight — wrap up and commit, start fresh for anything new.\"\n\n**Rules:**\n- One line max. No paragraphs.\n- Reference the actual task, not generic categories.\n- Don't prescribe what the user should do — describe what fits.\n- If you're not sure what the task is, fall back to a generic note or skip it.\n- Never suggest deleting workspace files or changing system config.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v1.0.1:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.0.1\",\n  \"publishedAt\": 1776892322782\n}\n\nFile v1.0.1:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v1.0.1:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v2.1.0: 5 files, 5617 bytes\n\nFiles: references/data-sources.md (2258b), references/thinking-tokens.md (963b), scripts/context_report.py (5703b), SKILL.md (2654b), _meta.json (141b)\n\nFile v2.1.0:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Quick Start\n\n```bash\npython3 scripts/context_report.py\n```\n\nAuto-detects the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n```\n\n## Auto-Check Every 10 Messages\n\nMaintain a message counter in `.msg-counter.json` (same directory as SKILL.md). On every user message:\n\n1. Increment the counter\n2. If the count is a multiple of 10, run the script and append the output to your reply\n3. If not, reply normally\n\nThe counter survives compaction. If the file is missing, create it starting at 0:\n\n```json\n{\"count\": 0}\n```\n\n## Output Format\n\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 85% remaining — 29.8K / 202.8K tokens\n~736 turns left\nCache hit rate: 99%\n```\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%).\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Turns remaining (extrapolated from recent token growth per turn)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v2.1.0:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"2.1.0\",\n  \"publishedAt\": 1776873899890\n}\n\nFile v2.1.0:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `estimatedCostUsd` — cumulative session cost\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\nThe script labels this as \"Session Setup\" in the output (workspace files + framework overhead combined).\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v2.1.0:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.\n\nArchive v2.0.0: 5 files, 5425 bytes\n\nFiles: references/data-sources.md (2258b), references/thinking-tokens.md (963b), scripts/context_report.py (5435b), SKILL.md (2517b), _meta.json (141b)\n\nFile v2.0.0:SKILL.md\n\n---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left — without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Quick Start\n\n```bash\npython3 scripts/context_report.py\n```\n\nAuto-detects the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n```\n\n## Auto-Check Every 10 Messages\n\nMaintain a message counter in `.msg-counter.json` (same directory as SKILL.md). On every user message:\n\n1. Increment the counter\n2. If the count is a multiple of 10, run the script and append the output to your reply\n3. If not, reply normally\n\nThe counter survives compaction. If the file is missing, create it starting at 0:\n\n```json\n{\"count\": 0}\n```\n\n## Output Format\n\n```\n🟢 93% remaining — 15.1K / 202.8K tokens used\n~206 turns left\nCache hit rate: 96%\n```\n\n### Health Indicator\n\n- 🟢 Under 60% used — plenty of room\n- 🟡 60–80% used — getting tight\n- 🔴 Over 80% used — consider wrapping up\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Turns remaining (extrapolated from recent token growth per turn)\n```\n\n## Notes\n\n- Script reads the transcript (`.jsonl`) as source of truth — the session store can lag behind by thousands of tokens\n- If the session store doesn't provide a context window limit (some thread sessions), it shows tokens used without a percentage\n- See [references/data-sources.md](references/data-sources.md) for file paths\n- See [references/thinking-tokens.md](references/thinking-tokens.md) for how reasoning tokens affect counts\n\nFile v2.0.0:_meta.json\n\n{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"2.0.0\",\n  \"publishedAt\": 1776872371241\n}\n\nFile v2.0.0:references/data-sources.md\n\n# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `estimatedCostUsd` — cumulative session cost\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\nThe script labels this as \"Session Setup\" in the output (workspace files + framework overhead combined).\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider.\n\nFile v2.0.0:references/thinking-tokens.md\n\n# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`.","readmeExcerpt":"Skill: Context Window Tracker Owner: 99rebels Summary: Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h... Tags: latest:1.4.0 Version history: v1.1.4 | 2026-04-30T17:21:11.387Z | user Revert to stable — undo formatting changes that increased security score v1.1.3 | 2026-04-30T16:56:52.077Z | user Script no lon","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"python3 scripts/context_report.py"},{"language":"bash","snippet":"python3 scripts/context_report.py --detailed"},{"language":"text","snippet":"--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner"},{"language":"text","snippet":"🟢 [███░░░░░░░░░░░░░░░░░] 29.8K / 202.8K tokens (15% used) | ~736 turns left | Cache: 99%"},{"language":"text","snippet":"🟢 [███░░░░░░░░░░░░░░░░░] Context Usage: 29.8K / 202.8K (15%)\n\n────────────────────\n**Token Breakdown**\n  System Prompt: ~10.2K tokens (5%)\n    AGENTS.md: ~2.0K\n    SOUL.md: ~416\n    TOOLS.md: ~717\n    MEMORY.md: ~2.3K\n  📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n  Conversation: ~19.6K tokens (10%)\n  📊 Total Used: 29.8K (15%)\n  Remaining: 173.0K (85%)\n\n────────────────────\n**Trends**\n  Avg tokens per turn: ~1.2K tokens\n  ⏳ Estimated turns remaining: ~144\n\n────────────────────\n**Session Stats**\n  📥 Total input: 25K | 📤 Total output: 1.8K | Cache hit rate: 99%\n  Thinking: active (3/12 responses)\n────────────────────"},{"language":"text","snippet":"✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  • Cache hit rate\n\n⚠ Estimated:\n  • Per-file system prompt breakdown (chars ÷ 4)\n  • Turns remaining (extrapolated from recent growth rate)\n  • Thinking token count (bundled by provider, not separately reported)"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: context-window-tracker\ndescription: >\n  Track and report OpenClaw context window usage with a detailed breakdown of what's\n  consuming tokens. Use when: user asks about context usage, token usage,\n  \"how much context am I using\", \"how full is my context window\", \"tokens remaining\",\n  \"am I close to the limit\", thinking/reasoning token costs, what's eating context\n  (session setup vs conversation vs overhead), or how many turns are left.\n  NOT for: estimating tokens for arbitrary text, managing context (compact/prune),\n  or cross-session cost aggregation.\nhomepage: https://github.com/99rebels/context-window-tracker\n---\n\n# Context Window Tracker\n\nShows how much context window is left, without opening the terminal.\n\n## When to Use\n\n- \"Check my context\"\n- \"How much context am I using?\"\n- \"How full is my context window?\"\n- \"Tokens remaining\"\n- \"Am I close to the limit?\"\n- Any question about context usage\n\n## Two Modes\n\n### Compact (default)\nOne line, glanceable. Good for quick checks.\n\n```bash\npython3 scripts/context_report.py\n```\n\n### Detailed\nFull breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.\n\n```bash\npython3 scripts/context_report.py --detailed\n```\n\nBoth modes auto-detect the most recently updated session. Options:\n\n```\n--session <key>    Target a specific session\n--agent <name>     Target a specific agent (default: main)\n--detailed         Full breakdown instead of compact one-liner\n```\n\n## Output Format\n\n### Compact\n```\n🟢 [███░░░░░░░░░░░░░░░░░] 29.8K / 202.8K tokens (15% used) | ~736 turns left | Cache: 99%\n```\n\n### Detailed\n```\n🟢 [███░░░░░░░░░░░░░░░░░] Context Usage: 29.8K / 202.8K (15%)\n\n────────────────────\n**Token Breakdown**\n  System Prompt: ~10.2K tokens (5%)\n    AGENTS.md: ~2.0K\n    SOUL.md: ~416\n    TOOLS.md: ~717\n    MEMORY.md: ~2.3K\n  📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)\n  Conversation: ~19.6K tokens (10%)\n  📊 Total Used: 29.8K (15%)\n  Remaining: 173.0K (85%)\n\n────────────────────\n**Trends**\n  Avg tokens per turn: ~1.2K tokens\n  ⏳ Estimated turns remaining: ~144\n\n────────────────────\n**Session Stats**\n  📥 Total input: 25K | 📤 Total output: 1.8K | Cache hit rate: 99%\n  Thinking: active (3/12 responses)\n────────────────────\n```\n\nThe bar uses `█` (filled) and `░` (empty) across 20 segments (each = 5%). The indicator shifts: 🟢 under 60%, 🟡 60-80%, 🔴 over 80%.\n\n## Guidance\n\nWhen the user asks about context usage, you may optionally include a brief note about remaining capacity based on the script output and the current conversation. Only do this at 75%+ usage. Skip for fresh sessions.\n\nRules:\n- One line max. Reference the actual task, not generic categories.\n- Don't prescribe actions, describe what fits.\n- Never suggest deleting workspace files or changing system config.\n\n## What's Exact vs Estimated\n\n```\n✅ Exact (from provider):\n  • Total tokens used (from transcript)\n  • Context window limit (from session store)\n  •"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7efp7pm24p8pa49yfxqqwd7d843jwe\",\n  \"slug\": \"context-window-tracker\",\n  \"version\": \"1.1.4\",\n  \"publishedAt\": 1777569671387\n}"},{"path":"references/data-sources.md","content":"# Data Sources\n\nWhere the script reads from and what each source provides.\n\n## Transcript (source of truth)\n\n```\n~/.openclaw/agents/<agent>/sessions/<sessionId>.jsonl\n```\n\nEach line is JSON. The script reads `type: \"message\"` entries with `role: \"assistant\"` and extracts `message.usage`.\n\nUsage fields (already normalized by OpenClaw from any provider):\n- `input` — non-cached input tokens\n- `output` — generated tokens (includes thinking/reasoning tokens for most providers)\n- `cacheRead` — tokens served from cache\n- `cacheWrite` — new tokens written to cache\n- `totalTokens` — the authoritative total (always accurate regardless of provider)\n- `cost` — per-response cost breakdown\n\n**Prefer transcript over session store** — the store can lag behind by several thousand tokens.\n\n## Session Store\n\n```\n~/.openclaw/agents/<agent>/sessions/sessions.json\n```\n\nProvides data the transcript doesn't have:\n- `contextTokens` — the context window limit for this model\n- `systemPromptReport` — per-file character breakdown of the system prompt\n- `inputTokens`, `outputTokens` — cumulative totals (may lag behind transcript)\n- `sessionFile` — path to the transcript file\n\n### System Prompt Report Structure\n\n```json\n{\n  \"systemPrompt\": {\n    \"chars\": 45511,\n    \"projectContextChars\": 23013,\n    \"nonProjectContextChars\": 22498\n  },\n  \"injectedWorkspaceFiles\": [\n    {\"name\": \"AGENTS.md\", \"rawChars\": 7809, \"injectedChars\": 7809, \"truncated\": false}\n  ]\n}\n```\n\n- `projectContextChars` — workspace files (AGENTS.md, SOUL.md, MEMORY.md, etc.)\n- `nonProjectContextChars` — framework overhead (tool schemas, skill list, runtime config)\n\n## How OpenClaw Normalizes Provider Responses\n\n```\nProvider raw response → OpenClaw normalized format\n────────────────────────────────────────────────────\nprompt_tokens          → input (minus cached_tokens)\ncompletion_tokens      → output (plus reasoning_tokens if present)\nprompt_tokens_details  → cacheRead\n.completion_tokens_details\n  .reasoning_tokens    → added to output\n```\n\n`totalTokens = input + output + cacheRead` is always the real total regardless of provider."},{"path":"references/thinking-tokens.md","content":"# Thinking / Reasoning Tokens\n\nHow each provider handles extended thinking and how it affects token counts.\n\nThinking tokens always cost money and always count against the context window. But providers report them differently:\n\n```\nAnthropic   → Bundled into input_tokens (same billing rate)\nOpenAI      → Separate field: completion_tokens_details.reasoning_tokens\nz.ai        → Varies by model, may bundle into input or output\n```\n\nOpenClaw's `totalTokens` always includes thinking tokens — it's the authoritative count for \"how full is my window.\"\n\n## Detection\n\nThe script can't detect thinking tokens from usage fields alone (they're bundled for most providers). It notes the provider's behavior in the report output:\n\n```\nThinking: bundled into input (Anthropic)\nThinking: separate reasoning_tokens field (OpenAI)\nThinking: varies by model (z.ai)\n```\n\nFor definitive detection, scan the transcript JSONL for content blocks with `\"type\": \"thinking\"`."}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h... Skill: Context Window Tracker Owner: 99rebels Summary: Track and report OpenClaw context window usage with a detailed breakdown of what's consuming tokens. Use when: user asks about context usage, token usage, \"h... Tags: latest:1.4.0 Version history: v1.1.4 | 2026-04-30T17:21:11.387Z | user Revert to stable — undo formatting changes that increased security score v1.1.3 | 2026-04-30T16:56:52.077Z | user Script no lon","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":960,"uniquenessScore":56,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-11T20:11:17.377Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-11T20:11:17.377Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-12T10:26:09.356Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}