openclaw - 💡(How to fix) Fix Feature: onSessionEnd agent turn — let the agent run cleanup before session reset [2 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#73845Fetched 2026-04-29 06:14:19
View on GitHub
Comments
2
Participants
2
Timeline
2
Reactions
0
Author
Timeline (top)
commented ×2

When a session resets (via /new, idle timeout, or compaction), the agent has no opportunity to run a final turn before the session is destroyed. Session end protocol tasks (writing daily notes, saving context) can only be done via cron workarounds.

Root Cause

When a session resets (via /new, idle timeout, or compaction), the agent has no opportunity to run a final turn before the session is destroyed. Session end protocol tasks (writing daily notes, saving context) can only be done via cron workarounds.

Fix Action

Fix / Workaround

When a session resets (via /new, idle timeout, or compaction), the agent has no opportunity to run a final turn before the session is destroyed. Session end protocol tasks (writing daily notes, saving context) can only be done via cron workarounds.

  • session_end and before_reset hooks exist but are void plugin hooks (fire-and-forget for plugins)
  • Neither triggers an agent turn
  • Workaround: cron job to periodically write daily notes (imprecise, wastes tokens)
RAW_BUFFERClick to expand / collapse

Summary

When a session resets (via /new, idle timeout, or compaction), the agent has no opportunity to run a final turn before the session is destroyed. Session end protocol tasks (writing daily notes, saving context) can only be done via cron workarounds.

Current Behavior

  • session_end and before_reset hooks exist but are void plugin hooks (fire-and-forget for plugins)
  • Neither triggers an agent turn
  • Workaround: cron job to periodically write daily notes (imprecise, wastes tokens)

Proposed

Add configurable sessions.onEnd.agentTurn that gives the agent one final turn with full conversation history and tool access before session archival.

OpenClaw v2026.4.11

extent analysis

TL;DR

Implementing a configurable sessions.onEnd.agentTurn option could allow the agent to run a final turn before session destruction, enabling proper session end protocol tasks.

Guidance

  • Review the proposed sessions.onEnd.agentTurn feature to understand its potential to address the issue of running final tasks before session reset or destruction.
  • Consider the implications of adding this feature, including how it might interact with existing session_end and before_reset hooks.
  • Evaluate the trade-offs of implementing this solution versus continuing to use cron workarounds for tasks like writing daily notes.
  • Assess the potential benefits of having the agent run a final turn with full conversation history and tool access before session archival.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The proposed solution assumes that adding a configurable option for an agent turn before session end would be feasible and effective. However, the exact implementation and potential side effects are not specified.

Recommendation

Apply workaround: Implement the proposed sessions.onEnd.agentTurn feature to provide a more precise and token-efficient solution for handling session end tasks, rather than relying on cron jobs.

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 Feature: onSessionEnd agent turn — let the agent run cleanup before session reset [2 comments, 2 participants]