session-state-trackerTracks and persists the current project, task, status, and next steps across OpenClaw session compaction and restarts via a SESSION_STATE.md file.
Install via ClawdBot CLI:
clawdbot install qsmtco/session-state-trackerVersion: 1.0.0
Author: qsmtco
License: MIT
The Session State Tracker solves the problem of context loss during OpenClaw session compaction and restarts. It provides a persistent SESSION_STATE.md file that keeps your current project, task, status, and next steps readily available.
SESSION_STATE.md after significant progressOpenClaw automatically compacts long-running sessions to stay within model context windows. Compaction summarizes older messages and removes them from active context. This leads to loss of conversational continuity:
Existing mechanisms (MEMORY.md, daily logs) are for curated long-term memory, not for current working context. We need a lightweight, always-present anchor that survives compaction.
The solution is built around a simple file (SESSION_STATE.md) and optional OpenClaw features:
SESSION_STATE.md โ A small Markdown file with YAML frontmatter storing current statememorySearch.experimental.sessionMemory = true) โ Enables memory_search to retrieve verbatim details from compacted messagesThe skill itself provides tools to read, write, and discover state. How these tools are used (automatic vs manual) is up to the agent's instructions (e.g., AGENTS.md) and the user's configuration choices.
SESSION_STATE.md lives in the workspace root:
---
project: "session-state-tracker"
task: "Implement skill with read/write/discover tools"
status: "active" # active | blocked | done
last_action: "Designed revised architecture"
next_steps:
- "Create skill skeleton"
- "Implement state.js"
- "Write CLI"
updated: "2026-02-14T23:20:00Z"
---
## Context
- Brief freeform notes, constraints, links, etc.
All frontmatter fields are plain strings, arrays, booleans, or numbers. The Context section is for human notes and is preserved but not used programmatically.
This section documents how to set up the Session State Tracker system in your OpenClaw installation. The skill itself is self-contained; the following steps are optional configuration that enhances automation.
Copy the skills/session-state-tracker/ directory into your workspace, or install via ClawHub:
clawhub install qsmtco/session-state-tracker
The skill provides three tools:
session_state_read โ reads the state filesession_state_write โ updates fields (auto-timestamps)session_state_discover โ uses memory_search to rebuild state from session transcriptsAnd a CLI: session-state (commands: show, set, refresh, clear).
No gateway restart is required for the skill itself (if commands.nativeSkills = "auto" it loads automatically; otherwise restart).
Privacy impact: This setting causes your conversation transcripts to be indexed into the memory vector store, making past messages searchable via memory_search. This increases the blast radius of your memory system. Only enable if you understand and accept this.
Why it's useful: The session_state_discover tool relies on memory_search to find recent task mentions. Without session indexing, discovery will return no results.
How to enable:
Patch your OpenClaw config (~/.openclaw/openclaw.json or openclaw.json in your profile):
{
"agents": {
"defaults": {
"memorySearch": {
"sources": ["memory", "sessions"],
"experimental": { "sessionMemory": true },
"sync": { "sessions": { "deltaBytes": 100000, "deltaMessages": 50 } }
}
}
}
}
Then restart the gateway:
openclaw gateway restart
Why: If you want the state file to be refreshed automatically before compaction, customize the memoryFlush.prompt to remind the agent to check SESSION_STATE.md.
How:
{
"agents": {
"defaults": {
"compaction": {
"memoryFlush": {
"prompt": "Check SESSION_STATE.md. If your current task has changed, update the file. Then write any lasting notes to memory/YYYY-MM-DD.md. Reply with NO_REPLY if nothing to store."
}
}
}
}
}
Restart the gateway after applying.
AGENTS.md with Maintenance RulesAdd the following section to your workspace AGENTS.md. This is not part of the skill; it's agent behavior configuration.
## Session State Maintenance
`SESSION_STATE.md` is your working memory across compaction and restarts.
**Format:**markdown
project: ""
task: ""
status: "active|blocked|done"
last_action: ""
next_steps: []
updated: "ISO timestamp"
**Rules:**
1. **At session start** (after reading `SOUL.md`, `USER.md`, `memory/`):
- If `SESSION_STATE.md` exists and `updated` is within the last 24 hours, read it and keep its contents in mind.
- If missing or older than 24 hours, use `memory_search(sources=["sessions"], query="project|task|working on")` to discover current focus, then write a fresh state file.
2. **After significant progress or a change in focus**:
- Call `session_state_write` (or write manually) to update `SESSION_STATE.md`.
- Always update the `updated` timestamp.
3. **When you see a `compaction` entry in the conversation**:
- Read `SESSION_STATE.md` to refresh your memory of the current task before responding.
- If the file feels out of date, run discovery (`session_state_discover`) and update it.
4. **During the pre-compaction flush** (if you customized the prompt):
- Verify `SESSION_STATE.md` matches the current focus; update if needed.
- Then write any lasting notes to `memory/YYYY-MM-DD.md`.
- Respond with `NO_REPLY`.
5. **Never delete** `SESSION_STATE.md`. If obsolete, set `status: "done"` and create a new file for new work.
If SESSION_STATE.md doesn't exist, create it with your current project:
session-state set project "my-project"
session-state set task "Describe current task"
session-state set status "active"
session-state set last_action "Initialized state"
session-state set next_steps '["Step 1", "Step 2"]'
Or manually edit the file.
SESSION_STATE.md if fresh; otherwise discovers from sessions.session_state_write or manual edit).NO_REPLY.compaction entry.AGENTS.md, the agent reads SESSION_STATE.md again to reโanchor.If you didn't enable session indexing or custom flush, you can still manually run session-state refresh when you suspect the state is stale, or edit the file directly. The agent should still follow the AGENTS.md rules to read the file at session start and after compaction (the rule about reading after a compaction entry works regardless of config; the agent just needs to have the habit to read the file).
session_state_readReads SESSION_STATE.md and returns all frontmatter fields plus body (the Context section).
Input: none
Output:
{
"project": "session-state-tracker",
"task": "Implement skill",
"status": "active",
"last_action": "Designed architecture",
"next_steps": ["Create skeleton", "Implement state.js"],
"updated": "2026-02-14T23:20:00Z",
"body": "Notes about constraints, links, etc."
}
session_state_writeUpdates one or more fields in SESSION_STATE.md. Automatically sets updated to current ISO timestamp unless provided.
Input: partial object, e.g., { "task": "New task", "status": "active" }
Output: { "success": true, "fields": ["task","status"], "updated": "2026-02-14T23:25:00Z" }
session_state_discoverUses memory_search (with sources: ["sessions"]) to synthesize a new state from recent conversation snippets. Automatically writes the discovered state to SESSION_STATE.md.
Input: optional { query, limit, minScore }
Output: state object (same shape as read) with a _meta field indicating snippet count and top source.
Note: Requires memory_search tool to be available and session transcript indexing to be enabled for meaningful results.
The skill installs a session-state binary:
# Show current state (including Context)
session-state show
# Update a single field (string; for arrays use JSON format)
session-state set task "Refine discovery algorithm"
session-state set next_steps '["Step A","Step B"]'
# Refresh state from session transcripts (calls discover)
session-state refresh
# Clear state (sets all fields empty)
session-state clear
Note: session-state refresh requires the memory_search tool to be available in the execution environment (when run via OpenClaw exec, it is injected; when run manually in a shell, it may fail unless you set up the environment).
memorySearch.experimental.sessionMemory = true) for discoverymemoryFlush.prompt for automatic pre-compaction refreshSkill runtime dependencies:
js-yaml (for robust YAML parsing)SESSION_STATE.md in the workspace root. It does not access files outside the workspace.session_state_discover uses the memory_search tool, which may use remote embedding APIs depending on your OpenClaw config. That is governed by your existing memory provider settings.exec, node, or sandbox escape.SESSION_STATE.md yourself and optionally use the CLI tools.| Symptom | Likely cause | Fix |
|---------|--------------|-----|
| session-state refresh fails with "memory_search not available" | Session indexing not enabled or running outside OpenClaw exec | Enable memorySearch.experimental.sessionMemory in config, or run via openclaw exec |
| State file not read after compaction | AGENTS.md rule missing or outdated | Ensure the "Session State Maintenance" section is present and includes rule #3 |
| YAML parse errors | Malformed frontmatter (e.g., missing colon, bad indentation) | Use a YAML validator; keep values simple (scalars, JSON arrays) |
| readState returns null | File missing or empty | Create initial SESSION_STATE.md with at least the frontmatter fields |
js-yaml for robust parsing.AGENTS.md rules rather than forced injection: respects OpenClaw's architecture where the agent decides when to read/write.session_state validate CLI commandThat's the complete skill. All configuration steps are clearly marked as optional, with privacy warnings. The skill itself is lowโprivilege and only operates on the state file.
AI Usage Analysis
Analysis is being generatedโฆ refresh in a few seconds.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection