openclaw - 💡(How to fix) Fix sessions.json index bloat: skillsSnapshot duplicated per session entry [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77932Fetched 2026-05-06 06:19:10
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
closed ×1commented ×1

sessions.json (per-agent session index) stores a full skillsSnapshot blob in every entry. This duplicates the entire skills catalog across all sessions, producing a multi-megabyte index for installs with many skills.

Root Cause

sessions.json (per-agent session index) stores a full skillsSnapshot blob in every entry. This duplicates the entire skills catalog across all sessions, producing a multi-megabyte index for installs with many skills.

Code Example

$ ls -la ~/.openclaw/agents/main/sessions/sessions.json
-rw-------  1 user  staff  13368440 ...  sessions.json   # 12.7 MB
RAW_BUFFERClick to expand / collapse

Summary

sessions.json (per-agent session index) stores a full skillsSnapshot blob in every entry. This duplicates the entire skills catalog across all sessions, producing a multi-megabyte index for installs with many skills.

Reproduction

On a host running OpenClaw with the main agent and ~140 active session entries (mix of cron/discord/slack/subagent/etc.):

$ ls -la ~/.openclaw/agents/main/sessions/sessions.json
-rw-------  1 user  staff  13368440 ...  sessions.json   # 12.7 MB

Field-size aggregate across all 142 entries (Python json.dumps length per field, summed):

FieldMB% of file
skillsSnapshot8.6067.7%
systemPromptReport1.048.2%
compactionCheckpoints0.070.5%
all others combined<0.05<0.4%

Per-entry skillsSnapshot breakdown (sample from agent:main:cron:8f74506f-...):

  • prompt: 17,308 chars (rendered system prompt skills section)
  • skills: 4,388 chars (slug list)
  • resolvedSkills: 87,601 chars ← dominant bloat, identical across all 142 entries
  • version: 13 chars

So 142 × ~87KB of duplicated resolvedSkills content = ~12 MB of avoidable index size.

Impact

  • sessions.json is read/rewritten on session lifecycle transitions; rewriting a 12.7MB JSON file on every state change is expensive and amplifies session-write-lock contention. (We've observed [session-write-lock] releasing lock held for 18082ms (max=15000ms) during high-load periods.)
  • Memory-resident copy in the gateway process is similarly inflated.
  • For users with many skills (this install has ~140), the duplication is roughly proportional to skill_count × session_count.

Proposed fix

Three options, in increasing implementation complexity:

  1. Omit resolvedSkills from session-index entries. It's reconstructable from current skills config when needed. Keep prompt and skills slug list if those are needed at restore-time.
  2. Store snapshot once globally, reference by hash. Write skillsSnapshot to e.g. ~/.openclaw/agents/main/skills-snapshots.json keyed by sha256 of resolved content. Session entries store skillsSnapshotRef: "sha256:...".
  3. Externalize per-session. Move skillsSnapshot into the per-session file under sessions/<id>.json rather than the index.

Option 1 is simplest and likely sufficient; option 2 preserves point-in-time reproducibility (useful if skills change after a session was started) without the duplication.

Additional question

Cron-keyed entries (agent:main:cron:UUID) account for 21% of the index by count (29/142 in this install) but the same per-entry size as everything else. Is there a reason cron sessions need a slot in sessions.json at all? They're isolated by design and don't carry persistent conversation state across runs. Could be a separate ticket.

Environment

  • OpenClaw installed from npm at /opt/homebrew/lib/node_modules/openclaw/ (macOS, M-series, node v22)
  • Single-user setup, ~140 skills in catalog
  • Diagnostic timestamp: 2026-05-05

extent analysis

TL;DR

Omitting resolvedSkills from session-index entries or storing the snapshot once globally and referencing it by hash can help reduce the size of the sessions.json file.

Guidance

  • Consider implementing one of the proposed fixes to reduce the duplication of skillsSnapshot content across all session entries.
  • Evaluate the necessity of storing cron sessions in sessions.json, as they are isolated and do not carry persistent conversation state.
  • Measure the impact of the proposed fixes on the size of the sessions.json file and the performance of session lifecycle transitions.
  • Consider the trade-offs between the simplicity of omitting resolvedSkills and the potential benefits of preserving point-in-time reproducibility with the other proposed fixes.

Example

No code snippet is provided as the issue does not require a specific code change, but rather a design decision on how to store and reference skillsSnapshot content.

Notes

The proposed fixes assume that the resolvedSkills content is not necessary for session restoration or other critical functionality. If this content is required, an alternative solution may be needed.

Recommendation

Apply workaround by omitting resolvedSkills from session-index entries, as it is the simplest and likely sufficient solution, and reconstruct the content from the current skills config when needed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix sessions.json index bloat: skillsSnapshot duplicated per session entry [1 comments, 2 participants]