openclaw - 💡(How to fix) Fix [Feature]: Session start hook — run an agentic turn on new session creation for context restoration [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#55050Fetched 2026-04-08 01:33:12
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Add a SESSION_START.md workspace hook (or equivalent config) that triggers a silent agentic turn at the start of each new session, allowing the agent to restore context before responding to the first user message.

Root Cause

Add a SESSION_START.md workspace hook (or equivalent config) that triggers a silent agentic turn at the start of each new session, allowing the agent to restore context before responding to the first user message.

RAW_BUFFERClick to expand / collapse

Summary

Add a SESSION_START.md workspace hook (or equivalent config) that triggers a silent agentic turn at the start of each new session, allowing the agent to restore context before responding to the first user message.

Problem to solve

When a session resets (idle timeout or daily reset), the agent starts completely fresh with no memory of prior conversation in that topic/channel. There is no automatic hook to restore context on new session creation.

  • BOOT.md only fires on gateway restart, not on session reset
  • HEARTBEAT.md is periodic, not session-scoped
  • Workspace files (AGENTS.md, MEMORY.md, etc.) are injected into every session, but there is no hook that runs only when a new session starts
  • The agent must manually call memory_search and read daily notes, but has no reliable trigger to do so at session start

Proposed solution

A SESSION_START.md workspace file (similar to HEARTBEAT.md) that is executed as a silent agentic turn at the beginning of each new session (new sessionId). This would allow the agent to:

  • Run memory_search for topic/channel-relevant prior context
  • Read today's daily note (memory/YYYY-MM-DD.md)
  • Load topic-specific memory files (memory/topics/<topic_id>.md)
  • Restore working context before responding to the first user message

The turn should be silent by default (NO_REPLY unless something needs to be surfaced). Configurable via agents.defaults.sessionStart.enabled and agents.defaults.sessionStart.prompt.

Alternatives considered

  1. BOOT.md: only triggers on gateway restart, not session reset
  2. HEARTBEAT.md: periodic polls, not tied to session lifecycle
  3. Manual AGENTS.md rules: unreliable, agent must remember to execute them
  4. Pre-compaction memory flush: only triggers when context window is near full, not on session start

Impact

Affected: All users with session resets (daily reset or idle timeout) — especially Telegram topic sessions and Discord threads Severity: Medium — blocks continuity, a core value proposition of the agent Frequency: Daily (every reset cycle) Consequence: Agent has no memory of prior work in a topic, users must re-explain context every day, defeats the purpose of persistent memory files

Evidence/examples

No response

Additional information

No response

extent analysis

Fix Plan

To implement the SESSION_START.md workspace hook, follow these steps:

  • Create a new file named SESSION_START.md in the workspace directory with the following content:
# SESSION_START.md
## Silent Agentic Turn

### Restore Context
- Run `memory_search` for topic/channel-relevant prior context
- Read today's daily note (`memory/YYYY-MM-DD.md`)
- Load topic-specific memory files (`memory/topics/<topic_id>.md`)

### Configuration
Configure `agents.defaults.sessionStart.enabled` and `agents.defaults.sessionStart.prompt` as needed.
  • Update the agent configuration to enable the SESSION_START.md hook:
agents:
  defaults:
    sessionStart:
      enabled: true
      prompt: "Restoring context..."
  • Modify the agent code to execute the SESSION_START.md hook at the beginning of each new session:
import os

def start_session(session_id):
    # Execute SESSION_START.md hook
    session_start_file = "SESSION_START.md"
    if os.path.exists(session_start_file):
        with open(session_start_file, "r") as f:
            session_start_content = f.read()
        # Run memory_search and load memory files
        # ...
        print("Context restored.")

Verification

To verify that the fix worked, test the following scenarios:

  • Start a new session and check if the agent restores context correctly.
  • Verify that the agent loads topic-specific memory files and daily notes.
  • Test the agents.defaults.sessionStart.enabled and agents.defaults.sessionStart.prompt configuration options.

Extra Tips

  • Make sure to update the SESSION_START.md file to include any additional context restoration logic as needed.
  • Consider adding logging or monitoring to track the execution of the SESSION_START.md hook and any errors that may occur.

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]: Session start hook — run an agentic turn on new session creation for context restoration [1 participants]