Install
openclaw skills install certainlogic-context-tokenreducerPrevent AI session token bloat and runaway costs. Tracks query count per session, warns at a configurable threshold, auto-writes a dense handoff summary before reset, and reads it back on the next session start — so no work is lost and every session starts lean. Without session resets, a standard OpenClaw session can balloon from 18K to 400K+ input tokens, multiplying cost 22x. This skill prevents that automatically. Use when managing long AI sessions, reducing token burn, keeping context lean, or implementing session hygiene for any OpenClaw-based agent. Triggers on phrases like "context management", "session reset", "token bloat", "query counter", "handoff", "save context", or "/new". Built by CertainLogic.
openclaw skills install certainlogic-context-tokenreducerKeeps sessions lean. Tracks query count, warns before context bloats, saves a handoff summary so work continues cleanly in the next session.
session_query_count.txt every turnhandoff.md and alert the user/new; next session reads and deletes handoff.md| File | Purpose |
|---|---|
session_query_count.txt | Integer. Increment each turn. Create if missing (default 0). |
handoff.md | Workspace root. Written at threshold. Read + deleted on next session start. |
1. Read session_query_count.txt (default 0 if missing)
2. Increment by 1
3. Write back
4. If count == THRESHOLD: trigger handoff flow
Default threshold: 10. Configurable per deployment.
handoff.md — see handoff-format.md for exact spec⚠️ 10 queries in — context is getting heavy. Handoff saved. Run
/newwhen ready to continue.
1. Check if handoff.md exists
2. If exists AND file is < 3 hours old:
a. Read it
b. Apply context to current session
c. Delete handoff.md
3. Reset session_query_count.txt to 0
When the user says "BTW", "switching gears", "new topic", or starts a clearly unrelated task:
handoff.md immediately (don't wait for threshold)/new when ready"Session context is cumulative. Every prior message, tool call, and assistant response is re-sent on every new query. Without resets, a lean 18K-token session becomes 50K–400K+ within hours.
See token-math.md for cost impact data and reset savings estimates.
| Command | Behavior |
|---|---|
/new or /reset | User-triggered. New session starts; skill reads handoff.md if present. |
/handoff | Explicit handoff write. Same as threshold flow, on demand. |
/counter | Report current query count and threshold. |
Override defaults in AGENTS.md or equivalent workspace config:
- CONTEXT_THRESHOLD: 10 # Queries before warning (default: 10)
- HANDOFF_TTL_HOURS: 3 # Hours before handoff.md is considered stale (default: 3)
| Without this skill | With this skill |
|---|---|
| Sessions balloon to 400K+ tokens | Sessions stay under 25K |
| Cost multiplies 22x over a day | Cost stays near baseline |
| Work lost on manual /new resets | Handoff auto-saved, resumed next session |
| No signal before context degrades | Warning fires before quality drops |
See token-math.md for the full cost breakdown.
Built by CertainLogic — trusted fact infrastructure for AI agents.