openclaw - 💡(How to fix) Fix Feature: ephemeral sessions — dispose on completion instead of retention timer [1 comments, 1 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#60745Fetched 2026-04-08 02:47:41
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
commented ×1subscribed ×1

With recurring cron jobs running every 15 minutes and webhook hooks firing on each email, session stores grow quickly. Duration-based retention is the wrong primitive for fire-and-forget workloads — completion-based disposal would be cleaner and more efficient.

Error Message

  • On run completion (success or error), the session entry is removed from sessions.json

Root Cause

With recurring cron jobs running every 15 minutes and webhook hooks firing on each email, session stores grow quickly. Duration-based retention is the wrong primitive for fire-and-forget workloads — completion-based disposal would be cleaner and more efficient.

Fix Action

Fix / Workaround

  • Very short retention (sessionRetention: "1m"): works but is a workaround — still timer-based, still creates entries that linger briefly, and the cleanup depends on the next maintenance cycle running.
  • maxEntries cap: reactive eviction, not proactive cleanup. Doesn't express intent.

Code Example

openclaw cron add --session isolated --ephemeral --message "Check email" ...

---

{ "sessionTarget": "isolated", "ephemeral": true }

---

{
  match: { path: "gmail" },
  action: "agent",
  sessionKey: "hook:gmail:{{messages[0].id}}",
  ephemeral: true,  // dispose session after run
}
RAW_BUFFERClick to expand / collapse

Problem

Cron jobs and webhook/hook-triggered agent runs create sessions that linger in the session store until a retention timer expires (cron.sessionRetention or session.maintenance.pruneAfter). For isolated, one-shot workloads like email processing or webhook handlers, these sessions have no value after the run completes — there is no follow-up message, no context to preserve.

This leads to session store bloat. In our setup, a 15-minute email-catchup cron accumulated 100+ stale sessions before we noticed and configured aggressive retention + enforcement. The current options are:

  • cron.sessionRetention (duration-based cleanup for cron sessions)
  • session.maintenance.pruneAfter (duration-based cleanup for all sessions)
  • session.maintenance.maxEntries (cap-based eviction)

None of these express the intent: "this session is done, clean it up now."

Proposed solution

Add an ephemeral session mode that disposes of the session entry (and optionally its transcript) immediately after the agent turn completes.

Possible surface areas:

Cron jobs

openclaw cron add --session isolated --ephemeral --message "Check email" ...

Or a JSON field:

{ "sessionTarget": "isolated", "ephemeral": true }

Hook mappings

{
  match: { path: "gmail" },
  action: "agent",
  sessionKey: "hook:gmail:{{messages[0].id}}",
  ephemeral: true,  // dispose session after run
}

Behavior

  • On run completion (success or error), the session entry is removed from sessions.json
  • Transcript file is either deleted or moved to an archive path (configurable)
  • Run log entry in cron/runs/ is unaffected (still governed by cron.runLog.*)
  • No change to non-ephemeral sessions

Alternatives considered

  • Very short retention (sessionRetention: "1m"): works but is a workaround — still timer-based, still creates entries that linger briefly, and the cleanup depends on the next maintenance cycle running.
  • maxEntries cap: reactive eviction, not proactive cleanup. Doesn't express intent.

Context

With recurring cron jobs running every 15 minutes and webhook hooks firing on each email, session stores grow quickly. Duration-based retention is the wrong primitive for fire-and-forget workloads — completion-based disposal would be cleaner and more efficient.

extent analysis

TL;DR

Implement an ephemeral session mode to dispose of session entries immediately after agent turn completion.

Guidance

  • Introduce an ephemeral flag in cron jobs and hook mappings to indicate sessions that should be disposed of after completion.
  • Update the session management logic to remove session entries from sessions.json and handle transcript files accordingly when the ephemeral flag is set.
  • Consider adding configuration options to control the behavior of ephemeral sessions, such as whether to delete or archive transcript files.
  • Evaluate the impact of ephemeral sessions on run log entries in cron/runs/ to ensure they remain unaffected.

Example

{
  "sessionTarget": "isolated",
  "ephemeral": true
}

This example shows how to set the ephemeral flag in a JSON field for a cron job or hook mapping.

Notes

The proposed solution aims to address the issue of session store bloat by introducing a new primitive for completion-based disposal. However, the implementation details and potential edge cases need to be carefully considered to ensure a robust and efficient solution.

Recommendation

Apply the workaround by implementing the proposed ephemeral session mode, as it directly addresses the issue of session store bloat and provides a more efficient and cleaner solution than the current duration-based retention options.

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