openclaw - 💡(How to fix) Fix Feature: Add config for automatic bootstrap execution [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#49956Fetched 2026-04-08 01:00:49
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Participants
Timeline (top)
commented ×1cross-referenced ×1

Code Example

{
  "agents": {
    "defaults": {
      "preSessionScripts": [
        "bash ~/.openclaw/workspace/scripts/generate-boot-context.sh",
        "bash ~/.openclaw/workspace/scripts/memory-queue-sync.sh"
      ]
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem: Currently, bootstrap/context injection relies on models voluntarily reading workspace files and running scripts. This is unreliable - models can skip or forget to run bootstrap scripts, leading to context loss.

Proposed Solution: Add a config option like:

{
  "agents": {
    "defaults": {
      "preSessionScripts": [
        "bash ~/.openclaw/workspace/scripts/generate-boot-context.sh",
        "bash ~/.openclaw/workspace/scripts/memory-queue-sync.sh"
      ]
    }
  }
}

These scripts would run automatically before the model sees the first user message, injecting the output directly into context.

Alternative: I created a plugin using the session_start hook, but a built-in config option would be cleaner for this use case.

Use Case: The Emanatis Group uses OpenClaw for institutional memory with PostgreSQL, Redis, and Lyra-cortex services. Cross-channel continuity requires bootstrap scripts to run on every session. Currently this relies on model compliance, which is unreliable.

Related:

  • Plugin hook system already supports session_start
  • onSessionStart exists for auth-profiles but not for custom scripts

Would you be willing to submit a PR? Yes, if maintainers approve the approach.

extent analysis

Fix Plan

To address the issue of unreliable context injection, we will implement a config option to run pre-session scripts automatically.

Step-by-Step Solution:

  1. Add config option: Introduce a new config option preSessionScripts under agents.defaults to store the list of scripts to be executed before the model sees the first user message.
  2. Modify session initialization: Update the session initialization code to read the preSessionScripts config option and execute the scripts before starting the session.
  3. Inject script output into context: Modify the script execution code to capture the output of the scripts and inject it into the context.

Example Code:

import subprocess

# Load config
config = {
  "agents": {
    "defaults": {
      "preSessionScripts": [
        "bash ~/.openclaw/workspace/scripts/generate-boot-context.sh",
        "bash ~/.openclaw/workspace/scripts/memory-queue-sync.sh"
      ]
    }
  }
}

# Execute pre-session scripts and inject output into context
def execute_pre_session_scripts(context):
    for script in config["agents"]["defaults"]["preSessionScripts"]:
        output = subprocess.check_output(script, shell=True)
        context.update({f"script_{script}": output.decode("utf-8")})

# Initialize session
def initialize_session():
    context = {}
    execute_pre_session_scripts(context)
    # Start session with the updated context
    start_session(context)

Verification

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

  • Run a session with the preSessionScripts config option set and verify that the scripts are executed and their output is injected into the context.
  • Run a session without the preSessionScripts config option set and verify that the scripts are not executed.

Extra Tips

  • Ensure that the scripts specified in the preSessionScripts config option have the necessary permissions and dependencies to run successfully.
  • Consider adding error handling for script execution failures to prevent session initialization issues.

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: Add config for automatic bootstrap execution [1 comments, 2 participants]