docs: update hooks load order, session-memory reset event, and bootstrap allowlists

This commit is contained in:
Jacob Tomlinson
2026-03-22 20:38:41 +00:00
parent 822c68a2d0
commit 773fb9cead
2 changed files with 17 additions and 16 deletions

View File

@@ -43,7 +43,7 @@ The hooks system allows you to:
OpenClaw ships with four bundled hooks that are automatically discovered:
- **💾 session-memory**: Saves session context to your agent workspace (default `~/.openclaw/workspace/memory/`) when you issue `/new`
- **💾 session-memory**: Saves session context to your agent workspace (default `~/.openclaw/workspace/memory/`) when you issue `/new` or `/reset`
- **📎 bootstrap-extra-files**: Injects additional workspace bootstrap files from configured glob/path patterns during `agent:bootstrap`
- **📝 command-logger**: Logs all command events to `~/.openclaw/logs/commands.log`
- **🚀 boot-md**: Runs `BOOT.md` when the gateway starts (requires internal hooks enabled)
@@ -84,10 +84,11 @@ Hooks run inside the Gateway process. Treat bundled hooks, managed hooks, and `h
Hooks are automatically discovered from these directories:
1. **Workspace hooks**: `<workspace>/hooks/` (per-agent, disabled by default until explicitly enabled)
2. **Managed hooks**: `~/.openclaw/hooks/` (user-installed, shared across workspaces)
3. **Extra hook directories**: `hooks.internal.load.extraDirs` (operator-configured shared hook folders)
4. **Bundled hooks**: `<openclaw>/dist/hooks/bundled/` (shipped with OpenClaw)
1. **Bundled hooks**: `<openclaw>/dist/hooks/bundled/` (shipped with OpenClaw)
2. **Plugin hooks**: hooks bundled inside installed plugins (see [Plugin hooks](/plugins/architecture#provider-runtime-hooks))
3. **Managed hooks**: `~/.openclaw/hooks/` (user-installed, shared across workspaces; can override bundled and plugin hooks)
4. **Extra hook directories**: `hooks.internal.load.extraDirs` (operator-configured shared hook folders; treated as managed)
5. **Workspace hooks**: `<workspace>/hooks/` (per-agent, disabled by default until explicitly enabled; cannot override hooks from other sources)
Workspace hooks can add new hook names for a repo, but they cannot override bundled, managed, or plugin-provided hooks with the same name.
@@ -412,8 +413,8 @@ Planned event types:
### 1. Choose Location
- **Workspace hooks** (`<workspace>/hooks/`): Per-agent, highest precedence
- **Managed hooks** (`~/.openclaw/hooks/`): Shared across workspaces
- **Workspace hooks** (`<workspace>/hooks/`): Per-agent; can add new hook names but cannot override bundled, managed, or plugin hooks with the same name
- **Managed hooks** (`~/.openclaw/hooks/`): Shared across workspaces; can override bundled and plugin hooks
### 2. Create Directory Structure
@@ -600,9 +601,9 @@ openclaw hooks disable command-logger
### session-memory
Saves session context to memory when you issue `/new`.
Saves session context to memory when you issue `/new` or `/reset`.
**Events**: `command:new`
**Events**: `command:new`, `command:reset`
**Requirements**: `workspace.dir` must be configured
@@ -611,7 +612,7 @@ Saves session context to memory when you issue `/new`.
**What it does**:
1. Uses the pre-reset session entry to locate the correct transcript
2. Extracts the last 15 lines of conversation
2. Extracts the last 15 user/assistant messages from the conversation (configurable)
3. Uses LLM to generate a descriptive filename slug
4. Saves session metadata to a dated memory file
@@ -674,8 +675,8 @@ Injects additional bootstrap files (for example monorepo-local `AGENTS.md` / `TO
- Paths are resolved relative to workspace.
- Files must stay inside workspace (realpath-checked).
- Only recognized bootstrap basenames are loaded.
- Subagent allowlist is preserved (`AGENTS.md` and `TOOLS.md` only).
- Only recognized bootstrap basenames are loaded (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md`, `MEMORY.md`, `memory.md`).
- For subagent/cron sessions a narrower allowlist applies (`AGENTS.md`, `TOOLS.md`, `SOUL.md`, `IDENTITY.md`, `USER.md`).
**Enable**:

View File

@@ -38,7 +38,7 @@ Ready:
🚀 boot-md ✓ - Run BOOT.md on gateway startup
📎 bootstrap-extra-files ✓ - Inject extra workspace bootstrap files during agent bootstrap
📝 command-logger ✓ - Log all command events to a centralized audit file
💾 session-memory ✓ - Save session context to memory when /new command is issued
💾 session-memory ✓ - Save session context to memory when /new or /reset command is issued
```
**Example (verbose):**
@@ -84,14 +84,14 @@ openclaw hooks info session-memory
```
💾 session-memory ✓ Ready
Save session context to memory when /new command is issued
Save session context to memory when /new or /reset command is issued
Details:
Source: openclaw-bundled
Path: /path/to/openclaw/hooks/bundled/session-memory/HOOK.md
Handler: /path/to/openclaw/hooks/bundled/session-memory/handler.ts
Homepage: https://docs.openclaw.ai/automation/hooks#session-memory
Events: command:new
Events: command:new, command:reset
Requirements:
Config: ✓ workspace.dir
@@ -263,7 +263,7 @@ global `--yes` to bypass prompts in CI/non-interactive runs.
### session-memory
Saves session context to memory when you issue `/new`.
Saves session context to memory when you issue `/new` or `/reset`.
**Enable:**